Issuing Error Messages in User Exits
Recently we came across the situation which was holding the users to reverse the Goods Issue (through VL09). On execution of VL09 user gets an “Error” message that “Shipment completion button is checked, please un-check it”(custom validation ). When user unchecks the shipment completion button in VT02N and then tries to do the reverse GI through VL09, the following error message was appearing:
Initially we thought there was some problem in SAP standard program but on further investigation we found a SAP note 415716 and according to that:
With the output of messages or user dialogs, you must make sure that this exit can be run both in the dialog and in the background. In particular, during goods issue posting, messages or user dialogs must never be output because this may result in incorrect material documents.
Basically this error was happening due to a check for shipment completion button in user exit, which restrict the user to do the reverse GI if the shipment is completed (VT02N).
This is due to the error message “Please uncheck the shipment completion button”. These error messages just roll-back the update to delivery document (document flow, status…), but it doesn’t roll-back the post of material document. So, reversal document has been created, but delivery document flow is not updated. This is how the problem occurs and delivery becomes inconsistent.
This error message was issued in our own coding in
The message was issued in a wrong way. Please read note 415716. This note explains how to use the user exits in include MV50AFZ1.
As a solution of this problem we found one classical BADI “LE_SHP_DELIVERY_PROC”, it has all the methods which correspond to the user exits in MV50AFZ1. For our purpose we used SAVE_DOCUMENT_PREPARE method. If you issue an error message here in this method it rolls back not only the update to delivery document but also rolls back the posting of material document.
With the output of messages or user dialogs, you must make sure that this exit can be run both in the dialog and in the background. In particular, during goods issue posting, messages or user dialogs must
never be output because this may result in incorrect material documents. Error messages should NOT be issued in this user exit, especially during GI posting / reversing.