Application Development and Automation 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: 
Read only

Program to

Former Member
0 Likes
2,756

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
469

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.

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
469

Look at <a href="http://www.sap-img.com/fu036.htm">BAPI to create Sales Order with reference</a>. Hope it will help you.

Regards.

Read only

Former Member
0 Likes
470

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.

Read only

ferry_lianto
Active Contributor
0 Likes
469

Hi,

Please check this BAPI BAPI_SALESDOCUMENT_COPY.

Regards,

Ferry Lianto