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

how to create sales order using bapi

Former Member
0 Likes
656

hi gurus

can anyone suggest me

how to create sales order using bapi

thanks&regards

mark.

hi gurus

can anyone suggest me

how to create sales order using bapi

thanks&regards

mark.

4 REPLIES 4
Read only

Sm1tje
Active Contributor
0 Likes
625

Use BAPI 'BAPISALESORDERCREATEFROMDATA*. Don't know the exact name, and have a look at the documentation. of the BAPI.

Read only

Former Member
0 Likes
625

Hi,

BAPI BAPI_SALESORDER_CREATEFROMDAT2

check the sample code

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreat...

Regards

Kiran Sure

Read only

asik_shameem
Active Contributor
0 Likes
625

Hi

You can use the bapi BAPI_SALESORDER_CREATEFROMDAT2.

There mandatory fields are below.

Header: ORDER_HEADER_IN

Sales order type

Sales organisation

Distribution channel

Division

Item: ORDER_ITEMS_IN

Material number (with leading zeros)

Quantity

plant

Partner: ORDER_PARTNERS

SP, sold-to party

Customer number (with leading zeros)

Read only

0 Likes
625

TABLES: VBAK,VBAP,VBEP.

DATA: ORDER_HEADER LIKE BAPISDHEAD,

" Sales and Distribution Document Header

ORDERPARTNER LIKE BAPIPARTNR OCCURS 0 WITH HEADER LINE,

" SD Document Partner

ORDER_ITEM_IN LIKE BAPIITEMIN OCCURS 0 WITH HEADER LINE,

" Create SD Document Item

HEADER_IND LIKE BAPISDHEADX,

" Checkbox Fields for Sales and Distribution Document Header

RETURN LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE,

" Return Parameter

W_ORDER LIKE BAPIVBELN-VBELN

." Sales Document

  • Define Parameters.

PARAMETERS : G_DOC_TY LIKE BAPISDHEAD-DOC_TYPE, "= 'TA'

G_SA_ORG LIKE BAPISDHEAD-SALES_ORG, "= '5555'

G_DIS_CH LIKE BAPISDHEAD-DISTR_CHAN, "= '55'

G_DIVIS LIKE BAPISDHEAD-DIVISION, "= '55'

G_P_NUMB LIKE BAPIPARTNR-PARTN_NUMB, "= '0000003002'

G_P_ROLE LIKE BAPIPARTNR-PARTN_ROLE, "= 'SP'

G_MAT LIKE BAPIITEMIN-MATERIAL, "= 'MAT1'

G_R_QTY LIKE BAPIITEMIN-REQ_QTY. "= '2.000'

  • Pass the Parameters into ORDER-HEADER.

ORDER_HEADER-DOC_TYPE = G_DOC_TY.

ORDER_HEADER-SALES_ORG = G_SA_ORG.

ORDER_HEADER-DISTR_CHAN = G_DIS_CH.

ORDER_HEADER-DIVISION = G_DIVIS.

  • Fill the internal table orderpartner.

ORDERPARTNER-PARTN_NUMB = G_P_NUMB.

ORDERPARTNER-PARTN_ROLE = G_P_ROLE.

APPEND ORDERPARTNER.

CLEAR ORDERPARTNER.

  • Fill the internal table order_item_in.

ORDER_ITEM_IN-MATERIAL = G_MAT.

ORDER_ITEM_IN-REQ_QTY = G_R_QTY.

APPEND ORDER_ITEM_IN.

CLEAR ORDER_ITEM_IN.

  • Call function BAPI_SALESORDER_CREATEFROMDAT1.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'

EXPORTING

ORDER_HEADER_IN = ORDER_HEADER

CONVERT_PARVW_AUART = 'X'

IMPORTING

SALESDOCUMENT = W_ORDER

RETURN = RETURN

TABLES

ORDER_ITEMS_IN = ORDER_ITEM_IN

ORDER_PARTNERS = ORDERPARTNER.

  • Commit BAPI's process

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

READ TABLE RETURN WITH KEY TYPE = 'E'.

IF SY-SUBRC = 0.

WRITE: 'Sales order not created' .

ELSE.

WRITE: ' Sales order NO.',W_ORDER COLOR 7, 'created successfully'.

ENDIF.

Thanks & Regards

Alok Vishnoi.