Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Manikandaraja
Explorer
Hello Colleagues,

We often used MDC Mass Processing Fiori App for BP's and Materials mass processing.

At the end of each consolidation process, we may create a MDG change request to proceed with Governance Process.

When we open that particular change request for further processing, our custom validation logics for custom Entities will get trigger in MDG through "USMD_RULE_SERVICE" BADI (if we already developed).

At this stage in MDG, correcting or entering the required data for custom entity one by one could be a difficult task for a requester.

At the Validation step in MDC the SAP's standard validation will be performed with the loaded data.

But how the custom entity data can be validated within MDC? So in this blog, we will see how to perform a custom validation rule at Validation Step in MDC itself, so that the change request can be created with all the required data for custom entity.

1. Extension for BP in MDC with Custom table/entity


By following below SAP how to document we can extend MDC with custom entity/table


https://www.sap.com/documents/2017/08/18cfbb67-cd7c-0010-82c7-eda71af511fa.html

2. MDC Custom Model Class


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


Additionally, we must redefine CHECK_BUSINESS_PARTNER_DATA method

CHECK_BUSINESS_PARTNER_DATA : This method requires to validate the loaded custom entity data and append a return messages to exception class CX_MDC_MODEL.

3. Methods to be Redefined in Custom Model Class



Model Class Implementation


Checking Custom Entity Data while looping and appending return messages.



Example to validate single attribute value and returning error message


 

4. Code Snippet


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.

 

5. Now we can test our custom validation messages in MDC




Custom Validation Message


 

Note: After the custom validation messages, Requester can edit the data in MDC itself or he/she can proceed further, so that the "Filter & Remove" step will exclude the incomplete data from current process and creates new process ID for the error records.

Conclusion: I hope from the above approach we can validate the custom entities data within MDC itself, before creating MDG change request. In this way we can avoid the custom validation error messages when mass CR getting processed in MDG.

 

Thank you for reading my blog, I hope this might help in some scenarios.

Please drop you comments and valuable suggestions 🙂

 

Thank you

Best Regards

Mani

 
2 Comments
Labels in this area