SAP MDG · REPLICATION INBOUND

How do I implement application logging for an SAP MDG mass key mapping report that creates and uploads key mappings for Material, Equipment, or Business Partner?

Use the FORM `process_message` pattern: fill `gt_log`, derive the status icon from message type, append the row to the log table, and call `BAL_LOG_MSG_ADD` with a `bal_s_msg` structure so every mapping validation or save result is written to the application log.

Use the FORM `process_message` pattern: fill `gt_log`, derive the status icon from message type, append the row to the log table, and call `BAL_LOG_MSG_ADD` with a `bal_s_msg` structure so every mapping validation or save result is written to the application log.

Use the `PROCESS_MESSAGE` form as the central logging hook in the MDG mass key mapping report. It copies the row context into `gt_log`, sets a traffic-light status based on the message type, and adds a BAL message with `BAL_LOG_MSG_ADD` so upload and download processing can be reviewed in the application log.

Process flow

  1. Select download or upload mode in the report.
  2. Resolve the source object IDs and system ID in download mode, or provide `p_path` and `p_lines` in upload mode.
  3. Call the MDG input-validation BAdI for object mapping where applicable.
  4. Use `PROCESS_MESSAGE` to write validation, warning, and error details to `gt_log` and BAL.
  5. Call `lr_if_mdg_id_matching_api->get_matching` to detect existing mappings.
  6. Call `lr_if_mdg_id_matching_api->add_matching` and `save` only if validation succeeds.
  7. Review the application log after execution.

Referenced tables

ObjectPurpose
gt_logInternal log output row structure filled by `PROCESS_MESSAGE`.
gt_log_hdCollection of application log handles appended after message creation.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1*----------------------------------------------------------------------* 2***INCLUDE CREATE_KEY_MAPPING_APPL_LOG . 3*----------------------------------------------------------------------* 4*&---------------------------------------------------------------------* 5*& Form PROCESS_MESSAGE 6*&---------------------------------------------------------------------* 7* text 8*----------------------------------------------------------------------* 9* -->P_1 text 10* -->P_STR1 text 11* -->P_STR3 text 12* -->P_STR2 text 13* -->P_STR4 text 14* -->P_STR6 text 15* -->P_STR8 text 16* -->P_0466 text 17* -->P_0467 text 18* -->P_0468 text 19* -->P_SPACE text 20* -->P_SPACE text 21* -->P_SPACE text 22* -->P_SPACE text 23*----------------------------------------------------------------------* 24FORM process_message USING pv_row_index LIKE sy-tabix 25 pv_obj_type_txt TYPE string 26 pv_obj_id_type_txt TYPE string 27 pv_sys_id TYPE string 28 pv_id_value TYPE string 29 pv_ext_sys_id TYPE string 30 pv_ext_id_value TYPE string 31 pv_msgid LIKE gt_log-msgid 32 pv_msgno LIKE gt_log-msgno 33 pv_msgty LIKE gt_log-msgty 34 pv_var1 35 pv_var2 36 pv_var3 37 pv_var4. 38 39 40 DATA: ls_s_msg TYPE bal_s_msg. 41 42 gt_log-row_index = pv_row_index. 43 gt_log-obj_type_txt = pv_obj_type_txt. 44 gt_log-obj_id_type_txt = pv_obj_id_type_txt. 45 gt_log-sys_id = pv_sys_id. 46 gt_log-id_value = pv_id_value. 47 gt_log-ext_sys_id = pv_ext_sys_id. 48 gt_log-ext_id_value = pv_ext_id_value. 49 gt_log-msgid = pv_msgid. 50 gt_log-msgno = pv_msgno. 51 gt_log-msgty = pv_msgty. 52 53 CASE pv_msgty. 54 WHEN 'E' OR 'A'. 55 gt_log-status = '@0A@'. "'ICON_RED_LIGHT'. 56 WHEN 'S' OR 'I'. 57 gt_log-status = '@08@'. "'ICON_GREEN_LIGHT'. 58 WHEN 'W'. 59 gt_log-status = '@09@'. "'ICON_YELLOW_LIGHT'. 60 ENDCASE. 61 62 APPEND gt_log. 63 64 ls_s_msg-msgid = pv_msgid. 65 ls_s_msg-msgno = pv_msgno. 66 ls_s_msg-msgty = pv_msgty. 67 ls_s_msg-msgv1 = pv_var1. 68 ls_s_msg-msgv2 = pv_var2. 69 ls_s_msg-msgv3 = pv_var3. 70 ls_s_msg-msgv4 = pv_var4. 71 72 CALL FUNCTION 'BAL_LOG_MSG_ADD' 73 EXPORTING 74 i_log_handle = gs_log_hd 75 i_s_msg = ls_s_msg 76 EXCEPTIONS 77 OTHERS = 1. 78 79 APPEND gs_log_hd TO gt_log_hd. 80 81 82ENDFORM. " PROCESS_MESSAGE

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

Related questions and keywords

Alternative questions

  • How does the PROCESS_MESSAGE form write MDG key mapping messages to the application log?
  • How can I add BAL logging to an MDG mass key mapping upload report?
  • What is the SAP MDG pattern for logging errors and success messages during key mapping creation?

Possible questions

  • How do I implement application logging for an SAP MDG mass key mapping report?
  • How does the key mapping upload logic validate existing mappings before saving?
  • How can I adapt the MDG mass key mapping report for custom object types?
  • What is the role of BAL_LOG_MSG_ADD in MDG upload processing?
  • How are source and target object IDs compared before saving mappings?

Keywords

SAP MDGABAPmass key mappingapplication logBALBAL_LOG_MSG_ADDprocess_messagekey mapping uploadID matchingMaterialEquipment ResourceBusiness Partner