先在前台创建条数据测试一下,然后把前台的一些必输数据导进bapi里面。在se37里面测试是否创建成功,这个bapi不需要调用BAPI_TRANSACTION_COMMIT。创建成功后,就可以再给其他字段再赋值。跟前台对应测试。
DATA: lv_aennr LIKE csap_mbom-aennr. "Change Numbe
DATA: lv_matnr LIKE csap_mbom-matnr VALUE 'ML-TG13', "Bom material
lv_plant LIKE csap_mbom-werks VALUE '1710',
lv_usage LIKE csap_mbom-stlan VALUE '1', "BOM usage
lv_stlal LIKE csap_mbom-stlal VALUE '1'. "Alternative BOM
DATA: gs_stko LIKE stko_api01, "header data
lv_fl LIKE capiflag-flwarning,
lv_bom LIKE stko_api02,
bom_no LIKE stko_api02-bom_no,
lv_date LIKE csap_mbom-datuv.
lv_date = sy-datum. "System dates cannot be used directly
DATA: gs_item LIKE TABLE OF stpo_api01 WITH HEADER LINE.
DATA: lt_dep_data LIKE TABLE OF csdep_dat,
lt_dep_descr LIKE TABLE OF csdep_desc,
lt_dep_order LIKE TABLE OF csdep_ord,
lt_dep_source LIKE TABLE OF csdep_sorc,
lt_dep_doc LIKE TABLE OF csdep_doc,
lt_ltx_line LIKE TABLE OF csltx_line,
lt_stpu LIKE TABLE OF stpu_api01,
lt_fsh_bomd TYPE TABLE OF fsh_tt_bomvd_api,
lt_sgt_bomc TYPE TABLE OF sgt_comp_segment_t,
gt_item LIKE TABLE OF stpo_api03 WITH HEADER LINE.
*head data
gs_stko-base_quan = '1'.
gs_stko-base_unit = 'PC'.
gs_stko-bom_status = '01'.
*create bom item data
*gs_item-item_categ = 'L'.
*gs_item-item_no = '0010'.
*gs_item-component = 'TKW_1015'.
*gs_item-comp_qty = '1'.
*gs_item-comp_unit = 'EA'.
*APPEND gs_item.
*
*CALL FUNCTION 'CSAP_MAT_BOM_CREATE'
* EXPORTING
* material = lv_matn
* plant = lv_plant
* bom_usage = lv_usage
* valid_from = lv_date
* i_stko = gs_stko
* IMPORTING
* bom_no = bom_no
* TABLES
* t_stpo = gs_item
* EXCEPTIONS
* error = 1
* OTHERS = 2.
cl_demo_output=>display_data( bom_no ).
*maintain bom data
gt_item-item_categ = 'L'.
*gt_item-item_no = '0030'. "Maintenance may not be added
gt_item-component = 'MZ-PROC-MC-AD-3102'.
gt_item-comp_qty = '1'.
gt_item-comp_unit = 'EA'.
APPEND gt_item.
CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
EXPORTING
material = lv_matn
plant = lv_plant
bom_usage = lv_usage
alternative = lv_stlal
valid_from = lv_date
change_no = lv_aenn
i_stko = gs_stko
fl_commit_and_wait = 'X'
fl_bom_create = 'X'
fl_new_item = 'X'
fl_complete = 'X'
IMPORTING
fl_warning = lv_fl
o_stko = lv_bom
TABLES
t_stpo = gt_item
EXCEPTIONS
error = 1
OTHERS = 2.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。