on 2007 Apr 11 7:10 AM
Hello all,
I am implementing BAdi HRPAD00INFTY for infotype 0008.
The requirement is, whenever user checks/saves Infotype 8, System should look out FTE wage type exists or not. If it exists then amount should be calculated and get updates for that wage type. If wage type not found insert wagetype FTE and amount in the infotype for the employee.
I have calculated amount in method AFTER_INPUT of the BAdi. I am trying to reflect the updated amount on the screen using method CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP. but it is not working.
I also tried to use the same method CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP in BEFORE_OUTPUT method.
Can somebody help me on this?
Any pointer would be helpful and appreciated.
Thanks in advance.
Best Regards,
Dharitree
Hi,
I have found the solution to be able to update the infotype from the method (PBO or PAI)
Create the followings methods as private in your class :
Parameters :
IV_FIELD Importing Type FIELDNAME
IV_VALUE Importing Type ANY
Code :
METHOD update_field_value.
DATA: lv_field_name TYPE string.
FIELD-SYMBOLS: <fs_field_value> TYPE any.
* structure field
CONCATENATE '(' sy-cprog ')' iv_field INTO lv_field_name.
ASSIGN (lv_field_name) TO <fs_field_value>.
IF sy-subrc = 0.
<fs_field_value> = iv_value.
ENDIF.
UNASSIGN <fs_field_value>.
* class attribute
CONCATENATE 'ME->AS_' iv_field INTO lv_field_name.
ASSIGN (lv_field_name) TO <fs_field_value>.
IF sy-subrc = 0.
<fs_field_value> = iv_value.
ENDIF.
UNASSIGN <fs_field_value>.
ENDMETHOD.
Parameters:
INNNN Importing Type PRELP
Code :
METHOD update_all_fields_values.
DATA: lv_field TYPE fieldname,
lr_struc TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: <fs_field> TYPE any,
<lr_compo> TYPE LINE OF abap_compdescr_tab.
DATA lv_type(5) TYPE c.
FIELD-SYMBOLS <pnnnn> TYPE any.
DATA dref TYPE REF TO data.
CONCATENATE 'P' innnn-infty INTO lv_type.
CREATE DATA dref TYPE (lv_type).
ASSIGN dref->* TO <pnnnn>.
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = innnn
IMPORTING
pnnnn = <pnnnn>.
lr_struc ?= cl_abap_typedescr=>describe_by_name( lv_type ).
IF lr_struc IS BOUND.
LOOP AT lr_struc->components[] ASSIGNING <lr_compo>.
ASSIGN COMPONENT <lr_compo>-name OF STRUCTURE <pnnnn> TO <fs_field>.
IF sy-subrc = 0.
CONCATENATE 'P' innnn-infty '-' <lr_compo>-name INTO lv_field.
CALL METHOD update_field_value( iv_field = lv_field iv_value = <fs_field> ).
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
Each times, in your PBO method or PAI method you call the cl_hr_pnnnn_type_cast=>pnnnn_to_prelp method, add the following call after :
me->update_all_fields_values( innnn = innnn ).
Hope it will help !
Best regards,
Mathieu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
97 | |
9 | |
8 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.