Scenario: Creating Sap Change Document Object and using it in the program to log the field changes in the standard data base tables: CDHDR & CDPOS.
Step1. Create a DB table and let’s say for certain field value change we need to track the previous value and the new value in the standard table CDHDR & CDPOS. In this case suppose want to keep the track of the material status change by the help of the filed ‘MAT_STATUS’.
Step2. Go to the data element of the field MAT_STATUS. In the Further Char tab, check the Change Document check box.
Step3. Go to the domain.
Step4. Here we have 3 allowed values for the field. This is not related to change document track. just for our test purpose we have restricted to certain values only.
Step5. Create some material records.
Step6. Now to create the Change Document Object, go to the Tcode- SCDO.
Step7. Click on the Create button.
Step8. Provide a change document object name and click the continue button.
Step10. Provide a description and the Table name which is created above. Then click on insert Entries button.
Step11. The below screen will appear.
Step12. From the Utilities Menu go to Generate Update Pgm.
Step13. Continue with Yes.
Step14. The e,ow pop up appears, Provide the include name, function group name and a name space ‘Z’ for the function module. At last click on Generate button.
Step15. The below details are automatically created for our change Document Object ‘ZMAT_STATUS_TRK’. The important is the Update function module which will be used later to store the changed value in the CDHDR and CDPOS table. Go back.
Step16. Later any point You can come to the Tcode- SCDO and select the Change document object and click on the button Generate Info.
Step17. U can get the all required Info.
Step18. Create a report and call the Change document Object function module. In the code, in the Update part we are calling the Change document Object FM and passing the values before and after. That is Old value and new value.
Step19. Screen flow logic.
Step20. Screen Fileds.
Step21. Screen buttons with ok code.
Step22. Lets execute the report. The below screen comes up.
Step23. Provide a material number and click on the Read button.
Step24. The appropriate data is filled in the respective fields. Lets change the Status value and hit the Update button.
Step25. Change the Status value to R and Click on the Update button.
Step26. The message appears and the DB table is updated.
Step27. Lets go to the CDHDR table and provide the Change Document Object name ans F8.
Step28. The records u will find here.
Step29. Go to CDPOS table and provide the Change Document Object Name and Hit F8.
Step30. The changed value of that particular field is logged here. The Old value and New Value.
How to see old and new values when an existing row in the database table is deleted or a new row was inserted?
These is a standard report CHANGEDOCU_READ could help, but SAP not assign any t-code to it.