SAP MDG · VALIDATION DERIVATION
How do I implement the real validation logic in IF_EX_USMD_RULE_SERVICE~CHECK_EDITION_FINAL for SAP MDG instead of leaving it empty?
Implement the BAdI in SE18/SE19, bind it to a Z* class that implements IF_EX_USMD_RULE_SERVICE, and put edition-specific checks in CHECK_EDITION_FINAL only if you need edition-level validation. For simple entity checks, use CHECK_ENTITY instead; for an empty edition hook, leaving the method as a retained framework stub is valid.
Implement the BAdI in SE18/SE19, bind it to a Z* class that implements IF_EX_USMD_RULE_SERVICE, and put edition-specific checks in CHECK_EDITION_FINAL only if you need edition-level validation. For simple entity checks, use CHECK_ENTITY instead; for an empty edition hook, leaving the method as a retained framework stub is valid.
From the retrieved guide, the correct way to implement a real MDG rule-service validation is to create the BAdI implementation in SE19, bind it to an implementing class, and code the required interface method with message handling through ET_MESSAGE. For edition-specific logic, CHECK_EDITION_FINAL is the right lifecycle hook when you want a validation at the end of the edition phase. The retrieved sample for this method is an intentionally empty stub, so any real logic must follow the standard USMD_RULE_SERVICE pattern used for validation methods: guard by context, evaluate the records, and append usmd_s_message rows when a rule fails.
Process flow
- Open SE18 and display BAdI definition
USMD_RULE_SERVICE. - Check the interface name IF_EX_USMD_RULE_SERVICE and the method intent.
- Open SE19 and create the BAdI implementation.
- Assign a Z* implementation class and save it to a transport request.
- Implement CHECK_EDITION_FINAL only if you need edition-final validation logic.
- Build validation messages in ET_MESSAGE using
USMD_S_MESSAGEwhen a rule fails. - Activate the class and BAdI implementation.
- Test the MDG scenario and debug whether CHECK_EDITION_FINAL is called.
Referenced tables
| Object | Purpose |
|---|---|
USMD_S_MESSAGE | Message structure used to return validation messages in MDG rule-service checks. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP implementation example
Concrete CHECK_ENTITY implementation pattern from the same knowledge document set.
1METHOD if_ex_usmd_rule_service~check_entity.
2 DATA: lo_app_context TYPE REF TO if_usmd_app_context,
3 lt_message TYPE usmd_t_message,
4 ls_message TYPE usmd_s_message,
5 lv_crtype TYPE usmd_crequest_type,
6 lv_crstep TYPE usmd_crequest_appstep,
7 lv_crid TYPE usmd_crequest.
8
9 FIELD-SYMBOLS: <ls_data> TYPE any,
10 <lv_value> TYPE any.
11
12 lo_app_context = cl_usmd_app_context=>get_context( ).
13 CHECK lo_app_context IS BOUND.
14 CHECK io_model->d_usmd_model = 'BP'.
15
16 lo_app_context->get_attributes(
17 IMPORTING
18 ev_crequest_type = lv_crtype
19 ev_crequest_step = lv_crstep
20 ev_crequest_id = lv_crid ).
21
22 CHECK it_data IS NOT INITIAL.
23
24 LOOP AT it_data ASSIGNING <ls_data>.
25 ASSIGN COMPONENT 'SOME_MAND_FIELD' OF STRUCTURE <ls_data> TO <lv_value>.
26 IF <lv_value> IS ASSIGNED AND <lv_value> IS INITIAL.
27 CLEAR ls_message.
28 ls_message-msgid = 'ZMDG_SUPPL'.
29 ls_message-msgno = '001'.
30 ls_message-msgty = 'E'.
31 ls_message-fieldname = 'SOME_MAND_FIELD'.
32 APPEND ls_message TO et_message.
33 ENDIF.
34 ENDLOOP.
35
36 IF et_message IS NOT INITIAL.
37 zcl_mdgbp_bp_validation=>adjust_messages(
38 EXPORTING
39 cr_number = lv_crid
40 CHANGING
41 ct_message = et_message ).
42 ENDIF.
43ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- What is the implementation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_EDITION_FINAL in MDG?
- How do I create and activate a BAdI implementation for
USMD_RULE_SERVICEstarting from SE18? - How should edition-level checks be coded in an MDG rule-service BAdI?
Possible questions
- How do I implement IF_EX_USMD_RULE_SERVICE~CHECK_EDITION_FINAL?
- Which transactions are used to create the
USMD_RULE_SERVICEBAdI implementation? - What should be coded in CHECK_EDITION_FINAL for MDG?
- How do I add validation messages in an MDG BAdI method?
- What is the minimal ABAP template for a
USMD_RULE_SERVICEcheck method?