report test3.
*代码摘抄
Data: loc_bp type BAPIBUS1006_HEAD-BPARTNER.
data: re_return like BAPIRET2 occurs 0.
data: wa_return type BAPIRET2.
data: re_order_header_in like BAPISDHD1.
data: wa_BAPISDH1X type BAPISDH1X.
data: order_partners like BAPIPARNR occurs 0 with header line.
data: order_items_in like BAPISDITM occurs 0 with header line.
data: order_items_sched LIKE bapischdl OCCURS 0 WITH HEADER LINE.
data: g_vbeln like smovbak-vbeln,
l_vbeln like smovbak-vbeln.
move BUSINESSPARTNER to loc_bp.
*delete line if middleware active.
*loc_bp = '0030000309'.
re_order_header_in-DOC_TYPE = 'TA'.
re_order_header_in-SALES_ORG = 'NL01'.
re_order_header_in-DISTR_CHAN = '02'.
re_order_header_in-DIVISION = '01'.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = loc_bp.
append order_partners.
order_partners-partn_role = 'WE'.
order_partners-partn_numb = loc_bp.
append order_partners.
order_items_in-itm_number = '000010'.
order_items_in-MATERIAL = MATERIAL.
order_items_sched-itm_number = '00010'.
order_items_sched-req_qty = '1'.
append order_items_sched.
append order_items_in.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
*DESTINATION 'zorder'
EXPORTING
ORDER_HEADER_IN = re_order_header_in
TESTRUN = ' '
importing
salesdocument = g_vbeln
TABLES
RETURN = re_return
ORDER_ITEMS_IN = order_items_in
ORDER_PARTNERS = order_partners
order_schedules_in = order_items_sched.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*DESTINATION 'zorder'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = wa_return.