SAP歷史更改記錄函式

TolyHuang發表於2007-06-09

SAP中很多地方對資料的操作都會有儲存更改歷史記錄,可能過以下兩個函式取得更改歷史記錄:

[@more@]

取得記錄表頭函式
call function 'CHANGEDOCUMENT_READ_HEADERS'
exporting
* ARCHIVE_HANDLE = 0
* DATE_OF_CHANGE = '00000000'
objectclass =
* OBJECTID = ' '
* TIME_OF_CHANGE = '000000'
* USERNAME = SY-UNAME
* LOCAL_TIME = ' '
* DATE_UNTIL = '99991231'
* TIME_UNTIL = '235959'
* NOPLUS_ASWILDCARD_INOBJID = ' '
tables
i_cdhdr =
* EXCEPTIONS
* NO_POSITION_FOUND = 1
* WRONG_ACCESS_TO_ARCHIVE = 2
* TIME_ZONE_CONVERSION_ERROR = 3
* OTHERS = 4
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

其中objectclass是指定要檢視什麼資料的歷史記錄,如檢視BOM的更改記錄, objectclas = 'STUE'

取得更改記錄明細函式
call function 'CHANGEDOCUMENT_READ_POSITIONS'
exporting
* ARCHIVE_HANDLE = 0
changenumber =
* TABLEKEY = ' '
* TABLENAME = ' '
* TABLEKEY254 = ' '
* KEYGUID = ' '
* KEYGUID_STR = ' '
* IMPORTING
* HEADER =
* ET_CDRED_STR =
* TABLES
* EDITPOS =
* EDITPOS_WITH_HEADER =
* EXCEPTIONS
* NO_POSITION_FOUND = 1
* WRONG_ACCESS_TO_ARCHIVE = 2
* OTHERS = 3
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

其中changenumber可從標頭檔案中反回的資料表中取得

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-918271/,如需轉載,請註明出處,否則將追究法律責任。

相關文章