SAP MDG · REPLICATION INBOUND
How do I generate a mass key-mapping template in SAP MDG for Material, Equipment, or Business Partner using the standard report pattern?
The report generates an Excel-based MDG key-mapping template in download mode by resolving selected object IDs, filling the mapping structure, and inserting the data into an embedded spreadsheet using `sheet->insert_full`. It supports Material, Equipment Resource, and Business Partner, and logs success or errors to the application log.
The report generates an Excel-based MDG key-mapping template in download mode by resolving selected object IDs, filling the mapping structure, and inserting the data into an embedded spreadsheet using `sheet->insert_full`. It supports Material, Equipment Resource, and Business Partner, and logs success or errors to the application log.
The key-mapping generation flow in this report is driven by download mode. It resolves the selected object IDs, fills a template structure with object type, business system, OITC, and ID value, then sends the result to an embedded Excel spreadsheet via `sheet->insert_full`.
The template is built for Material, Equipment Resource, or Business Partner, and the report writes a success or error message to the application log after processing.
Process flow
- Choose download mode in the report.
- Select object type: Material, Equipment Resource, or Business Partner.
- Enter the ID object type code and source system ID.
- Provide one or more object IDs.
- Let the report normalize IDs and select matching objects.
- Call the MDG input field mapping BAdI if implemented.
- Generate the Excel template with `FORM generate_template`.
- Open the embedded spreadsheet created by `sheet->insert_full`.
Referenced tables
| Object | Purpose |
|---|---|
MARA | Material object lookup in download mode. |
EQUI | Equipment Resource lookup in download mode. |
BUT000 | Business Partner lookup in download mode. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1*----------------------------------------------------------------------*
2***INCLUDE CREATE_KEY_MAPPING_GENERATE .
3*----------------------------------------------------------------------*
4*&---------------------------------------------------------------------*
5*& Form GENERATE_TEMPLATE
6*&---------------------------------------------------------------------*
7* text
8*----------------------------------------------------------------------*
9* -->P_LT_OBJECTS text
10* -->P_LV_S_ID text
11* -->P_OBJ_TYPE text
12* -->P_OITC text
13*----------------------------------------------------------------------*
14FORM generate_template TABLES p_lt_objects
15 USING p_lv_s_id
16 p_obj_type
17 p_oitc.
18
19 DATA :ls_otc TYPE mdgi_otc_t_bs,
20 ls_bus_match TYPE lcrs_bsysprod.
21 DATA ls_oitc TYPE mdg_s_ids_code_bs.
22 DATA: ls_fields TYPE dfies,
23 lv_lines TYPE i.
24 DATA: lv_str1 TYPE string,
25 lv_str2 TYPE string,
26 lv_str3 TYPE string.
27 DATA : lt_fields TYPE ddfields.
28
29 DATA: BEGIN OF xmplt_d OCCURS 60, " The structure of the data table
30 object_type_code TYPE mdg_object_type_code_desc_bs,
31 business_system_id TYPE sld_bskey,
32 oitc TYPE mdg_ids_type_code_desc_bs,
33 id_value TYPE mdg_object_id_bs,
34 ex_object_type_code TYPE mdg_object_type_code_desc_bs,
35 ext_business_system_id TYPE sld_bskey,
36 ext_oitc TYPE mdg_ids_type_code_desc_bs,
37 ext_id_value TYPE mdg_object_id_bs,
38 END OF xmplt_d.
39 DATA: lv_h TYPE i,lv_v TYPE i,lv_a TYPE i.
40 DATA ls_object TYPE mdg_object_id_bs.
41 DATA: ls_xmplt_v TYPE gxxlt_v,
42 ls_xmplt_h TYPE gxxlt_h,
43 ls_xmplt_d LIKE xmplt_d,
44 ls_xmplt_s TYPE gxxlt_s,
45 ls_xmplt_o TYPE gxxlt_o,
46 ls_xmplt_p TYPE gxxlt_p.
47
48 DATA: lt_xmplt_v TYPE TABLE OF gxxlt_v,
49 lt_xmplt_h TYPE TABLE OF gxxlt_h,
50 lt_xmplt_d LIKE STANDARD TABLE OF xmplt_d,
51 lt_xmplt_s TYPE TABLE OF gxxlt_s,
52 lt_xmplt_o TYPE TABLE OF gxxlt_o,
53 lt_xmplt_p TYPE TABLE OF gxxlt_p.
54
55 DATA : lv_index TYPE i VALUE '1'.
56
57 DATA container TYPE REF TO cl_gui_custom_container.
58 DATA error TYPE REF TO i_oi_error.
59 DATA control TYPE REF TO i_oi_container_control.
60 DATA document TYPE REF TO i_oi_document_proxy.
61 DATA sheet TYPE REF TO i_oi_spreadsheet.
62
63
64 ls_fields-tabname = TEXT-004.
65 APPEND ls_fields-tabname TO lt_fields.
66
67 ls_fields-tabname = TEXT-005.
68 APPEND ls_fields-tabname TO lt_fields.
69
70 ls_fields-tabname = TEXT-006.
71 APPEND ls_fields-tabname TO lt_fields.
72
73 ls_fields-tabname = TEXT-007.
74 APPEND ls_fields-tabname TO lt_fields.
75
76 ls_fields-tabname = TEXT-009.
77 APPEND ls_fields-tabname TO lt_fields.
78
79 ls_fields-tabname = TEXT-008.
80 APPEND ls_fields-tabname TO lt_fields.
81
82 ls_fields-tabname = TEXT-010.
83 APPEND ls_fields-tabname TO lt_fields.
84
85 ls_fields-tabname = TEXT-011.
86 APPEND ls_fields-tabname TO lt_fields.
87
88
89 LOOP AT lt_fields INTO ls_fields.
90
91 ls_xmplt_v-col_no = lv_index. " The header text for the key
92 ls_xmplt_v-col_name = ls_fields-tabname. " \ columns is defined.
93 APPEND ls_xmplt_v TO lt_xmplt_v.
94
95 ls_xmplt_s-col_no = lv_index. " Semantic Information is provided.
96 ls_xmplt_s-col_typ = 'STR'. " \ This report uses the fields:
97 ls_xmplt_s-col_ops = 'DFT'. " \ - TYPe: Presentation of data as
98 APPEND ls_xmplt_s TO lt_xmplt_s.
99 lv_index = lv_index + 1.
100
101 ENDLOOP.
102
103 IF p_lt_objects[] IS INITIAL.
104 ls_xmplt_d-object_type_code = p_obj_type.
105 ls_xmplt_d-ex_object_type_code = p_obj_type.
106 ls_xmplt_d-business_system_id = p_lv_s_id.
107 ls_xmplt_d-oitc = p_oitc.
108 ls_xmplt_d-ext_oitc = p_oitc.
109 APPEND ls_xmplt_d TO lt_xmplt_d.
110 ELSE.
111
112 LOOP AT p_lt_objects INTO ls_object.
113
114 ls_xmplt_d-object_type_code = p_obj_type.
115 ls_xmplt_d-ex_object_type_code = p_obj_type.
116 ls_xmplt_d-business_system_id = p_lv_s_id.
117 ls_xmplt_d-oitc = p_oitc.
118 ls_xmplt_d-ext_oitc = p_oitc.
119 ls_xmplt_d-id_value = ls_object.
120 APPEND ls_xmplt_d TO lt_xmplt_d.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How does the MDG mass key-mapping download template work?
- How can I create an Excel template for MDG key mapping in bulk?
- What is the ABAP pattern for generating a key-mapping spreadsheet in MDG?
Possible questions
- How do I generate a mass key-mapping template in SAP MDG for Material, Equipment, or Business Partner?
- How does the MDG mass key-mapping download template work?
- How can I create an Excel template for MDG key mapping in bulk?
- What is the ABAP pattern for generating a key-mapping spreadsheet in MDG?
- Which objects and fields are populated in the MDG key-mapping template?