海总牛逼!!!
pr用bapi创建的时候可以改自己想要的bom
DATA: ls_header TYPE bapimereqheader,
ls_headerx TYPE bapimereqheaderx,
lt_return TYPE TABLE OF bapiret2,
lt_item TYPE TABLE OF bapimereqitemimp,
ls_item TYPE bapimereqitemimp,
lt_itemx TYPE TABLE OF bapimereqitemx,
ls_itemx TYPE bapimereqitemx,
lt_bom TYPE TABLE OF bapimereqcomponent,
ls_bom TYPE bapimereqcomponent,
lt_bomx TYPE TABLE OF bapimereqcomponentx,
ls_bomx TYPE bapimereqcomponentx.
DATA: lv_prnumber TYPE banfn.
ls_header-pr_type = ‘ZLC’.
ls_headerx-pr_type = ‘X’.
ls_item-preq_item = ls_itemx-preq_item = ‘00010’.
ls_item-pur_group = ‘204’.
ls_item-material = ls_item-material_external = ‘ATBQ0410-22SVA-1’.
ls_item-plant = ‘2000’.
ls_item-deliv_date = sy-datum.
ls_item-store_loc = ‘2172’.
ls_item-quantity = 10.
ls_item-unit = ‘PCS’.
ls_item-item_cat = ‘L’.
ls_item-bomexpl_no = ‘99999999’.
ls_itemx-pur_group = ‘X’.
ls_itemx-material = ls_itemx-material_external = ‘X’.
ls_itemx-plant = ‘X’.
ls_itemx-deliv_date = ‘X’.
ls_itemx-store_loc = ‘X’.
ls_itemx-quantity = ‘X’.
ls_itemx-unit = ‘X’.
ls_itemx-item_cat = ‘X’.
ls_itemx-bomexpl_no = ‘X’.
APPEND ls_item TO lt_item.
APPEND ls_itemx TO lt_itemx.
CLEAR: ls_item,ls_itemx.
ls_bom-preq_item = ls_bomx-preq_item = ‘00010’.
ls_bom-item_no = ls_bomx-item_no = ‘0001’.
ls_bom-material = ls_bom-material_external = ‘ATBQ0410-11’.
ls_bom-entry_quantity = 20.
ls_bom-entry_uom = ‘PCS’.
ls_bom-plant = ‘2000’.
ls_bom-item_cat = ‘L’.
ls_bom-change_id = ‘R’.
ls_bomx-material = ls_bomx-material_external = ‘X’.
ls_bomx-entry_quantity = ‘X’.
ls_bomx-entry_uom = ‘X’.
ls_bomx-plant = ‘X’.
ls_bomx-item_cat = ‘X’.
ls_bomx-change_id = ‘X’.
APPEND ls_bom TO lt_bom.
APPEND ls_bomx TO lt_bomx.
CLEAR: ls_bom,ls_bomx.
ls_bom-preq_item = ls_bomx-preq_item = ‘00010’.
ls_bom-item_no = ls_bomx-item_no = ‘0002’.
ls_bom-material = ls_bom-material_external = ‘ATBQ0410-11A’.
ls_bom-entry_quantity = 40.
ls_bom-entry_uom = ‘PCS’.
ls_bom-plant = ‘2000’.
ls_bom-item_cat = ‘L’.
ls_bom-change_id = ‘R’.
ls_bomx-material = ls_bomx-material_external = ‘X’.
ls_bomx-entry_quantity = ‘X’.
ls_bomx-entry_uom = ‘X’.
ls_bomx-plant = ‘X’.
ls_bomx-item_cat = ‘X’.
ls_bomx-change_id = ‘X’.
APPEND ls_bom TO lt_bom.
APPEND ls_bomx TO lt_bomx.
CLEAR: ls_bom,ls_bomx.
CALL FUNCTION ‘BAPI_PR_CREATE’
EXPORTING
prheader = ls_header
prheaderx = ls_headerx
IMPORTING
number = lv_prnumber
TABLES
return = lt_return
pritem = lt_item
pritemx = lt_itemx
prcomponents = lt_bom
prcomponentsx = lt_bomx.
READ TABLE lt_return WITH KEY type = ‘E’ TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
ROLLBACK WORK.
ELSE.
COMMIT WORK AND WAIT.
ENDIF.
cl_demo_output=>write( lv_prnumber ).
cl_demo_output=>write( lt_return ).
cl_demo_output=>display( ).