cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: How to copy multiple sales order items into a return sales order?

Former Member
0 Kudos

Dear developers,

I have a requirement to copy multiple sales order items into a single return sales order. For example, generated return sales order have 2 items, item 10 is created with reference to sales item 2610/10 and item 20 is created with reference to sales item 2611/20. What's more, when it happens, copy control should be taken care of. I know it is possible to create this kind of order by transaction. But how to do it in coding?

In current SAP release, there is only BAPI for creating with reference on 1:1 relationship which means copy one document to another but what I need is N:1 copy.

Any suggestion is high appreciated!!

BR,

Tony.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Tony,

if you use the following menu path your copy control will be invoked :

VA01 for your return order, do not click on create with rerference on the initial screen of VA01, when you are on overview screen select "Sales document -> create with reference -> sales document", do it for each new item, so each new item may have reference to different orders.

You can write your program to call VA01 using BDC.

Former Member
0 Kudos

Siarhei,

Thanks for your help, but before I create this return, i need to update several sales orders, and these sales orders and return order should be in the same transaction. That is, if I fail in updating the sales order, the return order should not be created, vice versa. So by using BAPI I can control this by "BAPI_COMMIT" or "BAPI_ROLLBACK" in the end. Is it possible to do this using BDC?

Thanks

Former Member
0 Kudos

What are you trying to update in sales orders? Are you creating return orders via a custom program? What materials are they (serialized or batch managed or neither)? You need to push the successfully updated Sales orders corresponding return item in return orders and leave the unsuccessful item on the screen, a return order is created for successful items and leaves the rest for which a return order can be created after fixing.

You need provide little more design details in order for us to come up with quick ideas.

Former Member
0 Kudos

Hi ,

If you are creating sales order by using bapi then after calling bapi you can check import parameter <i><b>SALESDOCUMENT</b></i> in the bapi function module .If this parameter is not initial then sales order is created in this case you can create return order. If this import parameter is initial then sales order is not created and you cannot use return bapi function module.

Bapi is simple method than BDC.

In above case it is required to call BAPI_TRANSACTION_COMMIT after every successful sales order creation.

One more important point is you have to clear import parameter <i><b>SALESDOCUMENT</b></i> before calling sales order creation function module.

Thanks,

shyla

Former Member
0 Kudos

Hi shyla,

Thanks for your reply. In the current design, we use BAPI for changing sales documents and creating the return document. That's perfect fine for commit or rollback concerns. But what we are facing now is how to make use of copy control in return document creation using BAPI. As I said previously, the data for return items generation is from sales item to which this return item refer. And customer wants copy control in standard SAP should control which data from sales item should be copied into the return item. Could you help me with this?

Thanks,

Tony

Former Member
0 Kudos

Tony,

I think you can try to use either FMs like SD_SALES_DOCUMENT_READ & SD_SALES_DOCUMENT_MAITAIN, or CALL DIALOG SD_SALES_DOCUMENT_MAITAIN using bdcdata.

Updates are not made to DB unless you issue commit work.

Not sure if that works, but you can try to use FMs or call dialog for all your orders, then

set update task local & call transaciton VA01 using bdcdata for your return.

Former Member
0 Kudos

Siarhei,

Thinks for your suggestion.

I'm going to try BDC to create with reference to mutiple sales order items, it will be complicated.. god bless me.

Answers (0)