logging using change document

17
Change Documents Business data objects are changed frequently. We recommend that you log these changes for objects that are critical or susceptible to audits. You may find it helpful, and sometimes necessary, to be able to trace or reconstruct such changes later, for example for investigating or auditing purposes. SAP Systems log changes to business data objects in change documents. SAP Systems do not automatically use change documents for business objects. You must activate the process yourself. To activate a change document for an object, perform the following steps: ... Step1: Create a custom table zaudit_t in SE11 or else you can use any custom created table. Step2: First you need to check the change document in all the data elements of the custom created table for which you may need to track the changes and the one which you need the log. Author: Ravi Kiran Katta Page 1 5/12/2022

Upload: kattak2k

Post on 13-Nov-2014

1.416 views

Category:

Documents


2 download

DESCRIPTION

the proccedure provides you to log the changes made in any SAP application.

TRANSCRIPT

Page 1: Logging Using Change Document

Change Documents

Business data objects are changed frequently. We recommend that you log these changes for objects that are critical or susceptible to audits. You may find it helpful, and sometimes necessary, to be able to trace or reconstruct such changes later, for example for investigating or auditing purposes. SAP Systems log changes to business data objects in change documents.

SAP Systems do not automatically use change documents for business objects. You must activate the process yourself.

To activate a change document for an object, perform the following steps:...

Step1: Create a custom table zaudit_t in SE11 or else you can use any custom created table.Step2: First you need to check the change document in all the data elements of the custom created table for which you may need to track the changes and the one which you need the log.

Step3: Go to SCDO t.codeStep4: click on create in application toolbar.

Enter Change doc. object w/o namespace prefix: zaudit_cd in the popup window.

Author: Ravi Kiran Katta Page 1 4/8/2023

Page 2: Logging Using Change Document

Change Documents

Step 5:

Author: Ravi Kiran Katta Page 2 4/8/2023

Page 3: Logging Using Change Document

Change Documents

Step 6: a) Enter the table name under Name of Table for which you would like the have the logs.b) Try avoiding checking copy as internal table this could degrade the performance. c) On Doc. For individual fields at delete checking will provide the log when a record is deleted from the table entries.

Author: Ravi Kiran Katta Page 3 4/8/2023

Page 4: Logging Using Change Document

Change Documents

Step 7: click on Insert entries. Then the screen would look like this.

Author: Ravi Kiran Katta Page 4 4/8/2023

Page 5: Logging Using Change Document

Change Documents

Step 8: Now got to the utilities from the menu bar and select Generate update pgm.

Step 9:

After saying yes to generate. Now a window popups

Author: Ravi Kiran Katta Page 5 4/8/2023

Page 6: Logging Using Change Document

Change Documents

Here we need to enter the Function group name

Step 10: Make the selection depending on the requirement for Processing Type.

Step 11: Now, Click on Generate.

Author: Ravi Kiran Katta Page 6 4/8/2023

Page 7: Logging Using Change Document

Change Documents

Step 12: Now click on save.Then a message popups on the status bar saying …

Step 13: Go back to the main screen of SCDO.

Author: Ravi Kiran Katta Page 7 4/8/2023

Page 8: Logging Using Change Document

Change Documents

Step 14: select our created Object zaudit_cd1 from the main screen of SCDO and click on Generation Info from the application tool bar.

Author: Ravi Kiran Katta Page 8 4/8/2023

Page 9: Logging Using Change Document

Change Documents

Step 15: Here make a note of the function module name which has been generated ZAUDIT_CD1_WRITE_DOCUMENT during the process.

Step 16: Try checking the table CDHDR & CDPOS

This confirms that our object has been generated successfully and this is the end of 1st stage.

Author: Ravi Kiran Katta Page 9 4/8/2023

Page 10: Logging Using Change Document

Change Documents Step 17: Now at this 2nd stage you would be able to check this function module manually using Transaction code SE37 Or else try calling the FM in a program written using SE38 Or else we can also actually call the FM in the EVENTS in TMG.

