Skip to Content
0
Former Member
Dec 12, 2012 at 02:47 AM

BAPI_SALESDOCUMENT_COPY is not returning document number.

411 Views

Hi,

I am trying to create sales document with refrence to contract by using BAPI 'BAPI_SALESDOCUMENT_COPY', It is returning the document number for the first iteration and not returning for other iteratons and not returning errors too. Can you please suggest, what could be the reason.

Here is my code.

data:

L_VBELN TYPE VBELN_VA,

LI_RETURN TYPE TABLE OF BAPIRET2.

* Create DMR by copying the contract.
CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'
EXPORTING
SALESDOCUMENT = WA_VBAK-VBELN
DOCUMENTTYPE = 'ZIRS'
* TESTRUN = ' '
IMPORTING
SALESDOCUMENT_EX = L_VBELN
TABLES
RETURN = LI_RETURN.

IF L_VBELN IS NOT INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.

endif.

Regards,

Srikanth.