Skip to end of metadata
Go to start of metadata

CHANGE DOCUMENT:
This document briefly describes how to create a 'Change Document' for a business object.
Let us start with an example for clear understanding and to know the importance of the 'Change Document'.

  • Consider MM01 transaction, here MATNR is a primary key as well as 'Change Document Object'.
  • Now we try to create a Material in the MM01.
  • Now once we finish creating a material, we can find that a new material has been inserted not only from the MARA table or any other material related table but also from the tables 'CDHDR' or 'CDPOS'.The material we have created in 'CDHDR' table will be something like this.


  • Here since the material number i.e. MATNR is a 'Change Document Object' which we will be seeing shortly, a log has been created in the 'CDHDR' table.
  • We can as well see the 'Deletion' and 'Update' logs also.
  • Thus there is huge significance for 'Change Document' and it can be really helpful for objects which are subject to change. Like MATNR in the above case.
  • In financial accounting 'Change Document' can also be used for Auditing Purpose.
  • If changes are not yet to be made, but are planned, they can be logged as planned changes. A planned date for the changes can be specified.

Structure of the Change Document:
 

Ø       Change Document Header (Object ID)
Ø       Change Document Item (Contains Old and New value of a field and a Change Flag).
Ø       Change Document Number (Issued when the change is logged).


Certain essential features of 'Change Document' have been discussed below:

  1. It is useful for Error analysis.
  2. The object we think is significant enough to have a 'Change Document' should be 'Change Document Object' ,that is it has to be declared as such at  Data Element level itself  by checking the checkbox  beside 'Change Document' .
  3. A change object can be maintained for a single Object or for Multiple Objects. (Ex. MATNR and ERSDA both from the MARA table are Change Document Objects besides others).

Now we will see a detailed step by step processing of Creating Change Document for a Ztable(having multiple 'Change Document Objects') involving a ZReport and a Ztransaction .
The procedure to create a Change Document for a given Object .

  1. Go to transaction SCDO.
     
  2. A screen shown as above is displayed.
  3. Since we are creating a new Change Document
  4. Go to Create.

  5. A pop-up box is displayed where we have to enter a Name Space if required.
  6. The name of the Change Document Object should be given and press 'Continue'.
  7.   Say 'Yes' to proceed further since we have not mentioned any Namespace this has come up.
  8. Then we get this particular screen where we have to enter a table name and check the checkbox 'Copy as internal tab. 'since there are 2 change document objects in table.
  9. Because there are 2 Change Document objects we have to pass them to an internal table or if there is only a single Change Document Object we need not check this checkbox.
  10. Then save it and the screen below appears.
  11. Now say BACK.
  12. The screen below appears we find that the object created by us on the list of objects.
  13.  Place the cursor at our object and Click 'Generate Update Prog.'.
  14. A pop-up box appears as shown below say 'YES'.(This is Because we haven't mentioned  any Name Space).
  15.  A Pop-up box appears now, we have to enter a Include Name , Function group Name and choose the mode of update etc .
  16.  Now say, 'Generate '.
  17. Some very crucial Data is generated here and there are 3 types of Includes and 1 Function Module which are of our prime importance.
  18. The 3 types of include are F_<k4>CDT, F<k4>CDF_ and F<k4>CDV.
  19. The Function Module id created for us 'Objectid_WRITE_DOCUMENT'.
     
  20. Now we have finished creating a Change Document for our Objects .
  21. The Next step is to Call the respective Includes and the Function Module in our program of SE38 editor .
    1         We have to just include a 'F<k4>CDT' in our program because it contains both   the 'CDV and CDF' include in it .(we can check it by Double clicking the include 'CDT' ) .
    2         Now we have to insert entries into our table from the program itself .
         The Code to insert an entry from the program to a table having fields Rollno , Name and Class where Rollno and Name are Change Document Objects is as follows :


Here, We Declared a field string of type our table and then declared a Table (t_cd ) .

Now we are Appending Entries into the table t_cd and then we are Inserting these entries into our ZTable . 
 3         Now we have to Call the Function Module that has been generated in our 'SCDO' transaction .( if sy-subrc = 0 )


 4         All the values in the Function Module has to be filled as above .
5         The fields at the end  XYH1330_CD and YYH1330_CD are for the multiple change document objects we have taken .
6         Now we have to execute the program.

Note : With UPD_<>_CD as 'I', the CDPOS table is created with Insert entry and old and new values are not filled. Old and New values are filled only for U (update) and X<>_CD needs to be filled with new values and Y<>_CD needs to be filled with old values before calling this function module. This creates an entry in CDPOS table with old and new values.

We can see the Change logs in 2 tables 'CDHDR' and 'CDPOS'.
Ø       Go to 'SE11' and go to table 'CDHDR' or 'CDPOS'.
Ø       Enter our Object ID in the respective field and execute.
Ø       Change can be displayed for our insertion.
Ø       Similarly we see the logs for Updating or Deletion also.


This is how the Change Document log looks like in 'CDHDR table. 
 


Thus we can see the changes in these tables.
They also provide us with old value and new value.


  1. Guest

    "Old and New values are filled only for U (update) and X<>_CD needs to be filled with new values and Y<>_CD needs to be filled with old values before calling this function module."

    How do I exactly fill the table with old and new values?

  2. write a select quirey to get the old values from the table..

    Linganna Katigiri 

     

     

  3. How can  move the changes from SCDO transaction (includes, function modules) code to Development, quality and production systems ?

     

    -ysr.