SAP MDG · VALIDATION DERIVATION
How do I derive vendor organization data in SAP MDG for Business Partner supplier records?
Use a derivation method that reads the MDG change request context, extracts BP header data from BP_HEADER, and writes organization defaults to the custom entity ZBP_BUDET. In the provided pattern, the method derives ZZOBU_UNT = 'GPUR' for selected account groups and then marks the organization derivation as completed with a singleton flag.
Use a derivation method that reads the MDG change request context, extracts BP header data from BP_HEADER, and writes organization defaults to the custom entity ZBP_BUDET. In the provided pattern, the method derives ZZOBU_UNT = 'GPUR' for selected account groups and then marks the organization derivation as completed with a singleton flag.
Use the MDG change request context to read BP_HEADER, extract the business partner header data, and write organization defaults to the custom entity ZBP_BUDET. The documented pattern sets ZZOBU_UNT to 'GPUR' for selected account groups such as Z005 and Z007, then persists the derived data through I_IO_WRITE_DATA and sets an org-derivation flag to prevent повторное processing.
Process flow
- Get the active MDG application context with CL_USMD_APP_CONTEXT=>GET_CONTEXT( ).
- Read BP_HEADER entity data for the current change request using I_IO_MODEL->READ_ENTITY_DATA_ALL.
- Extract the BP header record from the returned generic entity data.
- Populate the target custom structure for ZBP_BUDET.
- Set ZZOBU_UNT to GPUR for the documented account groups.
- Write the result through I_IO_WRITE_DATA->WRITE_DATA.
- Set the singleton org flag to prevent duplicate derivation.
Referenced tables
| Object | Purpose |
|---|---|
BP_HEADER | Source entity holding business partner header data for the derivation. |
BP_CENTRL | Related BP central data entity referenced in the derivation context. |
BP_COMPNY | Related BP company data entity referenced in the derivation context. |
BP_PORG | Related BP purchasing organization entity referenced in the derivation context. |
ZBP_BUDET | Custom target entity written by the derivation method for vendor organization defaults. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1* Purpose: Derive vendor organization data from BP/MDG context.
2
3 METHOD derive_vendor_org_data.
4 CONSTANTS:
5 lc_headr TYPE usmd_entity VALUE 'BP_HEADER',
6 lc_centrl TYPE usmd_entity VALUE 'BP_CENTRL',
7 lc_compny TYPE usmd_entity VALUE 'BP_COMPNY',
8 lc_bpporg TYPE usmd_entity VALUE 'BP_PORG',
9 lc_postal TYPE usmd_entity VALUE 'AD_POSTAL',
10 lc_vengen TYPE usmd_entity VALUE 'BP_VENGEN',
11 lc_identity TYPE usmd_entity VALUE 'BP_IDNUM',
12 lc_ztecus TYPE usmd_entity VALUE 'ZBP_BUDET',
13 lc_venval TYPE usmd_entity VALUE 'BP_VENVAL',
14 lc_vencla TYPE usmd_entity VALUE 'BP_VENCLA',
15 lc_address TYPE usmd_entity VALUE 'ADDRESS',
16 lc_togru TYPE char40 VALUE 'TOGRU'.
17
18 DATA:
19 lo_app_context TYPE REF TO if_usmd_app_context,
20 lo_data_r TYPE REF TO data,
21 lv_crequest TYPE usmd_crequest,
22 lt_data_entity TYPE usmd_ts_data_entity,
23 ls_data_entity TYPE usmd_sx_data_entity,
24 ls_bpheader TYPE /mdgbp/_s_bp_es_bp_header,
25 lt_bpcompny TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_compny,
26 ls_bpcompny TYPE /mdgbpx/_s_bp_es_bp_compny,
27 lt_bpporg TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg,
28 lt_bpporg1 TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg,
29 lt_centrl TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_centrl,
30 ls_centrl TYPE /mdgbpx/_s_bp_es_bp_centrl,
31 ls_bpporg TYPE /mdgbpx/_s_bp_es_bp_porg,
32 ls_bpporg1 TYPE /mdgbpx/_s_bp_es_bp_porg,
33 ls_bpporg2 TYPE /mdgbpx/_s_bp_es_bp_porg,
34 lt_adpostal TYPE STANDARD TABLE OF /mdgbp/_s_bp_pp_ad_postal,
35 ls_adpostal TYPE /mdgbp/_s_bp_pp_ad_postal,
36 lt_identity TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_bp_idnum,
37 ls_identity TYPE /mdgbp/_s_bp_es_bp_idnum,
38 ls_bp_centrl TYPE /mdgbp/_s_bp_pp_bp_centrl,
39 lt_bp_centrl LIKE TABLE OF ls_bp_centrl,
40 ls_bp_vengen TYPE /mdgbpx/_s_bp_pp_bp_vengen,
41 lt_bp_vengen LIKE TABLE OF ls_bp_vengen,
42 ls_bp_porg TYPE /mdgbpx/_s_bp_pp_bp_porg,
43 lt_bp_porg LIKE TABLE OF ls_bp_porg,
44 lt_ztecustom TYPE STANDARD TABLE OF zmdgbp_s_bp_pp_zbp_budet,
45 ls_ztecustom TYPE zmdgbp_s_bp_pp_zbp_budet,
46 lt_bpvenval TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_venval,
47 ls_bpvenval TYPE /mdgbpx/_s_bp_es_bp_venval,
48 lt_bpvencla TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_vencla,
49 ls_bpvencla TYPE /mdgbpx/_s_bp_es_bp_vencla,
50 lt_address TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_address,
51 ls_address TYPE /mdgbp/_s_bp_es_address,
52 lo_att_data TYPE REF TO data,
53 lo_att TYPE REF TO cl_abap_structdescr,
54 lo_singleton TYPE REF TO zcl_mdg_singleton,
55* lo_data_ca_map TYPE REF TO zcl_fi_global_utility,
56 ls_ca_map TYPE zca_map,
57 lt_ca_map TYPE zca_map_tt,
58 lr_write_error TYPE REF TO cx_usmd_write_error,
59 lt_attribute TYPE usmd_ts_fieldname,
60 lv_ekorg TYPE ekorg,
61 lv_atinn_char TYPE string,
62 lv_number TYPE ad_addrnum,
63 lv_togru TYPE togru.
64
65 FIELD-SYMBOLS: <fs_lt_data> TYPE SORTED TABLE,
66 <fs_ls_data> TYPE any,
67 <fs_component> TYPE abap_compdescr.
68*================================================*
69 RETURN. "##STMNT_EXIT "Added by Samar to avoid this code
70 lo_app_context = cl_usmd_app_context=>get_context( ).
71 CHECK lo_app_context IS BOUND.
72lv_crequest = lo_app_context->mv_crequest_id.
73 DATA(lv_crtype) = lo_app_context->mv_crequest_type.
74 DATA(lv_step) = lo_app_context->mv_crequest_step.
75
76 i_io_model->read_entity_data_all( EXPORTING i_fieldname = 'BP_HEADER'
77 if_active = abap_false
78 i_crequest = lv_crequest
79 IMPORTING et_data_entity = lt_data_entity ).
80 CHECK lt_data_entity IS NOT INITIAL.
81 READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr
82 usmd_entity_cont = space
83 struct = 'KATTR'.
84 IF sy-subrc = 0.
85 CLEAR lo_data_r.
86 lo_data_r = ls_data_entity-r_t_data.
87 ASSIGN lo_data_r->* TO <fs_lt_data>.
88 LOOP AT <fs_lt_data> ASSIGNING <fs_ls_data>.
89 ASSIGN COMPONENT 'BU_TYPE' OF STRUCTURE <fs_ls_data> TO FIELD-SYMBOL(<fs_bu_type>).
90 IF <fs_bu_type> IS ASSIGNED.
91 MOVE-CORRESPONDING <fs_ls_data> TO ls_bpheader.
92 ENDIF.
93 ENDLOOP.
94 ENDIF.
95 IF ls_bpheader IS NOT INITIAL.
96
97*Popualte Org. structure
98 "BP Header
99 ls_ztecustom-bp_header = ls_bpheader-bp_header.
100 "Commodity Code
101* ls_ztecustom-zzocomcod = 'ZZ070000'.
102 "Populate the Business unit as GPUR when the account group is Z007, Z005. For All CR types
103 IF iv_bu_group = zif_bp_constants=>ktokk-z005 OR iv_bu_group = zif_bp_constants=>ktokk-z007 OR
104 iv_bu_group = zif_bp_constants=>ktokk-v005 OR iv_bu_group = zif_bp_constants=>ktokk-v007 OR
105 iv_bu_group = zif_bp_constants=>ktokk-vd05 OR iv_bu_group = zif_bp_constants=>ktokk-vd07.
106 ls_ztecustom-zzobu_unt = 'GPUR'.
107 ENDIF.
108 APPEND ls_ztecustom TO lt_ztecustom.
109 CLEAR: ls_ztecustom.
110
111
112 IF lt_ztecustom[] IS NOT INITIAL.
113 CREATE DATA lo_att_data LIKE LINE OF lt_ztecustom.
114 lo_att ?= cl_abap_structdescr=>describe_by_data_ref( p_data_ref = lo_att_data ).
115 LOOP AT lo_att->components ASSIGNING <fs_component>.
116 INSERT <fs_component>-name INTO TABLE lt_attribute.
117 ENDLOOP.
118
119 TRY.
120 CALL METHOD i_io_write_data->write_dataThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I populate BP supplier organization data automatically in MDG?
- What is the derivation logic for vendor organization data in MDG Business Partner?
- How do I default the MDG supplier purchasing organization and vendor organization fields?
Possible questions
- Which entity types are used for vendor organization derivation in MDG BP?
- Which fields can be defaulted from BP_HEADER and account group in vendor org derivation?
- How do I write derived vendor org data back to a custom MDG entity?
- How do I control vendor org derivation by account group in MDG?
- What is the ABAP pattern for writing MDG derivation data with IF_USMD_WRITE_DATA?