SAP Function Modules

CHANGEDOCUMENT_READ SAP Function module - Change document: Read and edit change documents







CHANGEDOCUMENT_READ is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name CHANGEDOCUMENT_READ into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: SCD2
Released Date: 22.12.1994
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM CHANGEDOCUMENT_READ - CHANGEDOCUMENT READ





CALL FUNCTION 'CHANGEDOCUMENT_READ' "Change document: Read and edit change documents
  EXPORTING
*   archive_handle = 0          " sy-tabix      Handle on Open Archive Files
*   changenumber = SPACE        " cdpos-changenr  Change document number
*   date_of_change = '00000000'  " cdhdr-udate  From-change date for search
    objectclass =               " cdhdr-objectclas  Object class
*   objectid = SPACE            " cdhdr-objectid  Object ID
*   tablekey = SPACE            " cdpos-tabkey  Object class table key
*   tablename = SPACE           " cdpos-tabname  Object class table name
*   time_of_change = '000000'   " cdhdr-utime   From-change time for search
*   username = SPACE            " cdhdr-username  Last changed by
*   local_time = SPACE          "               local or system time (re: time zone)
*   time_zone = 'UTC'           " ttzz-tzone    If LOCAL_TIME = X: Time zone in which change documents were created
*   tablekey254 = SPACE         " cdpos_uid-tabkey  Table Key for CDPOS in Character 254
*   keyguid = SPACE             " cdpos_uid-keyguid  UUID in character form
*   date_until = '99991231'     " cdhdr-udate   Change date up to which you want to search
*   time_until = '235959'       " cdhdr-utime   Change time up to which you want to search
*   keyguid_str = SPACE         " cdpos_str-keyguid  UUID in Character Format
*   read_changedocu = SPACE     " c             Flag, if != SPACE, read from archive for CHANGEDOCU
  IMPORTING
    et_cdred_str =              " cdred_str_tab  Table Type for Structure CDRED_STR
  TABLES
    editpos =                   " cdred         Table with edited change document items
  EXCEPTIONS
    NO_POSITION_FOUND = 1       "               No item found
    WRONG_ACCESS_TO_ARCHIVE = 2  "              incorrect access to archive
    TIME_ZONE_CONVERSION_ERROR = 3  "           Error converting local to system time
    .  "  CHANGEDOCUMENT_READ

ABAP code example for Function Module CHANGEDOCUMENT_READ





The ABAP code below is a full code listing to execute function module CHANGEDOCUMENT_READ including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_et_cdred_str  TYPE CDRED_STR_TAB ,
it_editpos  TYPE STANDARD TABLE OF CDRED,"TABLES PARAM
wa_editpos  LIKE LINE OF it_editpos .

DATA(ld_archive_handle) = '123 '.

SELECT single CHANGENR
FROM CDPOS
INTO @DATA(ld_changenumber).


SELECT single UDATE
FROM CDHDR
INTO @DATA(ld_date_of_change).


SELECT single OBJECTCLAS
FROM CDHDR
INTO @DATA(ld_objectclass).


SELECT single OBJECTID
FROM CDHDR
INTO @DATA(ld_objectid).


SELECT single TABKEY
FROM CDPOS
INTO @DATA(ld_tablekey).


SELECT single TABNAME
FROM CDPOS
INTO @DATA(ld_tablename).


SELECT single UTIME
FROM CDHDR
INTO @DATA(ld_time_of_change).


SELECT single USERNAME
FROM CDHDR
INTO @DATA(ld_username).

DATA(ld_local_time) = 'some text here'.

SELECT single TZONE
FROM TTZZ
INTO @DATA(ld_time_zone).


SELECT single TABKEY
FROM CDPOS_UID
INTO @DATA(ld_tablekey254).


SELECT single KEYGUID
FROM CDPOS_UID
INTO @DATA(ld_keyguid).


SELECT single UDATE
FROM CDHDR
INTO @DATA(ld_date_until).


SELECT single UTIME
FROM CDHDR
INTO @DATA(ld_time_until).


