This post will explain how to Create Sap Change Documents for Custom Table or Field step by step.
- Change Documents Overview
- Technical Overview for Change Documents
- Change Documents?Objects and Tables
- Sap Change Documents for Custom Fields
- Sap Change Documents for Custom Table
Table of Contents
Let’s first have a look on the result, we expect for this change tracking
For example, change in FI Document ( tcode FB03 to display a document and SAP Table BKPF )
To Display Changes on Document, Environment > Document Changes
All the changes are displayed as following with old value and new value for each modified field.
( Change Document tracking manage change on field level )
In order to compare new value and old value, go to All Changes
Technical Overview for Change Documents
Change Documents?Objects and Tables
Technically, the changes on Document are saved in these both tables
CDHDR : Change document header
CDPOS : Change document items
The object class assigned to Business Objects can be customized in tcode SCDO (Display Change Document Objects)
Sap Change Documents for Custom Fields
The Update function module for FI document is BELEG_WRITE_DOCUMENT
Let take for example for zzField on BKPF, object class assigned to FI document should be BELEG
Sample code following can be modified to adjust your requirement.
Or you can call directly the FM BELEG_WRITE_DOCUMENT, don’t forget to run commit work because this function module must run in UPDATE MODE in order to not disturb the main business process.
SELECT SINGLE * FROM BKPF WHERE BUKRS = p_companycode
AND BELNR = p_invoicedocnumber
AND GJAHR = p_fiscalyear.
CHECK SY-SUBRC = 0.
" Old data
*BKPF = BKPF.
" New data
BKPF-zzfield = p_link.
UPD_BKDF = 'X'.
Sap Change Documents for Custom Table
In order to manage change document ( history ) on customize table, a change document object have to be create.
- Create Change document Object (SCDO)
- Assign tables to CDO (SCDO)
- Generate CDO Update Program (SCDO)
- Generate Update Program and *WRITE_DOCUMENT Function
For me information, check the sap help documentation on Create a Change Document Object.