SAP Function CHANGEDOCUMENT_PREPARE_TABLES - Change document: Edit tables for change document

Parameter Reference Type Length Default Optional Text
CHECK_INDICATOR 0 SPACE X Flag whether tables are to be changed
CHECK_ONLY_LOGFLAGS CDCHECK_LOGFLAGS C 1 SPACE X Control Flag: Check Change Document-Relevant Fields Only
TABLENAME CDPOS-TABNAME C 30 Name of the table structure of the internal tables

Parameter Reference Type Length Text
RESULT 0 Flag whether tables are identical

Parameter Reference Length Optional Text
TABLE_NEW 0 Table contains the changed data
TABLE_OLD 0 Table contains the unchanged data

Exception Text
NAMETAB_ERROR Error when calling NAMETAB_GET
WRONG_STRUCTURE_LENGTH Table line not long enough to set indicator


INCLUDE 'DOCU_HAS_TO_BE_ELABORATED' OBJECT DOKU ID TX
(see also documentation on CHANGEDOCUMENT_OPEN)
This function module checks whether the two transferred tables areidentical. Additionally, a decision can be made via a parameter whetherthe internal tables are to be processed for the multiple case.
When editing, identical lines in TABLE_OLD
and TABLE_NEW are deleted and processing indicators are set for thedifferent lines.
Example call:
DATA: BEGIN OF TAB_OLD OCCURS 20.
INCLUDE STRUCTURE .
DATA: KZ(1) TYPE C.

DATA: END OF TAB_OLD.
DATA: BEGIN OF TAB_NEW OCCURS 20.
INCLUDE STRUCTURE .
DATA: KZ(1) TYPE C.

DATA: END OF TAB_NEW.
DATA: TABNAME LIKE CDHDR-TABNAME,
ERGEBNIS(1) TYPE C.
TABNAME = 'T4711'.


CALL FUNCTION 'CHANGEDOCUMENT_PREPARE_TABLES'
EXPORTING CHECK_INDICATOR = 'X'
TABLENAME = TABNAME
IMPORTING RESULT = ERGEBNIS
TABLES TABLE_OLD = TAB_OLD
TABLE_NEW = TAB_NEW
EXCEPTIONS ...
The flag has one of the following values:
  • "F"

  • TABLE_OLD is different from TABLE_NEW.
    • "T"

    • TABLE_OLD and TABLE_NEW are identical.
      The flag must have one of the following values:
      • "X"

      • Tables are only compared.
        • " " (Space)

        • Tables are compressed and formatted for MULTIPLE_CASE.
          The table structure must be defined in ADIC and have a key whichdoes not contain any packed fields. The key mustalso be the first fields in the table.
          The table structure must begin with the structure specified underTABLENAME and an additional processing flag (TYPE C, length 1).
          The table must be passed sorted by key.
          During compression, identical lines in TABLE_OLD and TABLE_NEW aredeleted and the processing flag set. The following cases aredistinguished:
          • Lines which exist with table key in TABLE_NEW, but not in TABLE_OLD:
          • Processing flag = "I" for INSERT.
            • Lines which exist with table key in TABLE_NEW and in TABLE_OLD, the
            • contents of the TABLENAME structure fields in TABLE_NEW is not the sameas in TABLE_OLD: Processing flag = "U" for UPDATE.
              • Lines which exist with table key in TABLE_NEW and in TABLE_OLD, the
              • contents of the TABLENAME structure fields in TABLE_NEW is the same asin TABLE_OLD: Delete the line in TABLE_NEW, Delete the line inTABLE_OLD.
                The table structure must begin with the structure specified underTABLENAME and an additional processing flag (TYPE C, length 1).
                The table must be passed sorted by the key.
                During compression, lines are deleted in TABLE_OLD and TABLE_NEW andthe processing flag is set. The following cases are distinguished:
                Line exists with table key in TABLE_OLD, but not in TABLE_NEW:Processing flag = "D" for DELETE.
                Line exists with table key in TABLE_OLD and in TABLE_NEW, the contentsof the structure TABLENAME fields is not the same in TABLE_OLD andTABLE_NEW: Processing flag = SPACE.
                Line exist with table key in TABLE_OLD and in TABLE_NEW, the contentsof the structure TABLENAME fields is the same in TABLE_OLD andTABLE_NEW: Delete the line in TABLE_OLD, Delete the line in TABLE_NEW.