Step 18: To make you understand, a small test code is written below

*** Types Declaration***types: BEGIN OF X_audit, ------Field of ZAUDIT TABLE OR a custom created table------ END OF X_audit.

*** Data Declaration***

Data: w_newvalues type X_audit, w_oldvalues type X_audit.

DATA: BEGIN OF t_cdtxt OCCURS 0. INCLUDE STRUCTURE cdtxt.DATA: END OF t_cdtxt.

DATA: l_tcode type cdhdr-tcode , l_time type cdhdr-utime, l_usnam type cdhdr-username, l_date type cdhdr-udate.

***Constants*****CONSTANTS : l_objectid TYPE cdhdr-objectid VALUE 'ZAUDIT_CD'.

Initialization.

Clear: l_tcode,l_time, l_usnam, l_date.

Clear: w_newvalues, w_oldvalues.

***Start-Of-Selection***Start-of-selection.

*Populating w_oldvalues workarea with old values from the tableSelect single * from zaudit_t Into w_oldvalues

Where belnr eq belnr_1 And gjahr eq gjahr_1 And bukrs eq bukrs_1. “ where, belnr_1, gjahr_1, bukrs_1 are the fields on selection screen.

* here we are populating w_newvalues workarea with new values---- W_newvalues-f1 = w_oldvalues-f1 -----------f2 = ‘XXXXXXX’ -----------f3 = ‘YYYYYYY’------------f4 = ‘ZZZZZZZ’

l_tcode = sy-tcode.

Author: Ravi Kiran Katta Page 10 4/8/2023

Page 11: Logging Using Change Document

Change Documents l_time = sy-uzeit.l_usnam = sy-uname.l_date = sy-datum.

*** modify the table with new values***MODIFY zaudit_t FROM w_submit.

IF sy-subrc EQ 0. MESSAGE 'Document Updated' TYPE 'S'.

call function 'ZAUDIT_CD1_WRITE_DOCUMENT' exporting objectid = l_objectid tcode = l_tcode utime = l_time udate = l_date username = l_usnam* PLANNED_CHANGE_NUMBER = ' ' object_change_indicator = 'U' “U-update, I-insert, D-delete* PLANNED_OR_REAL_CHANGES = ' '* NO_CHANGE_POINTERS = ' ' upd_icdtxt_zaudit_cd = 'U' n_zaudit_t = w_newvalues “pass the work area containing new values o_zaudit_t = w_oldvalues “pass the work area containing old values upd_zaudit_t = 'U' “ this parameter gives the values in the columns(new value, old value and changed field name) of table CDPOS.

tables icdtxt_zaudit_cd = t_cdtxt

ELSE. MESSAGE 'Document Not Updated' TYPE 'S'.ENDIF. “IF sy-subrc EQ 0.

Step 19: Please Do not worry about the screen below this is a custom created requirement.

Author: Ravi Kiran Katta Page 11 4/8/2023

Page 12: Logging Using Change Document

Change Documents

Here, we select one document using F4 on Document Number.

Author: Ravi Kiran Katta Page 12 4/8/2023

Page 13: Logging Using Change Document

Change Documents

Selecting a Document will populate the values on the screen as shown below

Author: Ravi Kiran Katta Page 13 4/8/2023

Page 14: Logging Using Change Document

Change Documents

Now, Changing the values and clicking the submit button, updates the values in the table.

Author: Ravi Kiran Katta Page 14 4/8/2023

Page 15: Logging Using Change Document

Change Documents

As, you see the Document is updated.

STEP 20: Now we check the table CDPOS & CDHDR to check the updated values.

CDHDR:

Author: Ravi Kiran Katta Page 15 4/8/2023

Page 16: Logging Using Change Document

Change Documents

CDPOS:

Author: Ravi Kiran Katta Page 16 4/8/2023