调用CCAP_ECN_CREATE实现该功能。
REPORT ZTEST.
"if sy-datum = '20160110'.
" update tadir set srcsystem = 'DEV' where srcsystem = 'DV1'.
"commit work.
"endif.
DATA: LS_CHANGE_HEADER TYPE AENR_API01.
DATA: LS_RETURN_MSG TYPE BAPIRET2.
DATA: LS_OBJECT_BOM_MAT TYPE AENV_API01..
DATA: LS_OBJECT_BOM_psp TYPE AENV_API01..
DATA: LS_OBJECT_DOC TYPE AENV_API01.
DATA: LV_MATERIAL TYPE MATNR.
DATA: LV_CHANGE_NO TYPE AENNR.
DATA: LT_OBJMGREC TYPE STANDARD TABLE OF AEOI_API01.
DATA: LS_OBJMGREC TYPE AEOI_API01.
DATA: LT_EFFECTIVITY TYPE STANDARD TABLE OF AEEF_API01.
DATA: LS_EFFECTIVITY TYPE AEEF_API01.
*
LS_CHANGE_HEADER-CHANGE_NO = 'A-4008057012'. "eco编号
LS_CHANGE_HEADER-STATUS = '01'."激活的
* ls_change_header-function = '1'."有释放码
LS_CHANGE_HEADER-REASON_CHG = 'ljcTest' . "更改原因
LS_CHANGE_HEADER-DESCRIPT = '刘金才测试'. "更改号描述
LS_CHANGE_HEADER-VALID_FROM = sy-datum. "有并行起始日期
LS_OBJECT_BOM_MAT-ACTIVE = 'X'.
LS_OBJECT_BOM_MAT-OBJ_REQU = 'X'.
LS_OBJECT_BOM_MAT-MGTREC_GEN = 'X'.
LS_OBJECT_BOM_MAT-GEN_NEW = 'X'.
CLEAR LS_OBJMGREC.
LS_OBJMGREC-BOM_USAGE = '1'. "BOM 用途
LS_OBJMGREC-MATERIAL = '000000000000001223'.
LS_OBJMGREC-PLANT = '2000'.
LS_OBJMGREC-PSP_ELEMENT = 'A-1005-D-001'.
LS_OBJMGREC-BOM_CAT = 'P'.
LS_OBJMGREC-CHG_OBJTYP = '1'. "工程更改管理对象\
LS_OBJMGREC-DESCR_OBJ = 'LIUJINCAI '.
INSERT LS_OBJMGREC INTO TABLE LT_OBJMGREC.
CALL FUNCTION 'CCAP_ECN_CREATE'
EXPORTING
CHANGE_HEADER = LS_CHANGE_HEADER
OBJECT_BOM = LS_OBJECT_BOM_MAT
OBJECT_BOM_MAT = LS_OBJECT_BOM_MAT
OBJECT_BOM_PSP = LS_OBJECT_BOM_MAT
FL_COMMIT_AND_WAIT = 'X'
IMPORTING
CHANGE_NO = LV_CHANGE_NO
TABLES
OBJMGREC = LT_OBJMGREC
EFFECTIVITY = LT_EFFECTIVITY
EXCEPTIONS
CHANGE_NO_ALREADY_EXISTS = 1
ERROR = 2
OTHERS = 3
.
IF SY-SUBRC = 0.
WRITE 'ok'.
ELSE.
WRITE SY-SUBRC.
ENDIF.
标签:OBJMGREC,WBS,更改,OBJECT,LS,TYPE,CHANGE,BOM
From: https://blog.51cto.com/u_8215601/7508967