By following below SAP how to document we can extend MDC with custom entity/table
From the above document, we created a custom model class ZCL_MDC_MODEL_BP that inherits from class CL_MDC_MODEL_BP and the following methods were redefined:
READ_ALL_DATA
MAP_EXTENSIONS_2API
SAVE_BUSINESS_PARTNER_ACTIVE
METHOD check_business_partner_data.
DATA: lo_bp_2_sta TYPE REF TO cl_badi_base,
lv_execute_mdg_checks TYPE abap_bool VALUE abap_false,
lx_sta_exception TYPE REF TO cx_mdg_bs_bp_sta_error,
lt_messages TYPE bapirettab,
ls_message_key TYPE scx_t100key,
lt_bapi_messages TYPE bapirettab,
ls_bapi_message TYPE bapiret2,
lt_address_data TYPE bus_ei_bupa_address_t,
ls_address_data TYPE bus_ei_bupa_address_t.
* Calling Super
TRY.
CALL METHOD super->check_business_partner_data.
CATCH cx_mdc_model .
ENDTRY.
CHECK me->mt_cvi_ei_extern IS NOT INITIAL.
* Custom Attributes Validation
LOOP AT me->mt_cvi_ei_extern ASSIGNING FIELD-SYMBOL(<ls_cvi_ei_extern>).
CLEAR : lt_messages,
ls_message_key.
CHECK <ls_cvi_ei_extern>-data-partner-header-object_instance-bpartnerguid IS NOT INITIAL
AND <ls_cvi_ei_extern>-data-partner-header-object_instance-bpartnerguid CN '0'.
READ TABLE me->mt_bp_keys ASSIGNING FIELD-SYMBOL(<ls_bp_keys>)
WITH KEY partner_guid = CONV bu_partner_guid( <ls_cvi_ei_extern>-data-partner-header-object_instance-bpartnerguid ).
CHECK sy-subrc = 0.
READ TABLE me->mr_but000_prc->* ASSIGNING FIELD-SYMBOL(<ls_but000_prc>)
WITH KEY process_id = process_id
process_step_no = step_number
source_key = <ls_bp_keys>-source_key.
IF <ls_cvi_ei_extern>-data-vendor-central_data-central-data-ktokk EQ 'PAY'
lt_address_data = <ls_cvi_ei_extern>-data-partner-central_data-address-addresses.
IF lt_address_data IS NOT INITIAL.
READ TABLE lt_address_data INTO DATA(ls_address_data_temp) INDEX sy-index.
IF sy-subrc EQ 0.
ASSIGN COMPONENT 'DATA' OF STRUCTURE ls_address_data_temp TO FIELD-SYMBOL(<ls_address_data>).
ENDIF.
ENDIF.
SELECT SINGLE ZATTRIBUTE FROM ZTABLE INTO @DATA(lv_variable) WHERE lifnr EQ @<ls_cvi_ei_extern>-data-vendor-header-object_instance-lifnr.
IF lv_variable IS INITIAL.
ls_bapi_message-type = 'E'.
ls_bapi_message-id = ''. " Your Custom Message Class
ls_bapi_message-number = ''. " Message ID
ls_bapi_message-message_v1 = <ls_cvi_ei_extern>-data-vendor-header-object_instance-lifnr.
APPEND ls_bapi_message TO lt_bapi_messages.
me->log->subordinate_log( iv_source_system = <ls_but000_prc>-source_system iv_source_id = <ls_but000_prc>-source_id )->add_bapi_messages( lt_bapi_messages ).
CLEAR lt_bapi_messages.
ENDIF.
ENDIF.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |