In SAP before creating a sales order there is a way to simulate it using a BAPI. This can be done using the following BAPI.
SAP ABAP BAPI to Simulate a Sales Order.
BAPISDHEDU Struture of VBEP (Sales Document: Schedule Line Data)
BAPICOND Communication Fields for Maintaining Conditions in the Order
BAPIINCOMP Communication Fields: Incompletion
Note: This is very similar to Sales Order Create BAPI 'BAPI_SALESORDER_CREATEFROMDAT1' but in this case the actual Sales Order is not created instead a simulation is carried out.
*-------------------------Data Declaration-----------------------------*
Data: st_BAPISDHEAD like BAPISDHEAD, " Sales Order Header Data
ta_BAPIITEMIN like BAPIITEMIN occurs 0 with header line, " Ln item
ta_BAPIPARTNR like BAPIPARTNR occurs 0 with header line, " Partner
int_BAPIITEMEX like BAPIITEMEX occurs 0 with header line,
int_BAPISDHEDU like BAPISDHEDU occurs 0 with header line,
int_BAPICOND like BAPICOND occurs 0 with header line,
int_BAPIINCOMP like BAPIINCOMP occurs 0 with header line,
d_BAPIRETURN1 like BAPIRETURN. " Bapi return msg
* Move the data to create sales order in the repective parameters------*
move: 'TA' to st_BAPISDHEAD-DOC_TYPE, " Sales document type
'15493' to st_BAPISDHEAD-PURCH_NO_C,
'00010' to ta_BAPIITEMIN-ITM_NUMBER,
'Y-351' to ta_BAPIITEMIN-MATERIAL,
'1100' to ta_BAPIITEMIN-PLANT,
'1' to ta_BAPIITEMIN-REQ_QTY,
'AG' to ta_BAPIPARTNR-PARTN_ROLE, " Sold to Party
'0000007777' to ta_BAPIPARTNR-PARTN_NUMB.
* Append the internal tables-------------------------------------------*
append ta_BAPIPARTNR.
clear ta_BAPIPARTNR.
append ta_BAPIITEMIN.
clear ta_BAPIITEMIN.
* Move ship to party---------------------------------------------------*
move: 'RG' to ta_BAPIPARTNR-PARTN_ROLE, " Ship to party
'0000007777' to ta_BAPIPARTNR-PARTN_NUMB.
* Append the internal tables-------------------------------------------*
append ta_BAPIPARTNR.
clear ta_BAPIPARTNR.
* Call BAPI to SIMULATE the Order
CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'
EXPORTING
ORDER_HEADER_IN = st_BAPISDHEAD
* CONVERT_PARVW_AUART = ' '
IMPORTING
* SALESDOCUMENT =
* SOLD_TO_PARTY =
* SHIP_TO_PARTY =
* BILLING_PARTY =
RETURN = d_BAPIRETURN1
TABLES
ORDER_ITEMS_IN = ta_BAPIITEMIN
ORDER_PARTNERS = ta_BAPIPARTNR
* ORDER_SCHEDULE_IN =
ORDER_ITEMS_OUT = int_BAPIITEMEX
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CCARD =
* ORDER_CCARD_EX =
ORDER_SCHEDULE_EX = int_BAPISDHEDU
ORDER_CONDITION_EX = int_BAPICOND
ORDER_INCOMPLETE = int_BAPIINCOMP
* MESSAGETABLE =
* EXTENSIONIN =
* PARTNERADDRESSES =
.
IF SY-SUBRC = 0.
ENDIF.
No comments:
Post a Comment