2012 Dec 12 2:47 AM
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.
2012 Dec 12 3:03 AM
Hi Srikant,
Can you please chek the data being passed to the BAPI after 1st iteration.
There could be a possibility that as you have not cleared the variables the same data is being passed again.
Kindly check and revert back.
Regards,
Amit
2012 Dec 12 3:11 AM
Hi Amit,
I have checked the values in runtime, i am passing different contract numbers.
Regards,
Srikanth.
2012 Dec 12 3:26 AM
HI Srikant,
Can you please share the code which you are using , i mean show us the loop.
Regards,
Amit
2012 Dec 12 4:41 AM
Hi Amit,
Here is the code.
loop ay i_vbak into wa_vbak.
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.
CLEAR :li_return, wa_vbak,l_vbeln.
REFRESH : LI_RETURN,
endloop.
2012 Dec 12 6:41 AM
Hi Srikant,
You are hardcoding the Doctype as 'ZIRS'.
We need to check whether this doc type is valid for all the sales order or not.
Can you please chek this FM SD_SALES_DOCUMENT_COPY.
and check the value of da_vbakkom and sy-subrc.
If sy-subrc is Zero , then only this document can be copied else not.
Please try and revert back.
Regards,
Amit