生产工单组件修改BAPI
工单组件修改函数组为 CNIF_MAT
1. 获取组件信息
BAPI_NETWORK_COMP_GETDETAILBAPI_NETWORK_COMP_GETLIST
2.修改组件信息 BAPI_NETWORK_COMP_CHANGE
3.删除组件信息 BAPI_NETWORK_COMP_REMOVE
4.添加组件信息 BAPI_NETWORK_COMP_ADD(不能用,参见另一篇博文)
其中基本使用方法为:获取后进行修改,也就是1和2和组合。
示例代码,举例如下:
REPORT ytest_co02.
"==================示例数据======================
DATA:
BEGIN OF it_comp ,
matnr TYPE mara-matnr,
posnr TYPE resb-rspos,
idnrk TYPE mara-matnr,
meins TYPE meins,
menge TYPE menge_d,
aufnr TYPE afko-aufnr,
lgort TYPE lgort_d,
text TYPE char100,
END OF it_comp.
it_comp-matnr = '000000541003089900'.
it_comp-idnrk = '000000404016392000'.
it_comp-posnr = '0010' .
it_comp-menge = '720' .
it_comp-aufnr = '000010462694'.
it_comp-lgort = '1013'.
"==================示例数据x结束======================
DATA: return LIKE bapiret2,
li_components_change LIKE TABLE OF bapi_network_comp_change,
lw_components_change LIKE bapi_network_comp_change,
li_components_change_update LIKE TABLE OF bapi_network_comp_cng_upd,
lw_components_change_update LIKE bapi_network_comp_cng_upd,
e_message_table LIKE TABLE OF bapi_meth_message.
DATA:li_components_detail LIKE TABLE OF bapi_network_comp_detail .
DATA:lw_components_detail LIKE bapi_network_comp_detail .
CLEAR:
li_components_detail,li_components_detail[],
li_components_change,li_components_change[] ,
li_components_change_update,li_components_change_update[],
e_message_table,e_message_table[].
CALL FUNCTION 'BAPI_NETWORK_COMP_GETDETAIL'
EXPORTING
number = it_comp-aufnr
TABLES
e_components_detail = li_components_detail.
LOOP AT li_components_detail INTO lw_components_detail WHERE item_number = it_comp-posnr AND material = it_comp-idnrk.
lw_components_change-component = lw_components_detail-component.
lw_components_change-entry_quantity = it_comp-menge.
lw_components_change-stge_loc = it_comp-lgort.
APPEND lw_components_change TO li_components_change .
lw_components_change_update-component = lw_components_detail-component.
IF it_comp-menge IS NOT INITIAL .
lw_components_change_update-entry_quantity = 'X'.
ENDIF .
IF it_comp-meins IS NOT INITIAL .
lw_components_change_update-base_uom = 'X'.
ENDIF .
IF it_comp-lgort IS NOT INITIAL .
lw_components_change_update-stge_loc = 'X'.
ENDIF .
APPEND lw_components_change_update TO li_components_change_update .
ENDLOOP.
CALL FUNCTION 'BAPI_NETWORK_COMP_CHANGE'
EXPORTING
number = it_comp-aufnr
IMPORTING
return = return
TABLES
i_components_change = li_components_change
i_components_change_update = li_components_change_update
e_message_table = e_message_table.
"todo: 处理返回消息
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.