Application Development 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: 

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hello everyone!

I'm using bapi BAPI_SALESORDER_CREATEFROMDAT2 to create new sales orders docs.

Some of the items i want to introduce are referenced by a corresponding invoice item. How can i do this on the parameters of the bapi??

Use this example: invoice number 5555 - posnr 10

thank you everyone in advance.

13 REPLIES 13

Former Member
0 Kudos

I know i have to use

ORDER_CFGS_REF STRUCTURE BAPICUCFG OPTIONAL

My question is: how ? can anyone show a simple example ?

0 Kudos

Nuno,

I might be wrong, but are you sure you can refer a sales order to a Invoice document line item.

Regards,

Ravi

0 Kudos

Hello Ravi,

Yes, i'm sure. On transaction VA01, choose on the first top-menu 'Create With Reference' (i have it in portuguese, so sorry if it's not the right translation ).

Nuno

0 Kudos

Nuno,

I looked into the structure of the BAPI as well as the VA01 transaction. In VA01 I could only find the doucment no. reference that you can mentiond. I could not find the line item no. as well.

So, I am assuming that you can create a document with ref to another document (but no particular line items). Given that, if you look at the HEADER data of the BAPI ORDER_HEADER_IN LIKE BAPISDHD1 STRUCTURE BAPISDHD1, there is two fields REFDOCTYPE and REF_DOC where you can specify the document type of the ref doc (Quote / Inquiry / Sales Order etc) and the document no.

Regards,

Ravi

note : please mark the helpful answers

0 Kudos

Ravi,

i'll try to show you how i can reference an item from an invoice to an item in my new sales order. Names in my SAP system are in portuguese, so i'll translate probably into a more literal way, but i think you can get there.

VA01 -> Sales Doc (first menu) -> Create with Reference -> select tab InvoiceDoc -> choose Invoice number -> press button "select items" -> then you'll get a list of all the items belonging to that invoice, being able to choose one of them.

You can also check the BAPISDITM structure of the FM BAPI_SALESORDER_CREATEFROMDAT2, used for the ORDER_ITEMS_IN table.

There you have fields REF_DOC, REF_DOC_IT and REF_DOC_CA (last one to specify type of document, this case 'M' for invoice).

I allready tried filling these 3 fields, and when i check my created document, i can see the item invoice by pressing work-flow key.

My problem is that i want my new item, referenced from that invoice item, to also IMPORT pricing conditions from there, because some times those values are different.

i hope this will help to understand my problem.

thanks

Nuno

0 Kudos

If anyone has any idea on how to solve this, i'm really needing some help here. The problem is still maintaining.

Thank you,

Nuno

0 Kudos

If you were able to create a sales order referring to an invoice by filling the REF_DOC, REF_DOC_IT and REF_DOC_CA fields, then your problem is resolved.

But if you want the sales order to be created taking all the values from the invoice exactly the same way as in the invoice, then it is a different issue. Whenever you create a sales document referring to another sales document, what comes into picture is a config task called 'Copy control'. This is what controls what can be copied, what is modified, etc. Please check with your config specialist to see what needs to be done.

Here is the config(tcode SPRO) path for your reference.


Implementation Guide for R/3 Customizing (IMG)
-->Sales and Distribution
   -->Sales
      -->Maintain Copy Control for Sales Documents
         -->Copying Control: Billing Document to Sales Document

Alternatively, you can reach here by using transaction VTAF.

Once in this transaction, select the line that relevant for you(target document type and source document type combination). Double click on 'Item' on the left side. Select the appropriate 'Item Category'. Then do 'Display'. On the right side, you will see a field called 'Pricing Type'. That needs to be a 'D' if you want the pricing to be copied as it is from the billing document. Look at the possible values there, you will know.

Please let me know if you need further assistance in this regard.

Srinivas

0 Kudos

Hello Srinivas,

Thank you very much for your fast answer. Today i'm not working at the R3 system where i have that problem. But monday, as soon as i arrive at the office, i'll try your suggestion.

Nevertheless, i still have some doubts if it'll work. I remember seeing users and functionals using transaction VA01, referencing the item of the invoice, and then the pricing conditions were imported with no problem at all. This behaviour probably means that the configuration you mention is allready probably well done, and that i'm missing some other parameter on the BAPI FM.

I'll be in touch...

0 Kudos

Hello Nuno,

I think you have been talking about two different things.

1 - Item reference: There are fields in the sales order that reference other SD documents. That is a field, that establishes the document flow. Its a reference, but it doesn't mean the itens are exactly the same.

2 - Document Copy: As someone said, there are standard document copy mechanisms that can be configured. These are used for instance during the creation of a request for credit/debit memo, based on a billing document (this seems to be your scenario). It takes a SD documents, and copies its content (using the rules) into a new one.

In my view you have two options. Either you find the standard program/FM used for document copy you see if it can be used for your purposes, or you'll need to do the copy "manually" inside your program. This copy would have to include sales conditions.

Or are you sure the VA01 standard copy only supplies references to that BAPI, and all the copy logic is already inside(the BAPI)?

Message was edited by: João Sousa

0 Kudos

Hello João,

I'm reaching the conclusion that functionally what they want is a "mid-term" of what you just explained. That is, in part they want that a new item from a new sales order document refers to an invoice doc, and imports from there the billing conditions and the material number, but then i need to add manually my own quantity, that can differ from the invoice for several reasons.

Even more, in the same sales order document, i've seen references to different invoices for different items of the new doc.

Do you have any suggestion for a FM to copy item elements from an Invoice to a sales order ??

thank you,

Nuno

0 Kudos

You cannot have it both ways. Once you change the quantity, you are effecting the pricing and the system will perform a new pricing based on your new quantity. So that reference to the invoice may be there, but the pricing will no longer be the same.

Are you seeing different pricing conditions popping up or going away? That could be again because of the quantity changes.

Just for testing purposes, see if you can create a sales document referring to a billing document without any changes done. If it works and you can see the conditions carried forward correctly, then it is your changes to quantity that are effecting it.

ferry_lianto
Active Contributor
0 Kudos

Hi Nuno,

You can code something like this which refer to sales order line item.

wa_order_cfgs_ref-posex = zwa_order_items_in-po_itm_no.
wa_order_cfgs_ref-config_id = zwa_order_items_in-po_itm_no.
wa_order_cfgs_ref-root_id = '00000001'.
APPEND wa_order_cfgs_ref TO i_order_cfgs_ref.

Also please check FM Documentation as well.

Hope this will help.

Regards,

Ferry Lianto

Former Member
0 Kudos

Dear Nuno Santos,

You have closed the thead as answered.

But I am not able to see the solution.

Perhaps, you have found some solution in the meantime. If so, can you kindly share the same with us, since we are facing the same problem.

Thanks

DMR