SELECT single KEYGUID
FROM CDPOS_STR
INTO @DATA(ld_keyguid_str).

DATA(ld_read_changedocu) = '123 '.

"populate fields of struture and append to itab
append wa_editpos to it_editpos. . CALL FUNCTION 'CHANGEDOCUMENT_READ' EXPORTING * archive_handle = ld_archive_handle * changenumber = ld_changenumber * date_of_change = ld_date_of_change objectclass = ld_objectclass * objectid = ld_objectid * tablekey = ld_tablekey * tablename = ld_tablename * time_of_change = ld_time_of_change * username = ld_username * local_time = ld_local_time * time_zone = ld_time_zone * tablekey254 = ld_tablekey254 * keyguid = ld_keyguid * date_until = ld_date_until * time_until = ld_time_until * keyguid_str = ld_keyguid_str * read_changedocu = ld_read_changedocu IMPORTING et_cdred_str = ld_et_cdred_str TABLES editpos = it_editpos EXCEPTIONS NO_POSITION_FOUND = 1 WRONG_ACCESS_TO_ARCHIVE = 2 TIME_ZONE_CONVERSION_ERROR = 3 . " CHANGEDOCUMENT_READ
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_et_cdred_str  TYPE CDRED_STR_TAB ,
ld_archive_handle  TYPE SY-TABIX ,
it_editpos  TYPE STANDARD TABLE OF CDRED ,
wa_editpos  LIKE LINE OF it_editpos,
ld_changenumber  TYPE CDPOS-CHANGENR ,
ld_date_of_change  TYPE CDHDR-UDATE ,
ld_objectclass  TYPE CDHDR-OBJECTCLAS ,
ld_objectid  TYPE CDHDR-OBJECTID ,
ld_tablekey  TYPE CDPOS-TABKEY ,
ld_tablename  TYPE CDPOS-TABNAME ,
ld_time_of_change  TYPE CDHDR-UTIME ,
ld_username  TYPE CDHDR-USERNAME ,
ld_local_time  TYPE STRING ,
ld_time_zone  TYPE TTZZ-TZONE ,
ld_tablekey254  TYPE CDPOS_UID-TABKEY ,
ld_keyguid  TYPE CDPOS_UID-KEYGUID ,
ld_date_until  TYPE CDHDR-UDATE ,
ld_time_until  TYPE CDHDR-UTIME ,
ld_keyguid_str  TYPE CDPOS_STR-KEYGUID ,
ld_read_changedocu  TYPE C .

ld_archive_handle = '123 '.

"populate fields of struture and append to itab
append wa_editpos to it_editpos.

SELECT single CHANGENR
FROM CDPOS
INTO ld_changenumber.


SELECT single UDATE
FROM CDHDR
INTO ld_date_of_change.


SELECT single OBJECTCLAS
FROM CDHDR
INTO ld_objectclass.


SELECT single OBJECTID
FROM CDHDR
INTO ld_objectid.


SELECT single TABKEY
FROM CDPOS
INTO ld_tablekey.


SELECT single TABNAME
FROM CDPOS
INTO ld_tablename.


SELECT single UTIME
FROM CDHDR
INTO ld_time_of_change.


SELECT single USERNAME
FROM CDHDR
INTO ld_username.

ld_local_time = 'some text here'.

SELECT single TZONE
FROM TTZZ
INTO ld_time_zone.


SELECT single TABKEY
FROM CDPOS_UID
INTO ld_tablekey254.


SELECT single KEYGUID
FROM CDPOS_UID
INTO ld_keyguid.


SELECT single UDATE
FROM CDHDR
INTO ld_date_until.


SELECT single UTIME
FROM CDHDR
INTO ld_time_until.


SELECT single KEYGUID
FROM CDPOS_STR
INTO ld_keyguid_str.

ld_read_changedocu = '123 '.

SAP Documentation for FM CHANGEDOCUMENT_READ


This function module reads change document headers and items, and prepares the old and new values in accordance with their type. In some ...See here for full SAP fm documentation

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name CHANGEDOCUMENT_READ or its description.