上一篇 调用SAP 采购配额维护 SAP ABAP 采购配额维护-CSDN博客 ME_UPDATE_QUOTA没有写入修改记录里面,使得从修改记录的表数据读取的报表/接口 取不到数据了
参考 https://wenku.baidu.com/view/95052a8ccd22bcd126fff705cc17552707225ea3.html?_wkts_=1709621750543&bdQuery=%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E8%87%B3CDHDR
找到SAP S4 已有的function ZWT_DEBI_WRITE_DOCUMENT
FUNCTION ZWT_DEBI_WRITE_DOCUMENT.
*"----------------------------------------------------------------------
*"*"Verbuchungsfunktionsbaustein:
*"
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(OBJECTID) LIKE CDHDR-OBJECTID
*" VALUE(TCODE) LIKE CDHDR-TCODE
*" VALUE(UTIME) LIKE CDHDR-UTIME
*" VALUE(UDATE) LIKE CDHDR-UDATE
*" VALUE(USERNAME) LIKE CDHDR-USERNAME
*" VALUE(PLANNED_CHANGE_NUMBER) LIKE CDHDR-PLANCHNGNR
*" DEFAULT SPACE
*" VALUE(OBJECT_CHANGE_INDICATOR) LIKE CDHDR-CHANGE_IND
*" DEFAULT 'U'
*" VALUE(PLANNED_OR_REAL_CHANGES) LIKE CDHDR-CHANGE_IND
*" DEFAULT SPACE
*" VALUE(NO_CHANGE_POINTERS) LIKE CDHDR-CHANGE_IND
*" DEFAULT SPACE
*" VALUE(N_KNA1) LIKE KNA1 STRUCTURE KNA1
*" VALUE(O_YKNA1) LIKE KNA1 STRUCTURE KNA1
*" VALUE(N_KNB1) LIKE KNB1 STRUCTURE KNB1
*" VALUE(O_YKNB1) LIKE KNB1 STRUCTURE KNB1
*" VALUE(UPD_KNA1) LIKE CDPOS-CHNGIND DEFAULT SPACE
*" VALUE(UPD_KNB1) LIKE CDPOS-CHNGIND DEFAULT SPACE
*" VALUE(UPD_KNBK) LIKE CDPOS-CHNGIND DEFAULT SPACE
*" TABLES
*" XKNBK STRUCTURE FKNBK
*" YKNBK STRUCTURE FKNBK
*"----------------------------------------------------------------------CALL FUNCTION 'CHANGEDOCUMENT_OPEN'EXPORTING OBJECTCLASS = 'DEBI 'OBJECTID = OBJECTIDPLANNED_CHANGE_NUMBER = PLANNED_CHANGE_NUMBERPLANNED_OR_REAL_CHANGES = PLANNED_OR_REAL_CHANGESEXCEPTIONS SEQUENCE_INVALID = 1OTHERS = 2.CASE SY-SUBRC.WHEN 1. MESSAGE A001(F2) WITH 'SEQUENCE INVALID'.WHEN 2. MESSAGE A001(F2) WITH 'OPEN ERROR'.
ENDCASE.* KNA1
IF UPD_KNA1 NE SPACE.CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'EXPORTING TABLENAME = 'KNA1 'WORKAREA_OLD = O_YKNA1WORKAREA_NEW = N_KNA1CHANGE_INDICATOR = UPD_KNA1DOCU_DELETE = 'X'EXCEPTIONS NAMETAB_ERROR = 1OPEN_MISSING = 2POSITION_INSERT_FAILED = 3OTHERS = 4.CASE SY-SUBRC.WHEN 1. MESSAGE A001(F2) WITH 'NAMETAB-ERROR'.WHEN 2. MESSAGE A001(F2) WITH 'OPEN MISSING'.WHEN 3. MESSAGE A001(F2) WITH 'INSERT ERROR'.WHEN 4. MESSAGE A001(F2) WITH 'SINGLE ERROR'.ENDCASE.
ENDIF.* KNB1
IF UPD_KNB1 NE SPACE.CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'EXPORTING TABLENAME = 'KNB1 'WORKAREA_OLD = O_YKNB1WORKAREA_NEW = N_KNB1CHANGE_INDICATOR = UPD_KNB1DOCU_DELETE = 'X'EXCEPTIONS NAMETAB_ERROR = 1OPEN_MISSING = 2POSITION_INSERT_FAILED = 3OTHERS = 4.CASE SY-SUBRC.WHEN 1. MESSAGE A001(F2) WITH 'NAMETAB-ERROR'.WHEN 2. MESSAGE A001(F2) WITH 'OPEN MISSING'.WHEN 3. MESSAGE A001(F2) WITH 'INSERT ERROR'.WHEN 4. MESSAGE A001(F2) WITH 'SINGLE ERROR'.ENDCASE.
ENDIF.* KNBK
IF UPD_KNBK NE SPACE.CALL FUNCTION 'CHANGEDOCUMENT_MULTIPLE_CASE'EXPORTING TABLENAME = 'KNBK 'CHANGE_INDICATOR = UPD_KNBKDOCU_DELETE = 'X'TABLES TABLE_OLD = YKNBKTABLE_NEW = XKNBKEXCEPTIONS NAMETAB_ERROR = 1OPEN_MISSING = 2POSITION_INSERT_FAILED = 3OTHERS = 4.CASE SY-SUBRC.WHEN 1. MESSAGE A001(F2) WITH 'NAMETAB-ERROR'.WHEN 2. MESSAGE A001(F2) WITH 'OPEN MISSING'.WHEN 3. MESSAGE A001(F2) WITH 'INSERT ERROR'.WHEN 4. MESSAGE A001(F2) WITH 'MULTIPLE ERROR'.ENDCASE.
ENDIF.CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'EXPORTING OBJECTCLASS = 'DEBI 'OBJECTID = OBJECTIDDATE_OF_CHANGE = UDATETIME_OF_CHANGE = UTIMETCODE = TCODEUSERNAME = USERNAME
OBJECT_CHANGE_INDICATOR = OBJECT_CHANGE_INDICATOR
NO_CHANGE_POINTERS = NO_CHANGE_POINTERSEXCEPTIONS HEADER_INSERT_FAILED = 1OBJECT_INVALID = 2OPEN_MISSING = 3NO_POSITION_INSERTED = 4OTHERS = 5.CASE SY-SUBRC.WHEN 1. MESSAGE A001(F2) WITH 'INSERT HEADER FAILED'.WHEN 2. MESSAGE A001(F2) WITH 'OBJECT INVALID'.WHEN 3. MESSAGE A001(F2) WITH 'OPEN MISSING'.WHEN 5. MESSAGE A001(F2) WITH 'CLOSE ERROR'.
ENDCASE.ENDFUNCTION.
底层无非4个function
1、CHANGEDOCUMENT_OPEN 开启 / 初始化
2、CHANGEDOCUMENT_SINGLE_CASE 单个
3、CHANGEDOCUMENT_MULTIPLE_CASE 批量
4、CHANGEDOCUMENT_CLOSE 关闭