Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating a sales order with reference/BAPI_SALESDOCUMENT_COPY

kai_stuke
Discoverer
0 Likes
3,224

Hi,

I have to create a sales order with a reference to another order and have to change some fields in the new document.

According to SAP note 370988 the function BAPI_SALESDOCUMENT_COPY should allow to create a sales order with reference to another order.

Unfortunately it doesn't work for me.

The BAPI doesn't return an error and creates a new order but that one is incomplete.

The reason seems to be that VKORG, VTWEG and SPART aren't provided and because of that the new order can't be created completely.

I can find no way to provide these fields to the BAPI.

Has anyone used the BAPI successfully or has found another way to achieve the desired result?

I already checked

  • batch input: problematic because I have to change partners which are displayed in an table control which can't be controlled reliably from batch input

  • the second way described in the SAP note: high effort and high risk, as each data field has to be copied explicitly from one represantation to another.

Any help is appreciated.

Kai

Hi,

I have to create a sales order with a reference to another order and have to change some fields in the new document.

According to SAP note 370988 the function BAPI_SALESDOCUMENT_COPY should allow to create a sales order with reference to another order.

Unfortunately it doesn't work for me.

The BAPI doesn't return an error and creates a new order but that one is incomplete.

The reason seems to be that VKORG, VTWEG and SPART aren't provided and because of that the new order can't be created completely.

I can find no way to provide these fields to the BAPI.

Has anyone used the BAPI successfully or has found another way to achieve the desired result?

I already checked

  • batch input: problematic because I have to change partners which are displayed in an table control which can't be controlled reliably from batch input

  • the second way described in the SAP note: high effort and high risk, as each data field has to be copied explicitly from one represantation to another.

Any help is appreciated.

Kai

4 REPLIES 4
Read only

Former Member
0 Likes
2,101

Why don't you just read the data from VBAK and VBAP and use for example

BAPI_SALESORDER_CREATEFROMDAT1 to create new one ?

Read only

0 Likes
2,101

That approach would effectively duplicate the implementation of BAPI_SALESDOCUMENT_COPY, wouldn't it?

As there is a lot more data involved than just VBAK/VBAP (e.g texts, partners, conditions, schedules) this is not only a lot more effort it's also harder to get it right, especially since there might also be copy control customization which has to be take into account.

Nevertheless I tried it and it isn't working in my case.

I' have to create a debit memo request (BUS2096) out of a sales order (BUS2032), and BAPIs SALES_ORDER_CREATE* only handle BUS2032.

Read only

0 Likes
2,101

I don't think it is the right way to use BAPI_SALESDOCUMENT_COPY to create a debit memo with reference to the order. You can create BUS2096 object with RFC "SD_SALESDOCUMENT_CREATE". For extracting the details of sales order, function module [SHP_GET_SD_DATA |http://wiki.sdn.sap.com/wiki/display/ABAP/SHP_GET_SD_DATA-FunctionmoduleforExtractingSalesorderDetails] will be helpful.

Read only

0 Likes
2,101

Why specifically do you think that BAPI_SALESDOCUMENT_COPY shouldn't be used?

I meanwhile solved the problem by enhancing the copy control routine to also copy VKORG/VTWEG/SPART.

That way the debit memo is created as expected with BAPI_SALESDOCUMENT_COPY.