SAP MDG · UTILITIES
How do I read SAP MDG change request validation messages from the application log (BAL)?
Use BAL object `FMDM` and external number `CREQUEST_<CR>` to search the application log for the MDG change request, load the found log headers, and read each message into `USMD_T_MESSAGE` for display in your dashboard or custom UI.
Use BAL object `FMDM` and external number `CREQUEST_<CR>` to search the application log for the MDG change request, load the found log headers, and read each message into `USMD_T_MESSAGE` for display in your dashboard or custom UI.
Use the MDG change request number to build the BAL external number `CREQUEST_<CR>`, search the log object `FMDM`, then load and read all message handles. The reusable pattern below shows how to convert the BAL messages into `USMD_T_MESSAGE` so you can display validation errors in a custom MDG dashboard or UI instead of opening SLG1.
Process flow
- Read the change request context from `USMD120C` or from the caller's `IV_CR`.
- Build the BAL external number as `CREQUEST_<CR>`.
- Create a BAL selection filter with object `FMDM`.
- Call `BAL_DB_SEARCH` to get matching log headers.
- Call `BAL_DB_LOAD` to load the log message handles.
- Loop through the handles and call `BAL_LOG_MSG_READ` for each message.
- Map the BAL fields into `
USMD_S_MESSAGE` and return them in `USMD_T_MESSAGE`.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change request header table used here to confirm the CR exists. |
USMD_S_MESSAGE | Message structure used to hold the converted validation messages. |
USMD_T_MESSAGE | Message table returned by the reader method. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1*&---------------------------------------------------------------------*
2*& 05_Validation_Messages_From_Application_Log
3*&---------------------------------------------------------------------*
4*& Reusable functionality:
5*& Read validation/application-log messages for a CR from BAL.
6*&---------------------------------------------------------------------*
7CLASS zcl_cr_validation_log_reader DEFINITION PUBLIC FINAL CREATE PUBLIC.
8 PUBLIC SECTION.
9 CLASS-METHODS get_validation_error
10 IMPORTING iv_cr TYPE usmd_crequest
11 EXPORTING et_message TYPE usmd_t_message.
12ENDCLASS.
13
14CLASS zcl_cr_validation_log_reader IMPLEMENTATION.
15 METHOD get_validation_error.
16 SELECT SINGLE * INTO @DATA(ls_120c)
17 FROM usmd120c
18 WHERE usmd_crequest = @iv_cr.
19
20 DATA: lt_log_handle TYPE balhdr_t,
21 lt_msg_handle TYPE bal_t_msgh,
22 ls_filter TYPE bal_s_lfil,
23 ls_obj TYPE bal_s_obj,
24 ls_extid TYPE bal_s_extn.
25
26 DATA(lv_ext_id) = |CREQUEST_{ iv_cr }|.
27
28 " Filter by application log object and external id.
29 ls_obj-sign = 'I'.
30 ls_obj-option = 'EQ'.
31 ls_obj-low = 'FMDM'.
32 APPEND ls_obj TO ls_filter-object.
33
34 ls_extid-sign = 'I'.
35 ls_extid-option = 'EQ'.
36 ls_extid-low = lv_ext_id.
37 APPEND ls_extid TO ls_filter-extnumber.
38
39 CALL FUNCTION 'BAL_DB_SEARCH'
40 EXPORTING
41 i_client = sy-mandt
42 i_s_log_filter = ls_filter
43 IMPORTING
44 e_t_log_header = lt_log_handle.
45
46 CHECK lt_log_handle IS NOT INITIAL.
47
48 CALL FUNCTION 'BAL_DB_LOAD'
49 EXPORTING
50 i_t_log_header = lt_log_handle
51 IMPORTING
52 e_t_msg_handle = lt_msg_handle.
53
54 LOOP AT lt_msg_handle INTO DATA(ls_msg_handle).
55 CALL FUNCTION 'BAL_LOG_MSG_READ'
56 EXPORTING i_s_msg_handle = ls_msg_handle
57 IMPORTING e_s_msg = DATA(ls_msg).
58
59 APPEND VALUE usmd_s_message(
60 msgty = ls_msg-msgty
61 msgid = ls_msg-msgid
62 msgno = ls_msg-msgno
63 msgv1 = ls_msg-msgv1
64 msgv2 = ls_msg-msgv2
65 msgv3 = ls_msg-msgv3
66 msgv4 = ls_msg-msgv4 ) TO et_message.
67 ENDLOOP.
68 ENDMETHOD.
69ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I retrieve MDG change request validation errors from BAL?
- What is the ABAP pattern to collect application-log messages for an MDG change request?
- How do I show MDG validation messages in a custom dashboard instead of SLG1?
Possible questions
- How can I retrieve MDG change request validation errors from BAL?
- What is the ABAP pattern to collect application-log messages for an MDG change request?
- How do I show MDG validation messages in a custom dashboard instead of SLG1?
- How do I enhance the messages before displaying them in ALV?
- Which BAL APIs are used to read change request log messages?