导语:最近在做BOM的东西,涉及到一个BOM相关性的维护,找了一些资料测了测,下面分享一下。
【BAPI名称】:CSAP_MAT_BOM_MAINTAIN
效果图:
代码:
DATA:gv_stko LIKE stko_api01,
gt_stpo LIKE TABLE OF stpo_api03 WITH HEADER LINE,
gt_dep_data LIKE TABLE OF csdep_dat WITH HEADER LINE,
gt_dep_source LIKE TABLE OF csdep_sorc WITH HEADER LINE,
gt_stpo_r LIKE TABLE OF stpo_api02 WITH HEADER LINE,
gv_warning,
gt_dep_data_r LIKE TABLE OF csdep_dat WITH HEADER LINE,
gt_dep_source_r LIKE TABLE OF csdep_sorc WITH HEADER LINE.
CALL FUNCTION 'CSAP_MAT_BOM_READ'
EXPORTING
material = 'CMBC000040'
plant = '1000'
bom_usage = '1'
alternative = '01'
valid_from = '20221116'
TABLES
t_stpo = gt_stpo_r
t_dep_data = gt_dep_data_r
t_dep_source = gt_dep_source_r
EXCEPTIONS
error = 1
OTHERS = 2.
*&更改bom的相关性定义
LOOP AT gt_stpo_r ASSIGNING FIELD-SYMBOL(<fs>) WHERE component = '2509000091'.
<fs>-identifier = 'Z0007'. " 特定客户的 APIs 对象标识符
APPEND <fs> TO gt_stpo.
ENDLOOP.
gt_dep_data-object_id = '2'.
gt_dep_data-identifier = 'Z0007'. "相关性名称
gt_dep_data-bom_no = '00000279'. "gt_stpo_r 里会有这个bom_no
gt_dep_data-item_node = 1. "项目行号
gt_dep_data-dep_intern = 'Z0007'.
gt_dep_data-dep_type = '5'.
gt_dep_data-status = '1'. "1 发布 2 准备中 3 已锁定
gt_dep_data-fldelete = 'X'. "删除标记
APPEND gt_dep_data.
CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
EXPORTING
material = 'CMBC000040'
plant = '1000'
bom_usage = '1'
valid_from = '20221116'
i_stko = gv_stko
fl_commit_and_wait = 'X'
fl_new_item = 'X'
IMPORTING
fl_warning = gv_warning
TABLES
t_stpo = gt_stpo
t_dep_data = gt_dep_data
t_dep_source = gt_dep_source
EXCEPTIONS
error = 1
OTHERS = 2.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
作者:小飞猪猪猪猪猪猪猪–CSDN