‎2007 Apr 02 7:20 PM
Hi friends,
I am trying to create Sales Order with reference to Scheduling Agreement, but although the
order gets created, it does not contain reference document information.
The BAPI I am using is BAPI_SALESORDER_CREATEFROMDAT2.
Could anyone give me the program to upload from an external source for doing this .
With Regards,
Sarath.
‎2007 Apr 02 7:25 PM
You need to create these references before calling the BAPI:
Add something like this *****
Assigning header.
hdr-REF_DOC = i_vakgu-vbeln. "assign quotation # to sales order
hdr-REFDOC_CAT = 'B'. "assign Quotation to VBTYP_N.
Assigning ref doc to create line item entries in VBFA.
itm-REF_DOC = i_vakgu-vbeln.
itm-REF_DOC_IT = i_vbap-posnr.
itm-REF_DOC_CA = 'B'.
append itm.
Add something like this above *****
Now call BAPI with the References created in <b>hdr</b> and <b>itm</b>
data: ret_text type BAPIRET2.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = hdr
convert = 'X'
IMPORTING
SALESDOCUMENT = salesdoc
TABLES
return = ret_tbl
ORDER_ITEMS_IN = itm
ORDER_PARTNERS = prtnr
ORDER_ITEMS_inx = itmx
ORDER_CONDITIONS_IN = conds
ORDER_CONDITIONS_INX = condsx
order_schedules_in = schd_lin.
if sy-subrc = 0
and not salesdoc is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = ret_text.
‎2007 Apr 02 7:25 PM
‎2007 Apr 02 7:25 PM
You need to create these references before calling the BAPI:
Add something like this *****
Assigning header.
hdr-REF_DOC = i_vakgu-vbeln. "assign quotation # to sales order
hdr-REFDOC_CAT = 'B'. "assign Quotation to VBTYP_N.
Assigning ref doc to create line item entries in VBFA.
itm-REF_DOC = i_vakgu-vbeln.
itm-REF_DOC_IT = i_vbap-posnr.
itm-REF_DOC_CA = 'B'.
append itm.
Add something like this above *****
Now call BAPI with the References created in <b>hdr</b> and <b>itm</b>
data: ret_text type BAPIRET2.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = hdr
convert = 'X'
IMPORTING
SALESDOCUMENT = salesdoc
TABLES
return = ret_tbl
ORDER_ITEMS_IN = itm
ORDER_PARTNERS = prtnr
ORDER_ITEMS_inx = itmx
ORDER_CONDITIONS_IN = conds
ORDER_CONDITIONS_INX = condsx
order_schedules_in = schd_lin.
if sy-subrc = 0
and not salesdoc is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = ret_text.
‎2007 Apr 02 7:34 PM
Hi,
Please check this BAPI BAPI_SALESDOCUMENT_COPY.
Regards,
Ferry Lianto