This blog will give an overview of sending Provider Contract Custom fields of CRM Order to S4 HANA Provider Contract.
Step1 : Create AET field in SAP CRM using Administrator Business Role.
Enhanced Object – PROVIDER_CONTRACT , Field name – ZZFIELD using the AET Application Enhancement tool in SAP CRM. In CRMD_ORDERADM_I table Object – ORDERADM_I
Step 2 : Create Z Implementation class of BADI – CRM_ISX_ERP_CONTRACT and redefine method map_create & add custom logic to send the data into CT_ITEM_PARAMETER.
Step 3 : Create the same field ZZFIELD in S4 HANA and Append fields in the standard structures – CI_DFKK_VT_I, CI_FKK_VT_I_DI for saving the provider contract data into table DFKK_VT_I
Step 4 : Create Z Implementation class of BADI – FICA_CONTRACT_COL_MAINTAIN and redefine method contract_change & add custom logic to save the data.
Method IF_CRM_ISX_ERP_CONTRACT~MAP_CREATE.
*Pass Item guid
CALL FUNCTION 'CRM_PROVIDER_ITEM_STRUCT'
EXPORTING
iv_item_guid = item_guid
IMPORTING
ev_main_rate_plan_item = rateplan_guid
et_orderadm_i = orderadm_i
et_ist_ita3_ext = ist
EXCEPTION
error_occured = 1
OTHERS = 2.
IF sy-subrc EQ 0.
DATA(ls_orderadm_i) = orderadm_i[ guid = ls_item-item_guid ].
IF sy-subrc EQ 0.
DATA(ls_ist) = ist[ ref_guid = rateplan_guid ].
IF sy-subrc EQ 0.
APPEND VALUE #( contract_id = ls_ist-a3extref contract_item_id = ls_ist-cont_itm_id
name = 'ZZFIELD' value = ls_orderadm_i-zzfield ) TO ct_item_parameter.
ENDIF. ENDIF. ENDIF.
ENDMETHOD.
METHOD if_fica_contract_maintain_badi~contract_change.
DATA : ls_data TYPE ci_fkk_vt_i_di,
lr_fields TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS <ls_any> TYPE any.
TRY.
lr_fields ?= cl_abap_typedescr=>describe_by_data(ls_data).
CATCH cx_sy_move_cast_error.
ENDTRY.
DATA(lt_components) = lr_fields->components.
LOOP AT is_contract-items INTO ls_contract.
LOOP AT ls_contract-parameters into ls_items.
READ TABLE lt_components into data(ls_component) WITH KEY name = ls_items-parameter-name.
IF sy-subrc EQ 0.
ASSIGN COMPONENT ls_component-name OF STRUCTURE ls_data to <ls_any>.
IF sy-subrc EQ 0.
<ls_any> = ls_items-parameter-value.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
IF ls_data IS NOT INITIAL.
READ TABLE ct_vt_item_data ASSIGNING FIELD-SYMBOL(<ls_item>) WITH KEY vtpid = ls_contract-item-contract_item_id.
IF sy-subrc EQ 0.
<ls_vt_item>-zzfield = ls_data-zzfield.
ENDIF.
ENDIF.