‎2008 Nov 10 3:01 PM
Hi
I am having one sales order which have essential data.i want to copy is SO in to other SO.Is there with u any code through Bapi ..
‎2008 Nov 10 4:06 PM
Hi,
This should work.
method create_from_inquiry.
data: lv_auara type auart.
data: ls_vbak type vbak.
data: ls_buf type sado_buf_flagstring.
data: ls_vbakkom type vbakkom.
data: lv_testrun type xfeld.
data: ls_ret2 type bapiret2.
data: lv_error type xfeld.
move testrun to lv_testrun.
select single * from vbak
into ls_vbak
where vbeln = vbeln_in.
if new_ordertype is initial.
select single auara
from tvak
into lv_auara
where auart = ls_vbak-auart.
else.
lv_auara = new_ordertype.
endif.
sy-tcode = 'VA01'.
call function 'BAPI_SALESDOCUMENT_COPY'
exporting
salesdocument = vbeln_in
documenttype = lv_auara
testrun = lv_testrun
importing
salesdocument_ex = vbeln_out
tables
return = bapireturn.
if lv_testrun is initial.
lv_error = zcl_bapi=>check_for_errors( bapireturn ).
if lv_error is initial.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
ls_ret2-type = 'S'.
ls_ret2-message = 'Verkooporder gecreeerd'.
ls_ret2-message_v1 = vbeln_out.
append ls_ret2 to bapireturn.
endif.
endif.
endmethod.
‎2008 Nov 10 3:17 PM
Hi,
Did you search the forum ?
https://www.sdn.sap.com/irj/scn/advancedsearch?query=bapitocreatesalesorderwithreference&cat=sdn_all
regards,
Advait
‎2008 Nov 10 4:06 PM
Hi,
This should work.
method create_from_inquiry.
data: lv_auara type auart.
data: ls_vbak type vbak.
data: ls_buf type sado_buf_flagstring.
data: ls_vbakkom type vbakkom.
data: lv_testrun type xfeld.
data: ls_ret2 type bapiret2.
data: lv_error type xfeld.
move testrun to lv_testrun.
select single * from vbak
into ls_vbak
where vbeln = vbeln_in.
if new_ordertype is initial.
select single auara
from tvak
into lv_auara
where auart = ls_vbak-auart.
else.
lv_auara = new_ordertype.
endif.
sy-tcode = 'VA01'.
call function 'BAPI_SALESDOCUMENT_COPY'
exporting
salesdocument = vbeln_in
documenttype = lv_auara
testrun = lv_testrun
importing
salesdocument_ex = vbeln_out
tables
return = bapireturn.
if lv_testrun is initial.
lv_error = zcl_bapi=>check_for_errors( bapireturn ).
if lv_error is initial.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
ls_ret2-type = 'S'.
ls_ret2-message = 'Verkooporder gecreeerd'.
ls_ret2-message_v1 = vbeln_out.
append ls_ret2 to bapireturn.
endif.
endif.
endmethod.