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 to create sales order with reference

glauco
Active Contributor
0 Kudos

Hi.

I'm looking for a solution to create a sales order with reference, in one week wasted. For example, I wasted some days until discovery the quantity will be filled (in new document) only if I fill schedule lines.

I searched in the forum (and sap notes) and found some suggestions, but I could not solve this issue.

My program is already codificated and I tryied two different BAPI's and also Call transaction. But until now, no one works fine. By BAPI, it creates document but occurs problems liek bellow.

I need create a sales order with reference, but functional asked to:

1- same repeated material items in ref. doc will become only one summarized line in new document; So, copy items will be N (original items) x M (probably less items, by using collect by material code).

2- New document type will be other (I'm filling it, ok).

3- Main problem until now:

-> BAPI BAPI_SALESORDER_CREATEFROMDAT2, does not run copy control rotines:

Here we have some important rotines in control copy, and must be relevant to new document.

-> In BAPI transaction I found BAPI_SALESDOCU_CREATEWITHDIA, but some errors (V2068, V4219, V0102) occurs in dialog way and TI_RETURN comes back empty.

PS: I tryied a lot of configurations to BAPI BAPI BAPI_SALESORDER_CREATEFROMDAT2. One of those was without items and running VA02 after that to add items. But this way also does not rum copy control.

PS.2: I was woundering if I create new document exactly equal to original document and aftar that I delete itens and modify quantities with call VA02.

What do you think ?

Apreciate any help.

best regards.

Glauco

4 REPLIES 4

former_member194152
Contributor
0 Kudos

Have you tried to fill following fields in table ORDER_ITEMS_IN and ORDER_ITEMS_INX :

REF_DOC

REF_DOC_IT

REF_DOC_CA

of  BAPI_SALESORDER_CREATEFROMDAT2?

0 Kudos

Hi gagan.

Yes. I've tryied these fields and also in header.

The problem is on creating, this BAPI BAPI_SALESORDER_CREATEFROMDAT2 does not call copy controls rotines.

PS: I will try using call transaction command with VA01 with reference. In sequence, I'll try BAPI (or call transaction to VA02) to change some fields which do not fill automatically in creation time.

best regards.

Glauco

Message was edited by: Glauco Kubrusly

Former Member

I know this is a little late for your question, but in case anyone else is researching to find a solution, I accomplished it this way:

In addition to calling the BAPI to create sales document, I implemented BADI_SD_SALES_CHECK_REF.

Before calling the BAPI, I saved relevant parameters including the lines I wanted to copy to a static class attribute. Minimal data is sent in the BAPI call including customer, document type, and sales area. In the BADI implementation, I filled the table of line items to copy from this class attribute. I also used some of these attributes in copy control routines, but some values had to be set in save_document_prepare since as many of us realize, other code after copy routines will sometimes override copied data. Importantly after return of BAPI call, the class attributes are cleared and refilled for repeated BAPI calls.

Former Member
0 Kudos

use BAPI_SALESDOCUMENT_COPY