Skip to Content
1
Jun 12, 2020 at 08:28 PM

BAPI_SALESORDER_CHANGE with buffered order

726 Views Last edit Jun 12, 2020 at 08:29 PM 2 rev

Does this BAPI work with a buffered sales order, that is, one that has just been created with BAPI_SALESORDER_CREATEFROMDAT2, but no COMMIT has been issued?

In my case it simply doesn't find the sales order, as it seems to searchea the database only, not the buffer.

Key requirements in my case are:
1) Item numbers should be auto-generated, like VA01 would do it;
2) Item-specific conditions are to be added.

BAPI_SALESORDER_CREATEFROMDAT2 is calling SD_SALESDOCUMENT_CREATE, which specifies in its documentation that you can't do both:

Use table ORDER_ITEMS_IN to specify item data.
You can carry out the item number assignment manually by filling the appropriate fields, or the system executes it automatically based on the Customizing settings if you leave the corresponding fields initial. If you decide to use mySAP ERP for the item number assignment, no schedule lines or conditions can be specified since there is no recognizable correlation between them and the item.

So I thought about generating the sales document using BAPI_SALESORDER_CREATEFROMDAT2 without any conditions, then using BAPI_SALESORDER_CHANGE to add the conditions. For the sake of keeping everything in one LUW, I would not want to COMMIT in-between.

P.S. There are some alternatives:

1) Item numbering configuration is stored in table TVAK. So I could directly SELECT it.

2) There is another BAPI which returns the numbers for me, without creating the sales order: BAPI_SALESORDER_SIMULATE. So I can copy the numbers from its output. Works fine, but this trick might not work for more changes that are coming. I'd like to be able to create an order in the buffer, change it and only COMMIT at the very end.

Thanks in advance for any suggestion!