05-29-2015 1:59 PM
We have a requirement that we need to create return order with reference to billing document with copying of all condition types in the basic order/invoice, before I asked this question in SCN I have tried to used some BAPI and FM
BAPI_SALESORDER_CREATFROMDAT1, SD_SALESDOCUMENT_CREATE , BAPI_CUSTOMERRETURN_CREATE,
BAPI_SALESORDER_CREATEFORMDAT2.
we are able to create the order but some of the condition types are not getting copied from the original invoice/order.
They are YBSC(Split case fee) , and if I change One condition type YCHN(Chain Discount) new condition type YRFD( Refer to Discount will be getting created) as of now except manually changed conditions, the FM for sales order creation will creating the condition types into the order .
since client dos not want to pass manually because if we add new conditions in future they don't want to change the program every time.
Please let me know if any other FM/BAPI apart from the the above and it should copied all the original condition types as same as original order/invoice .
Please help me guys. let me know if you need more information.
05-29-2015 2:52 PM
Gangadhar,
Before you create your order, how do fetch the details of the previous document? Are you performing a sales doc read and then feeding the data to your create sales order FM?
Like the option create with reference in VA01, there is no standard way of selecting the line items thru a BAPI. In order to achieve this functionality, please read thru the note - 370988
There are 2 options. Copy the order into a new order and then change the items, if required.
The other option is to read the previous document and then manually pass the required fields for the required items to create the new order.
In the first option, the entire order will be copied including the conditions. If your requirement is not to change/select particular items, you should look at option 1 as its a standard copy.
Hope this helps.
Thanks,
Vikram.M
06-01-2015 8:44 AM
Hi Vikram,
Thank you for your attention on this.
The Option 1 : copying order new order: I mean you re talking about the basic order (Not new order ) if I am not wrong .. this will not accept by client because they do not want to change and what ever the condition types in basic order this should be copied as like as VA01 does hence it will not useful I think
The option 2: Passing Manually : I was tried to create the Order by passing Manually .. I mean I passed explicitly condition types and BAPI throwing an error since some of the condition types the Function module should only create like Origin of Condition type is A (Automatic Pricing ) .
The Link you have copied in thread I am not able to open it is asking credentials .. I am not sure how can we look into that.. can you please upload the document or any other way which you like .
I am still looking for the Options on this.
06-01-2015 12:15 PM
Hi,
Why don't you use BAPI_SALESDOCUMENT_COPY. This BAPI is specifically wriiten to copy things from preceding doc to subsequent doc as long as you have proper copy routine created and assigned which is pretty standard.
Hope it helps.
06-01-2015 1:02 PM
Hi Rudra,
Thanks for your Reply.
I think we will not use because my basic order is batch order and I need to create the Return order .
for batch order the delivery and invoice are done already . if I use copy I will only copy new batch order and it will create return order I mean both the Document types are different in my case.
06-01-2015 1:12 PM
No worries.
As I said, it is meant for copying document and you can actually create a return order from Invoice using that BAPI. The pricing are always tricky and if I would have been your place I would be trying to use as much as standard code as possible.
Anyway , best of luck for your code.
Happy coding.
06-01-2015 1:22 PM
Thanks for your wishes.
The BAPI is perfectly creating the order but the issue with only with YBSC.
Evethogh i create Normal VA01 order without reference the YBSC not copied
and if create VA01 with reference invoice it is getting copied. the customer is asking in the second way ? I thought I would like to pass the YBSC to BAPI he doesn't accepting the BAPI it self should create the YBSC automatically he is saying.. so I was struck here..
06-01-2015 1:28 PM
Hi,
If it works via standard transaction VA01 and copying works fine, it will also work via that BAPI.
When you try to create a SO from scratch using CREATFROM* BAPIs you have to pass the manual condition separately . If you can make it work then the COPY BAPI is not needed obviously.
06-01-2015 1:45 PM
Hi Rudra,
I did not get your point.. can you please elaborate on the above.
06-01-2015 2:03 PM
Hi there,
You only mentioned it works fine when you create via VA01 with option "Create via reference" and your condition type YBSC is copied successfully right?
{code}
Evethogh i create Normal VA01 order without reference the YBSC not copied
and if create VA01 with reference invoice it is getting copied. the customer is asking in the second way ? I thought I would like to pass the YBSC to BAPI he doesn't accepting the BAPI it self should create the YBSC automatically he is saying.. so I was struck here..
{code}
What I meant was to simulate the same thing programmatically using the COPY BAPI as SAP takes care of pricing part which actually saves you the pain of making the pricing correct via the other BAPIs.
Hope it makes sense now.
06-01-2015 2:30 PM
Hey Rudra,
yep correct we can use BAPI COPY for creating the return order , I was tried just now and its working fine . no issues for Pricing. but we have one more twist here... in the Program concept we have additional functionality like Adding New Line item like va01 we can add new items .. but if I use copy it will copy only for Existing items what about new line items ? I am still thinking to use sales_order_change BAPI?
any other options you have?
06-01-2015 2:38 PM
Hi,
You thought correctly.
so call the BAPI to copy first.
Then as you have thought use CHANGE BAPI to add line items / Modify.
06-01-2015 2:49 PM
Gangadhar,
gangadhar soora wrote:
Hey Rudra,
yep correct we can use BAPI COPY for creating the return order , I was tried just now and its working fine . no issues for Pricing. but we have one more twist here... in the Program concept we have additional functionality like Adding New Line item like va01 we can add new items .. but if I use copy it will copy only for Existing items what about new line items ? I am still thinking to use sales_order_change BAPI?
any other options you have?
This is exactly what the note specifies. Use the copy option first. Once you have the new order, you can do a change to play with the line items. This is SAPs way of performing a create with reference when performed using BAPIs.
The below is from the note
Symptom
This note describes the problems of the 'Create with reference' function when using BAPIs to create sales documents.
If you are working online, you can use this function module to create a sales document with reference to an existing sales document or a billing document (for example, a debit or credit memo request) according to fix source document to the target document are defined in the copying control on header and item level. The creation with reference permits an item selection.
When you use BAPIs in SD, a function of this type is not fully available. A reference is only possible for a quantity contract, so that the targ quantity of the sales document. Furthermore, the document flow is also updated.
As an alternative to 'Create with reference' in Transaction VA01, two variants are provided for solving the 'Create with reference' problem in t
Other Terms
BAPI_SALESDOCUMENT_COPY, BAPI_SALESORDER_CHANGE, BAPI_CUSTOMERINQUIRY_CHANGE, BAPI_CUSTOMERQUOTATION_CHANGE, BAPI_SALESORDER_CREATEFROMDAT1, BAP BAPI_SALESORDER_CREATEFROMDATA, BAPISDORDER_GETDETAILEDLIST
Reason and Prerequisites
As of yet, no method exists for creating a sales document that refers to an existing document.
Solution
For solution No. 1
For solution No. 2
An example of solution 2 is attached as a text file. You are allowed to select items and quantities for example, if you use input parameters. If there are no entries, then transfer 1:1 from the reference document. Wh determine whether conditions are copied or recalculated ('G' for transferring from the preceding document; 'B' or ' ' for re-determining, and 'C' for re-determining with transfer of the manual elements).
Thanks,
Vikram.M
06-05-2015 1:18 PM
Hi Ganga,
Is your problem solved. Looks like yes.
Would you mind closing the thread please?
http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why
R