Skip to Content

Highlight the field with custom validation message as link in MDG-M 9.0

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

Add comment
10|10000 characters needed characters exceeded

  • Hi Rohit,

    Working on MDG 9.0. MDG-S.If you have any solution please let me know. :)

    Regards,

    Riyaj

  • Hi Mohd.

    Code has to be written in the USMD_RULE_SERVICE Badi. Method CHECK_ENTITY.

    Your are suppose to fill ET_MESSAGE with you error message with ROW & FIELDNAME attributes also (which will provide message hyperlinking ).

    Taking an example of raising Error message of BP_VENGEN-KONZS.

    ---------------------------------------------------------------------------------------------------------------------

    FIELDNAME here is 'KONZS'.

    To get the ROW value, use the method

    lv_row = cl_mdg_bs_key_row_map_service=>set_key( is_key = lo_data
    iv_entity = if_mdg_bs_ecc_bp_constants=>gc_sp_model_entity-general_data iv_fieldname = 'KONZS' ).

    Keep in mind that lo_data forms key for BP_VENGEN entity.So Key should be value of 'BP_HEADER' and value of 'ASSGNM_ID' combined to for lo_data ( of type TYPE REF TO DATA).

    append you message to ET_MESSAGE and it will show the custom message as Hyperlink to the field.

    Cheers,
    Rohit

  • Hi Rohit,

    Your logic worked. Thanks a lot.

    Regards,

    Riyaj.

  • Get RSS Feed

2 Answers

  • Sep 22, 2017 at 08:54 AM

    Thank you guys ..

    I got the solution to make the custom error message as hyperlink to corresponding fields. But this works only for sequential UI not the Tabbed UI. Please let me know if any one faced the same issue.

    Thanks

    Chandan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 01, 2017 at 10:35 AM

    Hi,

    It does work for the tabbed UI. You need to create data reference for the entity and need to fill the values for key fields in the entity and then pass the reference to the class CL_MDG_BS_KEY_ROW_MAP_SERVICE=>SET_KEY, to set the row value.

    Assume lr_key has the data reference of BP_IDNUM entity,

    Fill the key values BP_HEADER,BP ID Type, BP ID number, like below.

    ASSIGN lr_key->* TO <ls_idnum_key>.

    ASSIGN ('<ls_idnum_key>-BP_HEADER') TO <ls_id_data>.

    Fill the other key values in the similar way and call the below class,

    ls_message-row =

    cl_mdg_bs_key_row_map_service=>set_key( is_key = lr_key

    iv_entity = ‘BP_IDNUM’

    iv_fieldname = <filedname>).

    Then, append the message details with row value to the ET_MESSAGE table. It highlights the error field.

    Thanks,

    Shruthi R

    Add comment
    10|10000 characters needed characters exceeded