IBMi (AS400) fans only ' Journaling database physical files (tables)



Journaling database physical files is a powerful, built-in OS feature. It allows you to audit data file changes.
Tracks additions, updates, deletions of a physical file.



Let's see how it works.

Scenario: I have a phisical file (Tabel) called CLANA00F, I wont tracks additions, updates and deletions about CLANA00F.



Step 1: CRTJRNRCV create a journal receiver in your library

CRTJRNRCV JRNRCV(VDOTEST1/JRCV) THRESHOLD(1500000) TEXT('My Journal Receiver')
CRTJRNRCV  on IBMi




Step 2: CRTJRN create a journal into the journal receiver
CRTJRN JRN(VDOTEST1/JRNL) JRNRCV(VDOTEST1/JRCV)
CRTJRN  on IBMi


Here is the just created journal receiver and the journal. 
STRPDM  on IBMi




Step 3: STRJRNPF start auditing
STRJRNPF FILE(VDOTEST1/CLANA00F) JRN(VDOTEST1/JRNL) IMAGES(*BOTH) OMTJRNE(*OPNCLO) // the option OMTJRNE(*OPNCLO) omit open and close entries.
// Open and close operations on the specified file members do not create open and close journal entries. It saves some storage space in the attached receivers.                                     
STRJRNPF  on IBMi

                                                       



Since now on, any changes to the CLANA00F file will be recorded in the journal.



Now I show you with a practical example.



I add a new record to CLANA00F
Work with data in a file  on IBMi


Let's see what the journal shows:
DSPJRN JRN(VDOTEST1/JRNL) FILE((VDOTEST1/CLANA00F))

Perform option 5 in each row

DSPJRN  on IBMi

The 3rd row PT - Record added shows and the entry specific data

Display journal entry  on IBMi



I update a record in CLANA00F (I change ITA with FRA)
Let's see what the journal shows:
DSPJRN JRN(VDOTEST1/JRNL) FILE((VDOTEST1/CLANA00F))

DSPJRN  on IBMi



I delete a record in CLANA00F
Let's see what the journal shows:
DSPJRN JRN(VDOTEST1/JRNL) FILE((VDOTEST1/CLANA00F))
DSPJRN  on IBMi



Now let's see the whole history of CLANA00F
Display journal entries  on IBMi
Type . . . . . . . . :   JF - Start journaling for file
Type . . . . . . . . :   JM - Start journaling for member
Type . . . . . . . . :   PT - Record added
Type . . . . . . . . :   UB - Update, before-image
Type . . . . . . . . :   UP - Update, after-image
Type . . . . . . . . :   DL - Record deleted
With option 5 in each row, you can see the entry specific data.




That's it.

I appreciate all the comments made on this blog.

#IBMiSample

Each IBMi user knows they run the most efficient system. All others just have too much money.

Comments

  1. unfortunately ibm does not provide anything serious to investigate the changed data

    ReplyDelete

Post a Comment

Popular posts from this blog

(IBM i fans only) Efficient WRKSPLF with WSF - How to Search string into spooled files, Sort, and Generate PDFs on IBMi

(IBM i fans only) Detecting and Handling Non-Printable Characters in DB2 SQL Using LOCATE() and REPLACE() Functions

(IBM i fans only) How to Sniff User Access