Skip to main content
ABAP_Code_Snippets

Change log for Z-Table Maintenance (via SCDO)

Generally we don’t need table logging for custom table maintenance (SM30), but it is important and needed for some cases. All customizing tables are automatically recorded by default but if you use regular Application tables (master and transaction data), you’re about to get your hands dirty .)

Z-Table
Sample Z-Table

Automatic table change logging

Actually this is not suitable for our case because we want to log particular tables but it’s good to know..

You can use Automatic table change logging by setting the “Log Data Changes” flag under the table “Technical Settings” in SE11 (p.s. You must activate the table again after saving it, otherwise it will not be effective).

Next, to be able to log the table changes you must activate the system profile parameter Rec/Client. The default setting is OFF (no changes are logged). BASIS Team can assist you in this.
 Setting Rec/Client Parameter for Logging

Parameter value Meaning
rec/client = off Table change logging inactive
rec/client = all Table change logging active in all clients (*)
rec/client = <client 1>… Table change logging active in specified clients

(*) This can seriously affect the system performance in a bad way. SAP recommends not to use the value All.

In a nutshell, SAP recommends this option only in systems where this is worthwhile, because all tables with “Log data changes” option will be logged, so this has a major impact on performance (Even for one client)

You can now view the changes via transaction SCU3 (Table: DBTABLOG)

SCU3-Logs
SCU3-Logs

Logging using Change Document Objects (SCDO)

To log changes for particular tables in SM30 Maintenance, we can use change document objects and its associated functions.

Let’s do it step by step;

  1. Go to SCDO and create a Change Document Object (Choose Yes for opening Namespace Pop-ups)
    SCDO-Create
  2. Insert the entries and choose Utilities → Generate update pgm.
    SCDO-Insert Entries
  3. In the opening pop-up, give function group name (it will be created if it doesn’t exist) and generate the update program for the object by clicking Activate.SCDO-Generated
  4. In the Data Element → Further Characteristics Tab, set the “Change Document” flag for the objects which you want to track changes. As you recognise, many SAP standard data elements come with the selected flag.
  5. You can now insert appropriate calls in the corresponding programs, for our example we will use Table Maintenance Events.
  6. Under the table maintenance (SE56) go to Environment → Modification → Events.
    Give the events & subroutine names as shown in the figure and click the Editor icon to create suggested include (L<fg_name>F01).
    SM30-Events

Now, you can just copy and paste the code snippet (link is below) into the created include. It will begin to create logs in CDHDR-CDPOS tables.

SCDO-Logs
SCDO-Logs ( Reports: CHANGEDOCU_READ & RSSCD100 )

Source code:  SM30-SCDO Log

(Fork me on GitHub if you want to contribute)

SCN Blog

 

P.S. For suggestions or reviews pls. contact.

 

Zafer Onbaş

SAP ABAP/Fiori/UI5 Consultant & UI Developer

8 thoughts to “Change log for Z-Table Maintenance (via SCDO)”

  1. will it generate entries for table BDCP2? Can you please provide more details if we need to trigger change pointers for BDCP2 for custom message type.

  2. Hi, How to update the Change Document , if we modify table thru Badi or report. Could you please provide Sample Code.

    1. Hi, sure you can use the generated update function modules wherever you want (e.g. Custom program, enhancement etc.) using the information in Step 3 – SS.

  3. i have probleme with the case action
    When ‘U’
    i haven’t change pointer in table cdhdr

    i have just insert et delete but norhing in U

  4. I have inserted entry from sm30 using event 05, but the change log got updated 2 times in CDPOS and CDHDR table what is the reason can any help.

  5. Hello Zafer ,
    Scenario : I am trying to edit entries of a view using the ztcode . And maintained the above steps 1- 6 on main table and also added the code in the before and after save events for the table . But I dont see the control going to before save inspite of using break points whereas control goes to after save event when saved. Secondly though cdhdr has the entries of the records being changed , but in cdpos there are no details showing what was changed.
    Even the reports dont show the old and new values for the changed records.
    Regards,
    Nidhi

Leave a Reply to Thiiago Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.