List of tables that leave traces in CDHDR and CDPOS tables

8.5k views Asked by At

I want to capture changes for all possible SAP tables.

I figured out that CDHDR and CDPOS tables capture change documents but it's not clear for which all tables it does that.

I have multiple questions to ask:

  1. Get list of all tables for which CDHDR and CDPOS tables capture change documents.
  2. As CDPOS table only contains changed field and I need to map it with Primary Key of the table. How can I map changed record with primary key of a table?
2

There are 2 answers

3
AecorSoft On

To purely answer your question, I certainly can tell you to look into the t-code SCDO to get the clue on what you need, but I would choose to challenge your reasoning approach. So, you have a requirement to capture changes for all possible SAP tables. For what purpose? There are thousands of SAP tables being tracked by CDHDR and CDPOS, and most tables there do not bring immediate business values to you. Whenever a table column has a data element like BELNR_D and GJAHR, it could appear in CDHDR, because such element is marked as "Change Document" flag (t-code SE11): enter image description here

And SAP's explanation to the flag is:

The flag for change documents specifies whether changes to fields in database tables defined with reference to this data element are logged when change document objects are involved.

Therefore, with thousands of tables being tracked, it would not be a good idea to solve the problem purely from technical aspect, and we have not even started looking into the performance problem with CDHDR and CDPOS yet.

If your requirement is part of a data warehousing project, then without the hassle of dealing with CDPOS and CDHDR, you can analyze the incremental insertion, deletion and update through the transparent tables or standard extractors. If you can use DB trigger, then SLT could also be an option to get the changed records on the tables you are interested in at almost real-time (5-second delay by default setting).

To summarize, to get to what you need, you can navigate to SAP Menu - Tools - ABAP Workbench - Other Tools - Change Document, or simply the t-code SCDO. However, my comment above on the business requirement is what I really intend to express.

2
Sandra Rossi On

Why not running SELECT DISTINCT tabname FROM cdpos to get the actual list of all tables? I guess it should be sufficient because your SAP system has been live for a while. If you can't do it yourself, ask someone, once for all.

In the table CDPOS, you get the ID of the object changed from the column TABKEY. If the primary key is made of several columns, TABKEY is the concatenation of the character values, with the alignment based on each column size. I'm not sure, but I guess that the primary key columns (of tables referred by TABNAME of CDPOS) always have character types.

The columns of the primary key of one table can be extracted from the ABAP Dictionary with this SQL query: SELECT fieldname, leng FROM dd03l WHERE tabname = 'one_table' AND fieldname LIKE '.%' AND keyflag = 'X' ORDER BY position (column names starting with a dot are for internal stuff).