效果:
代码:
*&---------------------------------------------------------------------* *& Report ZPPRTEST4 *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT ZPPRTEST4. DATA: ls_requ TYPE coxt_s_quantity, ls_storage TYPE coxt_s_storage_location, ls_storagex TYPE coxt_s_storage_locationx, ls_return TYPE coxt_bapireturn, lt_return TYPE coxt_t_bapireturn, l_msg(100) TYPE c. TYPES: BEGIN OF ts_resb_bt. INCLUDE TYPE resbb. TYPES: indold LIKE sy-tabix, no_req_upd LIKE sy-datar, END OF ts_resb_bt. TYPES: tt_resb_bt TYPE TABLE OF ts_resb_bt. FIELD-SYMBOLS: <lt_resb_bt> TYPE tt_resb_bt, <ls_resb_bt> TYPE ts_resb_bt. ls_requ-quantity = 228. ls_requ-uom = 'PCS'. ls_storage-werks = '2000'. ls_storage-lgort = '2101'. ls_storagex-werks = 'X'. ls_storagex-lgort = 'X'. CALL FUNCTION 'CO_XT_COMPONENT_ADD' EXPORTING is_order_key = '000020030749' "生产订单 i_material = 'CTXB0056-S2V-1' "子件 is_requ_quan = ls_requ "子件需求数量和单位 i_operation = '00000007' "工艺工序节点计数器 is_storage_location = ls_storage "工厂和仓库 is_storage_locationx = ls_storagex i_postp = 'L' "项目种类 i_posno = '000000' "BOM项目计数器 IMPORTING es_bapireturn = ls_return. ASSIGN ('(SAPLCOBC)RESB_BT[]') TO <lt_resb_bt>. LOOP AT <lt_resb_bt> ASSIGNING <ls_resb_bt>. <ls_resb_bt>-posnr = '0020'. "组件项目编号 ENDLOOP. IF ls_return-type NE 'E'. CALL FUNCTION 'CO_XT_ORDER_PREPARE_COMMIT' TABLES et_bapireturn = lt_return. IF sy-subrc = 0. COMMIT WORK AND WAIT. l_msg = '添加成功'. cl_demo_output=>write( l_msg ). ELSE. cl_demo_output=>write( lt_return ). ENDIF. ELSE. cl_demo_output=>write( ls_return ). ENDIF. cl_demo_output=>display( ).