PO Number field (VBAK-BSTNK) in Sales order contains customer’s order reference number. To avoid raising duplicate order for a customer SAP can be configured to check duplicate PO numbers. This blog highlights where in configuration you can activate this duplicate order check and which customer enhancement you can implement to check duplication during inbound IDoc processing.
SPRO configuration
You can configure this setting in same place where you define Sales Order document type. Navigate to path Sales and Distribution-> Sales-> Sales Documents-> Sales Document Header-> Define Sales Document Types in SPRO. As this setting is defined in Sales Document type level you will have to activate this for each sales document type you use. However, do take care not to activate this setting on return orders as return order will have same customer reference as original order.
Specify value A in ‘Check purh.order no’ to activate the check.
After this setting, if sales order is raised for a customer with duplicate PO number then message ‘Purchase order number in document number: & already exists’ (V4 115) will be issued. Type of message i.e. whether it will be warning or error will depend on another setting. To access this navigate to Sales and Distribution-> Sales-> Sales Documents-> Define Variable Messages.
Here you can change kind of message you want to issue. Obviously if it specify E (Error) then user will not be able to create this duplicate order but if you want them to create with caution then putting setting as W (Warning) will be appropriate.
Customer Enhancement
You can use customer enhancement VEDA0001- ‘SD EDI Incoming Orders (Customer Extensions)’ to catch duplicate orders and issue notification emails. Or if you have more complex requirement to identify duplicate order which cannot be fulfilled by standard SAP logic then you can implement this customer enhancement and put you code there.
Standard SAP executes following select statement to check for duplicates. This should give you a good starting point to implement your own custom logic.
SELECT b~vbeln INTO CORRESPONDING FIELDS OF TABLE tvbeln FROM vbak AS b INNER JOIN vbkd AS a ON b~vbeln EQ a~vbeln WHERE a~bstkd_m EQ customer_order_number AND b~vbeln NE new_order_number AND b~kunnr EQ sold_to_party AND b~auart EQ order_type. IF NOT tvbeln IS INITIAL. * Duplicate order ENDIF.
In exit EXIT_SAPLVEDA_011 you can fill error messages in parameter DERRTAB, if you need to stop IDoc from posting.
I would like to avoid a manual delivery being created when a sales order has already been interfaced to another system to create an automatic delivery. Is this done in config or should I use a user_exit .
can you share T-code ?