SD--模拟创建订单(相关的函数列表的介绍系列篇(4))
BAPI_SALESORDER_SIMULATE - Sales Order: Simulate Sales Order
该函数和BAPI_SALESORDER_CREATEFROMDAT1 参数相同,但是不同的是该函数不会产生订单。你可以用该函数来模拟创建订单,来测试可用性检查和价格等数据,数据返回在 ORDER_ITEMS_OUT中。
样例代码:
REPORT z_salesorder_simulate.
DATA: order_header_in LIKE bapisdhead,
order_items_in LIKE TABLE OF bapiitemin,
return LIKE bapireturn,
wa_order_items_in LIKE LINE OF order_items_in,
order_partners LIKE TABLE OF bapipartnr,
wa_order_partners LIKE LINE OF order_partners,
order_items_out LIKE TABLE OF bapiitemex,
wa_order_items_out LIKE LINE OF order_items_out.
* Fill order_header_in
order_header_in-doc_type = 'TA'.
* Fill order_items_in
wa_order_items_in-material = '000000000000000001'.
wa_order_items_in-req_qty = '1000'.
APPEND wa_order_items_in TO order_items_in.
* Fill order_items_in
wa_order_partners-partn_role = 'AG'.
wa_order_partners-partn_numb = '0000000001'.
APPEND wa_order_partners TO order_partners.
* Execute Function Module BAPI_SALESORDER_SIMULATE
CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'
EXPORTING
order_header_in = order_header_in
IMPORTING
return = return
TABLES
order_items_in = order_items_in
order_partners = order_partners
order_items_out = order_items_out.
* The return structure gives any error messages
WRITE: return-message.
* Print out the order items
LOOP AT order_items_out INTO wa_order_items_out.
WRITE: wa_order_items_out-material,
wa_order_items_out-short_text,
wa_order_items_out-subtotal_2.
ENDLOOP.
该函数和BAPI_SALESORDER_CREATEFROMDAT1 参数相同,但是不同的是该函数不会产生订单。你可以用该函数来模拟创建订单,来测试可用性检查和价格等数据,数据返回在 ORDER_ITEMS_OUT中。
样例代码:
REPORT z_salesorder_simulate.
DATA: order_header_in LIKE bapisdhead,
order_items_in LIKE TABLE OF bapiitemin,
return LIKE bapireturn,
wa_order_items_in LIKE LINE OF order_items_in,
order_partners LIKE TABLE OF bapipartnr,
wa_order_partners LIKE LINE OF order_partners,
order_items_out LIKE TABLE OF bapiitemex,
wa_order_items_out LIKE LINE OF order_items_out.
* Fill order_header_in
order_header_in-doc_type = 'TA'.
* Fill order_items_in
wa_order_items_in-material = '000000000000000001'.
wa_order_items_in-req_qty = '1000'.
APPEND wa_order_items_in TO order_items_in.
* Fill order_items_in
wa_order_partners-partn_role = 'AG'.
wa_order_partners-partn_numb = '0000000001'.
APPEND wa_order_partners TO order_partners.
* Execute Function Module BAPI_SALESORDER_SIMULATE
CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'
EXPORTING
order_header_in = order_header_in
IMPORTING
return = return
TABLES
order_items_in = order_items_in
order_partners = order_partners
order_items_out = order_items_out.
* The return structure gives any error messages
WRITE: return-message.
* Print out the order items
LOOP AT order_items_out INTO wa_order_items_out.
WRITE: wa_order_items_out-material,
wa_order_items_out-short_text,
wa_order_items_out-subtotal_2.
ENDLOOP.