SAP MDG · VALIDATION DERIVATION
How do I implement DERIVE_ENTITY in SAP MDG USMD_RULE_SERVICE?
Implement `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` in BAdI `USMD_RULE_SERVICE` to default empty entity fields by modifying `CT_DATA` in place. Keep derivation deterministic, only fill initial targets, and return informational messages only if needed.
Implement `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` in BAdI `USMD_RULE_SERVICE` to default empty entity fields by modifying `CT_DATA` in place. Keep derivation deterministic, only fill initial targets, and return informational messages only if needed.
From the MDG rule-service template, `DERIVE_ENTITY` is the entity-level defaulting method of `IF_EX_USMD_RULE_SERVICE`. The standard pattern is: register the BAdI implementation in SE19, bind a Z* class to `USMD_RULE_SERVICE`, gate the logic by `ID_ENTITYTYPE`, and update `CT_DATA` rows in place only when the target field is initial. For implementation and testing, the key checks are the BAdI filter, the entity name, and whether the derived field remains user-editable when already filled.
Process flow
- Open SE18 and display BAdI
USMD_RULE_SERVICE. - Confirm interface IF_EX_USMD_RULE_SERVICE and required filter behavior.
- Create the implementation in SE19.
- Assign the implementing Z* class.
- Maintain the data-model filter for the intended MDG model.
- Implement IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY.
- Loop over CT_DATA and derive only when the target is initial.
- Activate class, implementation, and dependent objects in order to test the scenario.
Referenced tables
| Object | Purpose |
|---|---|
usmd_s_message | Message structure used to return informational derivation messages. |
usmd_t_message | Message table type used to append derivation messages to ET_MESSAGE. |
ILLUSTRATIVE ABAP SAMPLE
Generic DERIVE_ENTITY template from the source
This is the source-supported flattened sample pattern for entity-level defaulting in SAP MDG.
1METHOD if_ex_usmd_rule_service~derive_entity.
2 DATA: lv_crequest_id TYPE usmd_crequest,
3 lv_crequest_type TYPE usmd_crequest_type,
4 lt_message TYPE usmd_t_message.
5
6 FIELD-SYMBOLS: <ls_data> TYPE any,
7 <lv_target> TYPE any.
8
9 zcl_mdg_suppl_utility=>get_cr_details(
10 IMPORTING
11 ev_crequest_id = lv_crequest_id
12 ev_crequest_type = lv_crequest_type ).
13
14 CHECK ct_data IS NOT INITIAL.
15
16 LOOP AT ct_data ASSIGNING <ls_data>.
17 ASSIGN COMPONENT 'TARGET_FIELD' OF STRUCTURE <ls_data> TO <lv_target>.
18 IF <lv_target> IS ASSIGNED AND <lv_target> IS INITIAL.
19 <lv_target> = 'DERIVED_VALUE'.
20 ENDIF.
21 ENDLOOP.
22
23 APPEND LINES OF lt_message TO et_message.
24ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I default fields in SAP MDG using
USMD_RULE_SERVICE~DERIVE_ENTITY? - What is the sample ABAP for DERIVE_ENTITY in SAP MDG?
- How do I set up and test a DERIVE_ENTITY BAdI implementation?
Possible questions
- How do I implement a derivation BAdI for empty fields in MDG?
- What is the correct BAdI method for entity-level defaulting in SAP MDG?
- How do I register a
USMD_RULE_SERVICEimplementation in SE18/SE19? - How do I debug a DERIVE_ENTITY method in SAP MDG?
- What is the difference between CHECK_ENTITY and DERIVE_ENTITY?