on 2025 Oct 08 11:00 PM
Hello everyone,
I have some code in the user exit SAVE_DOCUMENT_PREPARE which is trigerred during sales order creation. In that code, i need to access all the schedule lines for an item so I am using the table XVBEP[] for that. For creating sales order i am using a material for which the confirmed stock is of a future date which means if i create a sales order today with that material, the i have two schedule line that item. the first one being of today's delivery date with 0 confirmed quantity and the other one with future delivery date with the required confirmed quantity.
when i put a break-point in my code piece in the user exit and create a sales order using Tcode va01, then when the break point hits in the debugger, i have two records in the XVBEP[] table. But when I create a sales order from an external system which calls the BAPI BAPI_SALESORDER_CREATEFROMDAT2 and put a break-point at the same spot, then I only got 1 record in the XVBRP[] table in debugger. I don't get the second schedule line with the confirmed quantity. But this sales order is saved by the external system using the BAPI, then it shows two schedule lines in va03. Also, there are no custom enhancements that deleted schedules lines.
Can anyone please help what could be the issue behind getting only one schedule line when sales order is created via external system using bapi?
@Chris1973 @Chuma @junwu @Sandra_Rossi @DonWilliams @Lakshmipathi
Request clarification before answering.
The difference between VA01 & BAPI is
In VA01, the ATP check and schedule line determination are fully executed before SAVE_DOCUMENT_PREPARE is triggered. So by the time your user exit runs, XVBEP[] is fully populated.
In BAPI_SALESORDER_CREATEFROMDAT2, the ATP check and schedule line determination may not be completed yet when SAVE_DOCUMENT_PREPARE is triggered. This means XVBEP[] might only contain the initial schedule line (e.g., with 0 confirmed quantity), and the second line is added later in the process. The BAPI doesn’t commit changes automatically. If the external system calls BAPI_TRANSACTION_COMMIT after the BAPI, the second schedule line might be added after your user exit has already run.
You mentioned XVBEP[] in one place and XVBRP[] in another. Just to clarify:
Make sure you're consistently checking XVBEP[] in all the cases.
I would recommend to follow the below steps
Use VBEP Instead of XVBEP in BAPI Context. If XVBEP[] is not fully populated, consider reading directly from VBEP using the item number (VBAP-POSNR) and sales document number (VBAK-VBELN) — but only if the document has already been created.
If your logic depends on finalized schedule lines, consider moving it to a later user exit like SAVE_DOCUMENT (after the document is saved) or USEREXIT_SAVE_DOCUMENT in MV45AFZZ
Force ATP check in BAPI input and that the schedule lines are passed correctly to trigger ATP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 7 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.