Skip to Content
0
Former Member
Jul 21, 2008 at 10:17 AM

create sales order using 'BAPI_SALESORDER_CREATEFROMDAT1'

139 Views

Hi,

Here is the code below

*-------------------------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
      d_bapireturn1 LIKE bapireturn1, " Bapi return msg
      d_vbeln LIKE bapivbeln-vbeln. " Sales Order Number

* 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 the Bapi to create the sales order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
order_header_in = st_bapisdhead
* WITHOUT_COMMIT = ' '
* CONVERT_PARVW_AUART = ' '
IMPORTING
salesdocument = d_vbeln
* SOLD_TO_PARTY =
* SHIP_TO_PARTY =
* BILLING_PARTY =
return = d_bapireturn1
TABLES
order_items_in = ta_bapiitemin
order_partners = ta_bapipartnr
* ORDER_ITEMS_OUT =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CCARD =
* ORDER_CFGS_BLOB =
* ORDER_SCHEDULE_EX =
.

IF d_vbeln <> space.
  WRITE: 'Sales order No. ', d_vbeln.
ELSE.
  WRITE: 'No data'.
ENDIF.

Why there is no sales order had been created after running this report?

Thanks a lot.

Best Regards,

Stephanie

Edited by: Stephanie HE on Jul 21, 2008 12:17 PM