SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG derivation helper methods for change request context, dynamic field defaulting, message handling, and customizing-based rules?

Use a small reusable helper class for MDG derivation: read the change request context and attributes, assign derived values only when target fields are initial, append messages in bulk, and read rule data from customizing table ZMDG_SUP_CC_DERV.

Use a small reusable helper class for MDG derivation: read the change request context and attributes, assign derived values only when target fields are initial, append messages in bulk, and read rule data from customizing table ZMDG_SUP_CC_DERV.

A clean MDG derivation implementation usually splits into four helper patterns: reading the change request context, reading a single attribute from the CR, assigning a value only if the target field is initial, and reading a rule row from customizing. The sample class below shows these patterns in a reusable utility form and uses existing utility calls for CR context and attribute access.

Process flow

  1. Create or open the derivation helper class.
  2. Implement a method to read CR context via the existing utility call.
  3. Implement a method to read one change-request attribute by field name.
  4. Implement a dynamic assignment method that fills only initial target fields.
  5. Implement a message append helper for bulk message transfer.
  6. Implement a customizing lookup method against ZMDG_SUP_CC_DERV.
  7. Call these helpers from your MDG rule-service derivation logic.
  8. Verify field names, CR step logic, and customizing fallback behavior in debugging.

Referenced tables

ObjectPurpose
ZMDG_SUP_CC_DERVCustomizing table used to derive rules by company code, business partner grouping, and foreign-vendor flag.

ILLUSTRATIVE ABAP SAMPLE

Reusable MDG derivation helper class

Source-supported sample based on the provided utility class pattern. It shows CR context access, single-attribute read, safe dynamic assignment, message append, and customizing-based rule lookup.

1CLASS zcl_usmd_derive_skill_lib DEFINITION 2 PUBLIC 3 FINAL 4 CREATE PUBLIC. 5 6 PUBLIC SECTION. 7 CLASS-METHODS get_cr_context 8 EXPORTING ev_crequest_id TYPE usmd_crequest 9 ev_crequest_type TYPE usmd_crequest_type 10 ev_crequest_step TYPE usmd_crequest_appstep. 11 12 CLASS-METHODS get_single_attr 13 IMPORTING iv_crequest TYPE usmd_crequest 14 iv_field TYPE usmd_fieldname 15 EXPORTING ev_value TYPE string. 16 17 CLASS-METHODS assign_if_initial 18 CHANGING cs_row TYPE any 19 IMPORTING iv_component TYPE fieldname 20 iv_value TYPE any. 21 22 CLASS-METHODS append_messages 23 CHANGING ct_target TYPE usmd_t_message 24 ct_source TYPE usmd_t_message. 25 26 CLASS-METHODS derive_from_customizing 27 IMPORTING iv_bukrs TYPE bukrs 28 iv_bu_group TYPE bu_group 29 iv_foreign_flag TYPE char1 30 EXPORTING es_rule TYPE zmdg_sup_cc_derv. 31 PROTECTED SECTION. 32 PRIVATE SECTION. 33ENDCLASS. 34 35CLASS zcl_usmd_derive_skill_lib IMPLEMENTATION. 36 37 METHOD get_cr_context. 38 zcl_mdg_suppl_utility=>get_cr_details( 39 IMPORTING 40 ev_crequest_id = ev_crequest_id 41 ev_crequest_type = ev_crequest_type 42 ev_crequest_step = ev_crequest_step ). 43 ENDMETHOD. 44 45 METHOD get_single_attr. 46 zcl_mdg_suppl_utility=>get_single_attribute( 47 EXPORTING 48 im_crnumber = iv_crequest 49 im_field = iv_field 50 IMPORTING 51 ex_value = ev_value ). 52 ENDMETHOD. 53 54 METHOD assign_if_initial. 55 FIELD-SYMBOLS <lv_field> TYPE any. 56 ASSIGN COMPONENT iv_component OF STRUCTURE cs_row TO <lv_field>. 57 IF <lv_field> IS ASSIGNED AND <lv_field> IS INITIAL. 58 <lv_field> = iv_value. 59 ENDIF. 60 ENDMETHOD. 61 62 METHOD append_messages. 63 IF ct_source IS NOT INITIAL. 64 APPEND LINES OF ct_source TO ct_target. 65 CLEAR ct_source. 66 ENDIF. 67 ENDMETHOD. 68 69 METHOD derive_from_customizing. 70 SELECT SINGLE * 71 FROM zmdg_sup_cc_derv 72 INTO es_rule 73 WHERE bukrs = iv_bukrs 74 AND ( ktokk = iv_bu_group OR ktokk = '*' OR ktokk = '' ) 75 AND ( foreign_vend = iv_foreign_flag OR foreign_vend = 'A' ) 76 AND disable <> 'X'. 77 ENDMETHOD. 78 79ENDCLASS.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I build reusable utility methods for MDG DERIVE_ENTITY logic?
  • How can I default fields safely in SAP MDG derivation using helper methods?
  • What is the recommended ABAP pattern for MDG derivation utilities?

Possible questions

  • How do I read the MDG change request context in derivation?
  • How do I assign a derived value only when a field is initial?
  • How do I append derivation messages safely in SAP MDG?
  • How do I read customizing for derivation rules?
  • How do I structure a reusable derivation helper class in ABAP?

Keywords

SAP MDGABAPDERIVE_ENTITYUSMD_RULE_SERVICEchange request contextdynamic field assignmentcustomizing-based derivationmessage handlingZCL_USMD_DERIVE_SKILL_LIB