Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Add validation for service tab in ME51N

Former Member
0 Kudos

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 ?

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

The issue how to read service data ?

raymond_giuseppi
Active Contributor
0 Kudos

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.

raymond_giuseppi
Active Contributor
0 Kudos

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

raymond_giuseppi
Active Contributor

To access service data assign im_item to a ref to if_services_mm and use method get_srv_data.

.