DATA: orderdata LIKE bapi_pp_order_create,
order_number LIKE bapi_order_key-order_number,
order_type LIKE bapi_order_copy-order_type,
return LIKE bapiret2.
DATA: aufnr TYPE bdcdata-fval,
fevor TYPE bdcdata-fval,
subrc TYPE syst-subrc,
messtab TYPE STANDARD TABLE OF bdcmsgcoll.
DATA: lt_main TYPE TABLE OF ztpp008w_main,
ls_main TYPE ztpp008w_main,
lt_mat TYPE TABLE OF ztpp008w_mat,
ls_mat TYPE ztpp008w_mat.
DATA: lv_rowno TYPE int4.
LOOP AT gt_alv ASSIGNING <fs_alv> WHERE sel = 'X'.
IF <fs_alv>-icon = icon_led_red.
CONTINUE.
ENDIF.
CLEAR orderdata.
orderdata-material_long = <fs_alv>-matnr. " 物料编码
orderdata-plant = p_werks. " 工厂
orderdata-planning_plant = p_werks. "
orderdata-order_type = 'ZP01'. " 生产订单类型
orderdata-basic_start_date = <fs_alv>-psttr. " 开始日期
orderdata-basic_start_time = '000000'. "
orderdata-basic_end_date = <fs_alv>-pedtr. " 结束日期
orderdata-basic_end_time = '240000'. "
orderdata-prod_version = <fs_alv>-verid. " 生产版本
orderdata-quantity = <fs_alv>-zwcjsl. " 订单数量
orderdata-profit_center = <fs_alv>-prctr. " 利润中心
orderdata-sales_order = <fs_alv>-zvbel. " 销售订单号
orderdata-sales_order_item = <fs_alv>-posnr. " 销售订单行号
CLEAR: return, order_number, order_type.
CALL FUNCTION 'BAPI_PRODORD_CREATE'
EXPORTING
orderdata = orderdata
IMPORTING
return = return
order_number = order_number
order_type = order_type.
IF return-type = 'E' OR return-type = 'A' OR return-type = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
<fs_alv>-icon = icon_led_red.
* <fs_alv>-res = 'E'.
<fs_alv>-msg = return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
<fs_alv>-icon = icon_led_green.
<fs_alv>-msg = '创建成功'(t35).
<fs_alv>-aufnr = order_number.
ENDIF.
ENDLOOP.
创建生产订单 BAPI
于 2024-06-29 10:48:24 首次发布