Table of contents
Scenario
Given some data, Got error message (SAP MDG: Testing -Name 02 Is Mandatory) after clicking on check.
Keeping Mouse on Error Message, it will update the statement into Underline
Now, clicking on the line, the screen will navigate to Name 2 Field
Create The Enhancement Impl. & BADI Impl.
Filter Value
Implementing Class
Code
***********************************************************************
DATA: lr_data TYPE REF TO data.
DATA: lt_messages TYPE usmd_t_message.
DATA: ls_message TYPE usmd_s_message.
DATA: lv_bp_header TYPE bu_businesspartner,
lv_row TYPE mdg_message_row.
FIELD-SYMBOLS: <ls_key> TYPE any.
IF id_entitytype EQ 'BP_CENTRL'.
LOOP AT it_data ASSIGNING FIELD-SYMBOL(<ls_data>).
ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE <ls_data> TO FIELD-SYMBOL(<lv_bp_header>).
IF sy-subrc EQ 0 AND <lv_bp_header> IS ASSIGNED.
lv_bp_header = <lv_bp_header>.
ENDIF.
CALL METHOD io_model->create_data_reference
EXPORTING
i_fieldname = 'BP_CENTRL'
i_struct = if_usmd_model_ext=>gc_struct_key
if_table = abap_false
IMPORTING
er_data = lr_data
et_message = lt_messages.
IF lr_data IS BOUND.
ASSIGN lr_data->* TO <ls_key>.
IF <ls_key> IS ASSIGNED.
ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE <ls_key> TO FIELD-SYMBOL(<lv_key>).
IF Sy-subrc EQ 0 AND <lv_key> IS ASSIGNED.
<lv_key> = lv_bp_header.
CALL METHOD cl_mdg_bs_key_row_map_service=>set_key
EXPORTING
is_key = lr_data " Reference to key
iv_entity = 'BP_CENTRL' " Entity Type
iv_fieldname = 'NAME2' " Source Field
RECEIVING
rv_row = lv_row. " MDG message navigation: row referencing a key
endif.
ENDIF.
ENDIF.
ASSIGN COMPONENT 'NAME_ORG2' OF STRUCTURE <ls_data> TO FIELD-SYMBOL(<lv_name_org2>).
IF sy-subrc EQ 0 AND <lv_bp_header> IS ASSIGNED AND <lv_name_org2> IS INITIAL.
ls_message-msgid = 'ZMDG_MESSAGE_CLASS'.
ls_message-msgty = 'E'.
ls_message-msgno = '000'.
ls_message-row = lv_row.
APPEND ls_message TO et_message.
CLEAR ls_message.
ENDIF.
ENDLOOP.
ENDIF.
Thanks & Regards,