Hi Expert,
I am doing the validation for material in 'USMD_RULE_SERVICE~CHECK_ENTITY' BADI. Here I am trying to create the custom message as link to point the fields on the screen. but somehow I am not able to achieve the goal.
Below is the code I have implemented in the BADI.
*Start of code
when 'MARCPURCH'.
call method io_model->create_data_reference " key value lr_key is passed in Zerror_msg for link addition in msg
exporting
i_fieldname = 'MARCPURCH'
i_struct = if_usmd_model_ext=>gc_struct_key
if_table = abap_false
importing
er_data = lr_key.
if lr_key is bound.
assign lr_key->* to <ls_key>.
assign component 'MATERIAL' of structure <ls_key> to <lv_key1>.
assign component 'WERKS' of structure <ls_key> to <lv_key2>.
<lv_key1> = <lv_matnr>. "Material number created on run time
<lv_key2> = <lv_werks>. "Plant added
endif.
loop at it_data[] assigning <wa_data> .
assign component 'EKGRP' of structure <wa_data> to <lv_data>.
if <lv_data> <> 'M2'. " or <lv_data> <> 'AQ' or <lv_data> <> 'PQ'. "Title check for company
ls_message-fieldname = 'MARCPURCH-EKGRP'.
ls_message-msgid = 'ZMDGMM'.
ls_message-msgno = '004'.
ls_message-msgty = 'E'.
ls_message-msgv1 = lv_material.
ls_message-row = cl_mdg_bs_key_row_map_service=>set_key(
is_key = lr_key
iv_entity = 'MARCPURCH'
iv_fieldname = 'EKGRP' ).
append ls_message to et_message.
if et_message is not initial.
lo_msg_nav = cl_mdg_bs_mat_msg_nav=>get_instance( ).
lo_msg_nav->save_navigation_data(
exporting it_message = et_message ).
endif.
endif.
endloop.
endcase.
Any help will be highly appreciated.
Thanks
Chandan