INCLUDE mm_messages_mac. "useful macros for message handling
*Get Header details
DATA: lwa_hdr TYPE mepoheader.
* Get Document Type
lwa_hdr = im_header->get_data( ).
IF lwa_hdr-kdatb < sy-datlo.
*STEP 1 --> Invalidate Header object
* invalidate the object
CALL METHOD im_header->invalidate( ).
*Add a custom Error Context ( the number is important to remove messages when required)
mmpur_context 910.
mmpur_message_forced 'E' 'ZXYZ' '007' lv_msgv1 '' '' ''.
ELSE.
*In Case of No error, call the macro to remove message
mmpur_remove_msg_by_context lwa_hdr-id 910.
ENDIF.
DATA: lwa_item TYPE mepoitem
* im_item of PROCESS_ITEM can be used as a referance to get item data
lwa_item = im_item->get_data( ).
IF lwa_item-matnr IS NOT INITIAL.
lv_msgv1 = lwa_item-ebelp.
mmpur_context 921. " New Context 921 to be added
mmpur_business_obj_id lwa_item-id. " To ensure right item gets flagged for error
mmpur_message_forced 'E' 'ZXYZ' '005' lv_msgv1 '' '' ''.
* invalidate the object
CALL METHOD lr_item->invalidate( ). " Invlidate Ite,
ELSE.
mmpur_remove_msg_by_context lwa_item-id 921 . " Needed if Message is to be removed "upon user correction
ENDIF
IF " Custom Validation Failed
lv_msgv1 = lwa_item-ebelp.
mmpur_context 921.
mmpur_business_obj_id lwa_item-id.
mmpur_message_forced 'E' 'ZXYZ' '005' lv_msgv1 '' '' ''.
* invalidate the object
CALL METHOD lr_item->invalidate( ).
ch_failed = abap_true.
ELSE.
mmpur_remove_msg_by_context lwa_item-id 921 .
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |