2017 Mar 05 1:30 PM
Hello,
I want to add some validation on entries in Service tab in ME51N , and to show error message when the validation fails, and remove that error when it is corrected.
What is the best place to put the validation logic in the BADI function CHECK or PROCESS_ITEM, as I don't want to save until the errors are corrected?
For showing messages I am using mmpur_message ,how can I remove the message when the error is correctdd ?
2017 Mar 06 11:10 AM
Better use PROCESS_ITEM if information is available. to remove your own error messages in the method, use the context. Sample (at start of method implementation)
ls_item = im_item->get_data( ). " get item data
mmpur_context mmcnt_context_badi. " set context to 'BAdI'
if not ls_item-id is initial. " if relevant
mmpur_remove_msg_by_context ls_item-id mmcnt_context_badi. " remove your previous message
endif.
Regards,
Raymond
2017 Mar 06 10:07 AM
2017 Mar 06 10:37 AM
Assign im_item to if_service_mm, then use method get_srv_data of this interface.
" Get item data
im_item->get_data( ).
" assign to a ref to if_services_mm
TRY.
lo_services ?= im_item. " Casting
CATCH cx_sy_move_cast_error.
RETURN.
ENDTRY.
" if ok, get service data
lo_services->get_srv_data(
EXPORTING
im_packno = ls_item-packno
" etc.
2017 Mar 06 11:10 AM
Better use PROCESS_ITEM if information is available. to remove your own error messages in the method, use the context. Sample (at start of method implementation)
ls_item = im_item->get_data( ). " get item data
mmpur_context mmcnt_context_badi. " set context to 'BAdI'
if not ls_item-id is initial. " if relevant
mmpur_remove_msg_by_context ls_item-id mmcnt_context_badi. " remove your previous message
endif.
Regards,
Raymond
2017 Mar 06 11:16 AM
To access service data assign im_item to a ref to if_services_mm and use method get_srv_data.
.