Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Change log table

Former Member
0 Likes
12,188

CDHDR and CDPOS are the tables which are used to log the changes which are happeneing, for eg it stored the transaction code, user, objectid, object name, description of the changes which has happened.

if i made a change to a sales order, and the information gets stored in these tables,

How long will these information be available.

Can u retreive changes which were done 2 years ago?

where are these tables stored, on what server? what kind of table it is and whats the mechanism in which data gets stored into these tables?

as far as i have tried out it works for sales orders. i mean it works if i change a sales order and then if i look into the entries of the tables cdhdr and cdpos, they have information about the changes which i have made. but i guess, the Gurus who are working in systems which have 2 or 3 yr old data can tell me if these tables will hold two years old data etc

thanks in advance

awaiting reply

Sriram

5 REPLIES 5
Read only

Former Member
0 Likes
9,199

Hi sriram,

"CHANGE DOCUMENTS" in SAP Terminology

1 The same thing which u are asking

we had developed here. For Eg : Any change

in the material master will be detected

and a mail will be sent to the concerned

employee.

THIS WILL ALSO DETECT WHICH FILEDS HAVE CHANGED.

IT CAN ALSO GIVE, The Old Value, And The New Value.

2. This Mechanism is called CHANGE DOCUMENTS in

SAP Terminology

3. 2 Fuction Modules are Required.

(They will fetch necessary data from CDHDR,CDPOS)

CHANGEDOCUMENT_READ_HEADERS

CHANGEDOCUMENT_READ_POSITIONS

4. The First FM gives list of all

records ( with change no) which have changed.

5. Loop at the above and the second FM will

provide the details (old-val, new-val) for

each record.

6. While using 1st Fm, i used docclass as 'MATERIAL'.

BCOS

the concept of change documents is applicable

to other type of documents also (depends upon

customization)

regards,

amit m.

Read only

Former Member
0 Likes
9,199

i will try this out.

information was useful

it would be nice if amit copuld share the sequential and logical approach to the object. change of material and sending it to email

thanks a lot amit

Sriram

Read only

0 Likes
9,199

Hi again,

1. In your case there would be se38

program to detect the sales order change.

2. VERKBELEG this is the name of the change document,

which u would pass in the first FM.

3. There will also be a date parameter, in the FM,

which will specify,

WHICH DATE ONWARDS, the change documents are required.

regards,

amit m.

Read only

Former Member
0 Likes
9,199

Hi,

You can check the program RSVTPROT - Evaluation of Change logs.

To add to What Amit has mentioned you can use the FM similar to this mentioned below.

    LOOP AT SO_VBELN.
      REFRESH ITAB_CDHDR.
      DATE_FROM = S_CHADT-LOW.
      DATE_UNTIL = S_CHADT-HIGH.
      CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
        EXPORTING
          DATE_OF_CHANGE             = DATE_FROM
          OBJECTCLASS                = 'VERKBELEG'
          OBJECTID                   = SO_VBELN-VBELN
          TIME_OF_CHANGE             = TIME_UNTIL
          DATE_UNTIL                 = DATE_UNTIL
          USERNAME                   = ' '
        TABLES
          I_CDHDR                    = ITAB_CDHDR
        EXCEPTIONS
          NO_POSITION_FOUND          = 1
          WRONG_ACCESS_TO_ARCHIVE    = 2
          TIME_ZONE_CONVERSION_ERROR = 3
          OTHERS                     = 4.
      IF SY-SUBRC NE 0.
        CONTINUE.
      ENDIF.
      LOOP AT ITAB_CDHDR WHERE USERNAME IN S_CHABY.
        REFRESH IT_CDSHW.
        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
          EXPORTING
            CHANGENUMBER            = ITAB_CDHDR-CHANGENR
          TABLES
            EDITPOS                 = IT_CDSHW
          EXCEPTIONS
            NO_POSITION_FOUND       = 1
            WRONG_ACCESS_TO_ARCHIVE = 2
            OTHERS                  = 3.
        IF SY-SUBRC EQ 0.
          PERFORM GET_ACTION .
        ENDIF.
      ENDLOOP.
    ENDLOOP.
  ENDIF.

Cheers

VJ

Read only

Former Member
0 Likes
9,199

Hi again,

1. Instead of calling TWO Fm,

we can also do in

JUST ONE SINGLE FM.

2. For Material,

just copy paste in new program.

3. Then see the internal table CDRED,

in debugging,

it will contain some records.

(after the FM call)

4.

report abc.

data : obj type CDOBJECTCL_RANGE_TAB.

data : objWA type LINE OF CDOBJECTCL_RANGE_TAB.

data : CDRED like table of CDRED with header line.

*----


objWA-SIGN = 'I'.

OBJWA-OPTION = 'EQ'.

objWA-LOW = 'MATERIAL'.

APPEND OBJWA TO OBJ.

CALL FUNCTION 'CHANGEDOCUMENT_READ_RANGES'

EXPORTING

  • ARCHIVE_HANDLE = 0

  • CHANGENUMBER_TAB =

DATE_OF_CHANGE = '20060601'

OBJECTCLASS_TAB = obj

  • OBJECTID_TAB =

  • TABLEKEY_TAB =

  • TABLENAME_TAB =

  • TIME_OF_CHANGE = '000000'

  • USERNAME_TAB =

  • LOCAL_TIME = ' '

  • TABLEKEY254_TAB =

  • KEYGUID_TAB =

  • DATE_UNTIL = '99991231'

  • TIME_UNTIL = '235959'

TABLES

EDITPOS = CDRED

  • 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.

BREAK-POINT.

5. You can change DATE_OF_CHANGE

as per your requirement.

You can also change the document

type to VERKBELEG (instead of MATERIAL)

regards,

amit m.