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: 

Referencing Sales Order to a Quotation via BAPI

Former Member
0 Kudos

Dear all,

I encouter problems to reference a Sales Order to a Quotation when I try to use the SAP BAPI 'BAPI_SALESORDER_CREATEFROMDAT2'. Even though later when I managed to create the referencing on both the Sales Order Header and Sales Order Line to the Quotation, the system still doesn't closed the Quotation status as Completed. This has caused the Quotation remains active and open for other Sales Order for referencing. Any ideas?

Thank you and regards;

-ah tiang-

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

Did you used BAPI commit...after calling the BAPI...

if not please try that..

former_member188685
Active Contributor
0 Kudos

are you using this after calling the bapi BAPI_TRANSACTION_COMMIT..

Former Member
0 Kudos

Hi!

According to OSS note 370988 it seems you can't create sales order properly with reference to quotation using BAPI_SALESORDER_CREATEFROMDAT2 in straight-forward way:

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 fixed rules. The rules for transferring information from the 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 target quantity of the contract can be reduced by the order 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 the BAPI.

1. Create a '1:1 ' - that is, a document copy of a sales document (customer quotation, order) with 'BAPI_SALESDOCUMENT_COPY'. At this point, you cannot create the 1:1 copy of either a billing document or a delivery.

2. Create a sales document that refers to an existing document with 'BAPISDORDER_GETDETAILEDLIST' and 'BAPI_SALESORDER_CREATEFROMDAT2'.

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

1. Create the documents using the BAPI_SALESDOCUMENT_COPY function module. However, this only permits a 1:1 copy without factoring out individual items.

2. After you have created the document copy, you can use a change BAPI to edit this copy.

For solution No. 2

1. Collect the data for the reference document (for example a customer quotation) with the 'BAPISDORDER_GETDETAILEDLIST' function module. In the example code, focus exclusively on the partners, items, schedule lines and conditions.

2. Prepare the Data. Execute the 'copying control' manually. This way, you decide which values are to be transferred.

3. Create the sales document using the 'BAPI_SALESORDER_CREATEFROMDAT2' function module by transferring the prepared data.

4. Finally, you must remove a COMMIT WORK so that the sales document can be written into the database.

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. When you enter the 'condition type' parameter, you can 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).

Hope it helps.

And welcome here on SDN!

Regards,

Maxim.

0 Kudos

Hi, I managed to create the sales order using the referencing but now the problems which I've encounter is that the Quotation status remains open under the Document Flow Overview and another Sales Order still can re-reference to the same Quotation again...???!!!!

Any help on this..??