Hi SCN Folks,
Hope you guys are doing great 🙂
Note: This blog does not include execution screenshots.
This post outlines a custom development approach in SAP Master Data Governance (MDG) to make the Tax Number field mandatory for specific Groupings. The logic is implemented using the enhancement framework via BADI: USMD_RULE_SERVICE, specifically through the method CHECK_ENTITY.
Prerequisite: A working knowledge of BADI USMD_RULE_SERVICE and ABAP development is required to follow this implementation.
Development Details
Target Groupings: ZSGP, ZSGCMessage Class: ZMDGS_MSG_CLASSMessage Number: 001Message Type: EMessage Text: Tax Number is Mandatory !!!BADI Method Implemented: IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY
The validation logic is written directly in the method CHECK_ENTITY
This ensures that when the specified groupings are selected, the system enforces the presence of a Tax Number and raises a custom message if it’s missing.
Code:
METHOD if_ex_usmd_rule_service~check_entity.
CALL METHOD io_model->read_entity_data_all
EXPORTING
i_fieldname = ‘BP_HEADER’
if_active = abap_false
i_crequest = id_crequest ” Change Request
IMPORTING
et_data_entity = DATA(lt_data). ” Data for Entity Types
.
READ TABLE lt_data INTO DATA(ls_data) WITH KEY usmd_entity = ‘BP_HEADER’ usmd_entity_cont = ‘ ‘ struct = ‘KATTR’.
ASSIGN ls_data-r_t_data->* TO FIELD-SYMBOL(<lt_data>).
LOOP AT <lt_data> ASSIGNING FIELD-SYMBOL(<ls_data>).
ASSIGN COMPONENT ‘BU_GROUP’ OF STRUCTURE <ls_data> TO FIELD-SYMBOL(<lv_group>).
IF <lv_group> IS ASSIGNED AND
<lv_group> EQ ‘ZSGP’ OR
<lv_group> EQ ‘ZSGC’.
READ TABLE lt_data INTO ls_data WITH KEY usmd_entity = ‘BP_HEADER’ usmd_entity_cont = ‘BP_TAXNUM’ struct = ‘KATTR’.
IF sy-subrc <> 0.
et_message = VALUE #( ( msgid = ‘ZMDGS_MSG_CLASS’ msgty = ‘E’ msgno = ‘001’ ) ).
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Thank You,
Sandeep Suggu.
SAP Community Profile | SAP Profile | LinkedIn
Hi SCN Folks, Hope you guys are doing great 🙂Note: This blog does not include execution screenshots.This post outlines a custom development approach in SAP Master Data Governance (MDG) to make the Tax Number field mandatory for specific Groupings. The logic is implemented using the enhancement framework via BADI: USMD_RULE_SERVICE, specifically through the method CHECK_ENTITY.Prerequisite: A working knowledge of BADI USMD_RULE_SERVICE and ABAP development is required to follow this implementation.Development DetailsTarget Groupings: ZSGP, ZSGCMessage Class: ZMDGS_MSG_CLASSMessage Number: 001Message Type: EMessage Text: Tax Number is Mandatory !!!BADI Method Implemented: IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY The validation logic is written directly in the method CHECK_ENTITYThis ensures that when the specified groupings are selected, the system enforces the presence of a Tax Number and raises a custom message if it’s missing.Code: METHOD if_ex_usmd_rule_service~check_entity.
CALL METHOD io_model->read_entity_data_all
EXPORTING
i_fieldname = ‘BP_HEADER’
if_active = abap_false
i_crequest = id_crequest ” Change Request
IMPORTING
et_data_entity = DATA(lt_data). ” Data for Entity Types
.
READ TABLE lt_data INTO DATA(ls_data) WITH KEY usmd_entity = ‘BP_HEADER’ usmd_entity_cont = ‘ ‘ struct = ‘KATTR’.
ASSIGN ls_data-r_t_data->* TO FIELD-SYMBOL(<lt_data>).
LOOP AT <lt_data> ASSIGNING FIELD-SYMBOL(<ls_data>).
ASSIGN COMPONENT ‘BU_GROUP’ OF STRUCTURE <ls_data> TO FIELD-SYMBOL(<lv_group>).
IF <lv_group> IS ASSIGNED AND
<lv_group> EQ ‘ZSGP’ OR
<lv_group> EQ ‘ZSGC’.
READ TABLE lt_data INTO ls_data WITH KEY usmd_entity = ‘BP_HEADER’ usmd_entity_cont = ‘BP_TAXNUM’ struct = ‘KATTR’.
IF sy-subrc <> 0.
et_message = VALUE #( ( msgid = ‘ZMDGS_MSG_CLASS’ msgty = ‘E’ msgno = ‘001’ ) ).
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD. Thank You, Sandeep Suggu.SAP Community Profile | SAP Profile | LinkedIn Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog