创建独立需求计划:BAPI_REQUIREMENTS_CREATE
修改独立需求计划:BAPI_REQUIREMENTS_CHANGE
DATA: lv_reqmtsplannumber TYPE pbdnr.
DATA: ls_requirements_item TYPE bapisitemr.
DATA: lt_return TYPE STANDARD TABLE OF bapireturn1.
DATA: ls_return TYPE bapireturn1.
DATA: ls_requirement_param TYPE cm60r.
DATA: lt_requirements_schedule_in TYPE STANDARD TABLE OF bapisshdin.
DATA: lt_requirements_schedule_del TYPE STANDARD TABLE OF bapisshdin.
DATA: ls_requirements_schedule_in TYPE bapisshdin.
CLEAR ls_requirements_item.
CLEAR ls_requirement_param.
CLEAR ls_requirements_schedule_in.
CLEAR ls_pbid.
CLEAR lv_reqmtsplannumber.
lv_werks = gs_data-pbdnr+0(4).
lv_berid = gs_data-pbdnr.
"工厂
ls_requirements_item-plant = lv_werks.
"MRP AREA
ls_requirements_item-mrp_area = lv_berid.
"
ls_requirements_item-req_number = gs_data-pbdnr.
"激活
ls_requirements_item-vers_activ = 'X'.
"版本
ls_requirements_item-version = gs_data-versb.
"Material
ls_requirements_item-material = gs_data-matnr.
"日期
ls_requirements_schedule_in-req_date = lv_budat.
"计划周期
ls_requirements_schedule_in-date_type = '1'.
"数量
ls_requirements_schedule_in-req_qty = lv_menge.
APPEND ls_requirements_schedule_in TO lt_requirements_schedule_in.
CALL FUNCTION 'BAPI_REQUIREMENTS_CREATE'
EXPORTING
requirements_item = ls_requirements_item
requirement_param = ls_requirement_param
* DO_COMMIT = 'X'
* UPDATE_MODE = 'X'
* REFER_TYPE = ' '
* PROFILID = ' '
IMPORTING
* MATERIAL =
* PLANT =
* REQUIREMENTSTYPE =
* VERSION =
reqmtsplannumber = lv_reqmtsplannumber
* MRP_AREA =
* MATERIAL_EVG =
* REQ_PLAN_ID_EXT =
* REQ_SEGMENT =
TABLES
requirements_schedule_in = lt_requirements_schedule_in
* REQUIREMENTS_CHAR_IN =
return = lt_return.
CALL FUNCTION 'BAPI_REQUIREMENTS_CHANGE'
EXPORTING
material = lv_matnr
plant = lv_werks
requirementstype = 'LSF'
version = gs_data-versb
reqmtsplannumber = gs_data-pbdnr
vers_activ = 'X'
* REQUIREMENT_PARAM =
mrp_area = lv_berid
do_commit = 'X'
update_mode = 'X'
delete_old = 'X'
* NO_WITHDR = ' '
* MATERIAL_EVG =
* REQ_PLAN_ID_EXT =
* REQ_SEGMENT =
* MATERIAL_LONG =
* REQ_SEG_LONG =
* IMPORTING
* REQUIREMENT_ITEM_OUT =
TABLES
requirements_schedule_in = lt_requirements_schedule_in
* REQUIREMENTS_CHAR_IN =
return = lt_return.
BAPI_REQUIREMENTS_CHANGE 首先会将原有的删除。然后去新建新的