SAP MDG · REPLICATION INBOUND
How do I implement mass key mapping creation in SAP MDG using the ZCREATE_MASS_KEY_MAPPNG report pattern?
The report pattern supports two modes: download to resolve selected MDG object IDs and generate mapping output, or upload to read a file and process mappings in bulk. It dynamically switches selection-screen fields, resolves object types and ID object type codes, calls the MDG ID matching API/BAdI, and writes application log entries.
The report pattern supports two modes: download to resolve selected MDG object IDs and generate mapping output, or upload to read a file and process mappings in bulk. It dynamically switches selection-screen fields, resolves object types and ID object type codes, calls the MDG ID matching API/BAdI, and writes application log entries.
The example report `ZCREATE_MASS_KEY_MAPPING_FLAT_EXAMPLE` shows the same overall flow as `ZCREATE_MASS_KEY_MAPPNG`: choose Download or Upload, resolve the object type and ID object type code, normalize the selected IDs, call the MDG ID-matching logic, and then generate output or process an upload file. The selection screen switches dynamically, and the run is logged with BAL.
Process flow
- Create a selection screen with Download and Upload radio buttons.
- Load lookup values from `MDGI_IDSTC_T_BS` and `MDGI_OTC_T_BS` during initialization.
- Create the application log with `BAL_LOG_CREATE`.
- Resolve the local business system with `cl_mdg_id_matching_api_bs=>get_instance`.
- Dynamically enable or disable selection-screen fields based on the chosen mode.
- In Download mode, resolve the object type and ID object type code.
- Normalize IDs and fetch objects from `MARA`, `EQUI`, or `BUT000` depending on object type.
- Call the MDG ID matching BAdI/API using `GET BADI` and `CALL BADI` or the matching API methods from the mass upload flow.`,
Referenced tables
| Object | Purpose |
|---|---|
MDGI_IDSTC_T_BS | Lookup table for ID object type descriptions and codes used on the selection screen. |
MDGI_OTC_T_BS | Lookup table for object type descriptions and codes used on the selection screen. |
MDGI_IDSTC_BS | Source table used to derive the ID object type code from the object type code. |
MARA | Material master table read in download mode for Material objects. |
EQUI | Equipment table read in download mode for Equipment Resource objects. |
BUT000 | Business Partner master table read in download mode for Business Partner objects. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1*&---------------------------------------------------------------------*
2*& Report ZCREATE_MASS_KEY_MAPPING_FLAT_EXAMPLE
3*&---------------------------------------------------------------------*
4*& Purpose:
5*& Flat, non-modular example of how the mass key-mapping creation flow
6*& works in ZCREATE_MASS_KEY_MAPPNG.
7*&
8*& This is a descriptive example only. It focuses on the main idea:
9*& - choose the mapping mode
10*& - resolve the input object IDs
11*& - call the MDG ID-matching logic
12*& - generate the mapping output or process an upload file
13*&
14*& The real program uses multiple includes. This file shows the same
15*& process in one place for easier understanding.
16*&---------------------------------------------------------------------*
17
18REPORT zcreate_mass_key_mapping_flat_example.
19
20TYPES: BEGIN OF ty_message,
21 msgty TYPE symsgty,
22 msgid TYPE symsgid,
23 msgno TYPE symsgno,
24 msgv1 TYPE symsgv,
25 msgv2 TYPE symsgv,
26 msgv3 TYPE symsgv,
27 msgv4 TYPE symsgv,
28 msg_index TYPE int4,
29 fieldname TYPE fieldname,
30 END OF ty_message.
31
32TYPES ty_message_tab TYPE STANDARD TABLE OF ty_message WITH EMPTY KEY.
33
34TYPES: BEGIN OF ty_mapped_id_obj,
35 oitc TYPE mdg_ids_type_code_bs,
36 bs_key_name TYPE sld_bskey,
37 id_value TYPE mdg_object_id_bs,
38 object_type_code TYPE mdg_object_type_code_bs,
39 END OF ty_mapped_id_obj.
40
41DATA: lt_ids_codes TYPE STANDARD TABLE OF mdgi_idstc_t_bs,
42 lt_obj_types TYPE STANDARD TABLE OF mdgi_otc_t_bs,
43 lt_object_id TYPE RANGE OF mdg_object_id_bs,
44 lt_objects TYPE STANDARD TABLE OF mdg_object_id_bs,
45 lt_messages TYPE ty_message_tab,
46 lt_range TYPE RANGE OF char255,
47 lv_mode TYPE char10,
48 lv_s_id TYPE sld_bskey,
49 lv_tab TYPE char20,
50 lv_field TYPE char20,
51 lv_where TYPE string,
52 lv_id_type TYPE mdg_ids_type_code_bs,
53 lv_dummy_num TYPE bu_partner,
54 lv_matnr TYPE matnr,
55 lv_equnr TYPE char18,
56 lv_found TYPE boole_d,
57 lv_maching_api TYPE REF TO cl_mdg_id_matching_api_bs,
58 lr_input_val TYPE REF TO bs_gis_key_mapping,
59 lr_if_matching TYPE REF TO if_mdg_id_matching_api_bs,
60 lv_lcl_system TYPE sld_bskey.
61
62DATA: ls_obj_id TYPE mdgi_otc_t_bs,
63 ls_id_code TYPE mdgi_idstc_t_bs,
64 ls_message TYPE ty_message,
65 ls_mapped_obj TYPE ty_mapped_id_obj.
66
67DATA: gs_s_log TYPE bal_s_log,
68 gs_log_hd TYPE balloghndl,
69 gt_log_hd TYPE STANDARD TABLE OF balloghndl,
70 gt_log TYPE STANDARD TABLE OF bal_s_msg.
71
72CONSTANTS: gc_downld TYPE char10 VALUE 'DOWNLOAD',
73 gc_upld TYPE char10 VALUE 'UPLOAD',
74 gc_true TYPE abap_bool VALUE abap_true.
75
76SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
77PARAMETERS: p_downld RADIOBUTTON GROUP mode DEFAULT 'X' USER-COMMAND mode,
78 p_upld RADIOBUTTON GROUP mode.
79SELECTION-SCREEN END OF BLOCK b1.
80
81SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
82PARAMETERS: obj_type TYPE mdg_object_type_code_desc_bs AS LISTBOX VISIBLE LENGTH 50 USER-COMMAND fcode,
83 oitc TYPE mdg_ids_type_code_desc_bs AS LISTBOX VISIBLE LENGTH 50 USER-COMMAND fcode,
84 lv_s_id TYPE sld_bskey.
85SELECT-OPTIONS lt_id FOR ls_mapped_obj-id_value.
86PARAMETERS: p_path TYPE rlgrap-filename,
87 p_lines TYPE i DEFAULT 1000.
88SELECTION-SCREEN END OF BLOCK b2.
89
90INITIALIZATION.
91 " Load lookup values used by the selection screen.
92 SELECT * FROM mdgi_idstc_t_bs INTO TABLE @lt_ids_codes WHERE langu = @sy-langu.
93 SELECT * FROM mdgi_otc_t_bs INTO TABLE @lt_obj_types WHERE langu = @sy-langu.
94
95 " Create application log handle for the run.
96 gs_s_log-extnumber = 'MASS_KEY_MAPPING'.
97 gs_s_log-object = 'GIS_LOG'.
98 gs_s_log-subobject = ''.
99 gs_s_log-aldate_del = sy-datum + 200.
100 gs_s_log-del_before = gc_true.
101 CALL FUNCTION 'BAL_LOG_CREATE'
102 EXPORTING
103 i_s_log = gs_s_log
104 IMPORTING
105 e_log_handle = gs_log_hd.
106
107 " Determine the local business system used by the mapping API.
108 CALL METHOD cl_mdg_id_matching_api_bs=>get_instance
109 IMPORTING
110 er_if_mdg_id_matching_api = lr_if_matching
111 ev_lcl_business_system = lv_lcl_system.
112
113 IF lv_s_id IS INITIAL.
114 lv_s_id = lv_lcl_system.
115 ENDIF.
116
117AT SELECTION-SCREEN OUTPUT.
118 IF p_downld = abap_true.
119 lv_mode = gc_downld.
120 ELSE.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How does the mass key-mapping creation flow work for download and upload modes?
- How do I resolve object IDs and call MDG ID matching for mass key mapping?
- How do I build a report that generates and uploads MDG key mappings?
Possible questions
- How do I generate a key-mapping template for Material IDs?
- How do I enable upload mode with file path and row limit?
- Which MDG ID matching API is used in the example?
- How are Material, Equipment Resource, and Business Partner handled in download mode?
- How is application logging handled in the report?