2008 May 13 11:01 AM
hi gurus
can anyone suggest me
how to create sales order using bapi
thanks®ards
mark.
hi gurus
can anyone suggest me
how to create sales order using bapi
thanks®ards
mark.
2008 May 13 11:04 AM
Use BAPI 'BAPISALESORDERCREATEFROMDATA*. Don't know the exact name, and have a look at the documentation. of the BAPI.
2008 May 13 11:09 AM
Hi,
BAPI BAPI_SALESORDER_CREATEFROMDAT2
check the sample code
Regards
Kiran Sure
2008 May 13 11:12 AM
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)
2008 May 13 1:06 PM
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.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |