效果如下:
源代码:
*&---------------------------------------------------------------------*
*& Report ZCYCLE054
*&---------------------------------------------------------------------*
*&批量CC01
*&---------------------------------------------------------------------*
REPORT zcycle054.
DATA: lt_item TYPE TABLE OF aeoi_api01,
ls_header TYPE aenr_api01,
ls_object_mat TYPE aenv_api01, "物料
ls_object_bom TYPE aenv_api01, "BOM
ls_item TYPE aeoi_api01.
DATA: lv_change_no TYPE aenrb-aennr.
"表头
ls_header-change_no = 'ECN-TEST4'.
ls_header-status = '01'.
ls_header-valid_from = sy-datum.
ls_header-descript = 'CYCLE TEST'.
ls_header-reason_chg = 'CYCLE TEST'.
"------------------物料start---------------------
"物件类型
ls_object_mat-active = 'X'.
ls_object_mat-obj_requ = 'X'.
"ls_object_mat-mgtrec_gen = 'X'.
"ls_object_mat-gen_new = 'X'.
"物件
ls_item-material = '11-I06A000-00004'.
ls_item-chg_objtyp = '4'. "物料
ls_item-plant = '1001'.
APPEND ls_item TO lt_item.
CLEAR ls_item.
"------------------物料end---------------------
"------------------BOM START-------------------
ls_object_bom-active = 'X'.
ls_object_bom-obj_requ = 'X'.
"ls_object_bom-mgtrec_gen = 'X'.
ls_item-material = '11-I06A000-00004'.
ls_item-chg_objtyp = '1'. "BOM
ls_item-plant = '1001'.
ls_item-bom_usage = '1'. "BOM 用途
ls_item-bom_cat = 'M'. "BOM 类别
APPEND ls_item TO lt_item.
CLEAR ls_item.
"------------------BOM END-------------------
APPEND ls_item TO lt_item.
CLEAR ls_item.
CALL FUNCTION 'CCAP_ECN_CREATE'
EXPORTING
change_header = ls_header
object_mat = ls_object_mat
object_bom = ls_object_bom
IMPORTING
change_no = lv_change_no
TABLES
* ALT_DATES =
objmgrec = lt_item
* EFFECTIVITY =
* TEXTHEADER =
* TEXTLINES =
EXCEPTIONS
change_no_already_exists = 1
error = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE: 'ECN变更号建立失败'.
ELSE.
WRITE: 'ECN变更号建立成功,单号为' && lv_change_no.
ENDIF.
说明:物件的参数CHG_OBJTYP(工程更改管理物件)的值来源表TCC01