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: 

Document number in SD_DOCUMENT_COPY_ONE_STEP

Former Member
0 Kudos
139

Hi all,

In one scenario,it's used SD_DOCUMENT_COPY_ONE_STEP to create documents .Is there any FM to find the newly created document number ?. See the code below



types: BEGIN OF ty_vbak,
          vbeln TYPE vbeln_va,
          auart TYPE vbak-auart,
          vkorg TYPE vbak-vkorg,
          vtweg TYPE vbak-vtweg,
       END OF ty_vbak.

DATA  :it_vbak TYPE TABLE OF  ty_vbak,
	wa_vbak type ty_vbak.	

SELECT vbeln auart vkorg vtweg FROM vbak
    INTO  TABLE it_vbak WHERE erdat =  sy-datum
                          AND auart IN ( <so doc types>).

LOOP AT it_vbak INTO wa_vbak.
  CASE wa_vbak-auart.
    WHEN gc_so_doc_type_1.
      lv_auarn  = gc_so_doc_type_10.
    WHEN gc_so_doc_type_2.
      lv_auarn  = gc_so_doc_type_20.
  ENDCASE.

    CALL FUNCTION 'SD_DOCUMENT_COPY_ONE_STEP'
      EXPORTING
        i_auarn = lv_auarn
        i_vbeln = wa_vbak-vbeln.

*find newly created doc no of type 10 or 20
    SELECT vbeln
           erdat
           INTO TABLE it_vbeln_new_so
           FROM  vbak
             WHERE auart = lv_auarn  AND
                   erdat = sy-datum. .

ENDLOOP.

Instead of using SELECT query after 'SD_DOCUMENT_COPY_ONE_STEP', is there any FM to get the same as the select is not reccomended inside the LOOP.

Thanks and regards

Jijo

1 ACCEPTED SOLUTION

Former Member
0 Kudos
73

Hi,

Check

SD_SALESDOCUMENT_CREATE

BAPI_SALESORDER_CREATEFROMDAT2

2 REPLIES 2

Former Member
0 Kudos
74

Hi,

Check

SD_SALESDOCUMENT_CREATE

BAPI_SALESORDER_CREATEFROMDAT2

0 Kudos
73

Hi,

The above FM used only to create sales orders with header and item details.

I used FMs.


BAPI_SALESORDER_GETLISTBOS     Sales Order with BOS: List of all Orders for Cus 
BS01_SALESORDER_GETDETAIL      Sales Order: Display Order Data of Order         
BS01_SALESORDER_GETLIST        Sales Order: List of all Orders for Customer    

But all are terminated with errors.

Thanks and regards

Jijo