Issuing a warning message when duplicate materials are entered on a sales order


Although SAP allows a material number to be entered on a sales order more than once, in some cases this is not considered best practice for many businesses. Often, this can cause confusion with the customer and is best corrected by updating the quantity on the existing order line instead of entering duplicate materials on the order.

ABAP Warning Message

Duplicate material numbers on a sales order can easily be solved by the user if a simple warning message is provided which notifies them that the material number is already on the order. The user can then take steps to correct the quantity on the existing order line instead of adding the same material to the order again.

User Exit for Sales Orders

You can issue a warning message to the user by adding some ABAP code to the User Exit called USEREXIT_CHECK_VBAP in the program MV45AFZB. I have given an example below which simply checks to see if the material number already exists on the order but on a different sales order line. It also checks to see if the cumulative order quantity is zero.

*                                                                      *
*       This Userexit can be used to add addtional logic for           *
*       checking the position for completeness and consistency.        *
*                                                                      *
*       US_DIALOG  -  Indicator, that can be used to suppress          *
*                     dialogs in certain routines, e.g. in             *
*                     copy mode.                                       *
*                                                                      *
*       This form is called from form VBAP_PRUEFEN_ENDE.               *
*                                                                      *
FORM userexit_check_vbap USING us_dialog.
* Give the user a warning message if a material number has
* already being entered on the sales order.        
LOOP AT xvbap
   WHERE matnr EQ vbap-matnr
         AND posnr NE vbap-posnr
         AND kwmeng NE 0.
   MESSAGE i001(vl) WITH 'Material is already on the order'.
ENDFORM.                    "userexit_check_vbap


Duplicate materials on a sales order can be easily resolved by simply notifying the user that the material already exists on the sales order. The user can then taken corrective action by updating the quantity on the original material order line.

Leave a Reply

Your email address will not be published. Required fields are marked *