DATA ls_return TYPE bapireturn1 .
DATA ls_plannedorder TYPE bapi_pldord -pldord_num .
DATA lt_componentsdata TYPE STANDARD TABLE OF bapi_pldordcomp_i1 WITH HEADER LINE.
ls_headerdata-pldord_profile = 'LA'.
ls_headerdata-material = l_tcpn. "'K000128'.
ls_headerdata-plan_plant = gw_out-plwrk.
ls_headerdata-prod_plant = gw_out-plwrk.
ls_headerdata-order_start_date = gw_out-jhsj.
ls_headerdata-order_fin_date = gw_out-jhsj + 2.
ls_headerdata-total_plord_qty = gw_out-gamng."dwyl.
“以下是需要复制BOM时需要选择的参数(组件直接从BOM复制,不需要增加组件)
if l_copy = 'X'.
ls_headerdata-conversion_ind = 'X'.
ls_headerdata-firming_ind = 'X'.ls_headerdata-bom_exp_fix_ind = 'X'.
else.
”以下是不需要复制BOM时需要选择的参数(组件不从BOM复制,需要增加组件参数信息)
ls_headerdata-manual_component = '1'.
ls_headerdata-firming_ind = 'X'.
LOOP AT lt_ali_ato INTO lw_ali_ato.
lt_componentsdata-plant = gw_out-plwrk.
lt_componentsdata-material = lw_ali_ato-sjpn.
lt_componentsdata-entry_qty = lw_ali_ato-ddzyl.
APPEND lt_componentsdata.
ENDLOOP.
endif.
"调用BAPI创建计划订单
CALL FUNCTION 'BAPI_PLANNEDORDER_CREATE'
EXPORTING
headerdata = ls_headerdata
IMPORTING
return = ls_return
plannedorder = ls_plannedorder
TABLES
componentsdata = lt_componentsdata[].