Wednesday, March 4, 2026

Retrieving the description for the Audit Journal Entry Types

I have, to date, been disappointed that I could not programmatically retrieve a description for the 420 Audit journal entry types. Referring to IBM's documentation was just not practical. A new SQL View in the Fall 2025 Technical Refreshes has given me what I wanted, a list of all the journal entry types with their descriptions.

The View is JOURNAL_CODE_INFO, which is found in the library QSYS2. It contains the following columns:

  1. JOURNAL_CODE:  The journal code
  2. JOURNAL_CODE_DESCRIPTION:  Description of the Journal code
  3. JOURNAL_ENTRY_TYPE:  Journal entry type
  4. JOURNAL_ENTRY_TYPE_DESCRIPTION:  Description for the journal entry type

The journal codes are for a specific "action", while the Journal Entry Type is the type of information. You can see this with the new View with the following statement:

01  SELECT * FROM QSYS2.JOURNAL_CODE_INFO ;

I am only going to show the first few results are there are too many to show here.

                                    JOURNAL
JOURNAL  _                  _ENTRY   JOURNAL_ENTRY_
_CODE     CODE_DESCRIPTION          _TYPE    TYPE_DESCRIPTION
-------   ------------------------- -------  -------------------------
A         System accounting entry   DP       Direct print information
A         System accounting entry   JB       Job accounting segment
A         System accounting entry   SP       Spooled print information
B         Integrated file system    AA       Change audit attribute
B         Integrated file system    AJ       Start of apply

If I wanted to make a list of all the Journal Codes I can do so with the following:

01  SELECT JOURNAL_CODE,
02         ANY_VALUE(JOURNAL_CODE_DESCRIPTION) AS "Description"
03    FROM QSYS2.JOURNAL_CODE_INFO
04   GROUP BY JOURNAL_CODE
05   ORDER BY JOURNAL_CODE ;

Line 2: As I am going to group my results by Journal Code, I use the ANY_VALUE scalar function to add the description column, without needing to add it to the GROUP BY clause.

The above generates the following unique list. As I mentioned before this is just the first few rows of the results.

JOURNAL_CODE   Description
------------   -----------------------------
A              System accounting entry
B              Integrated file system
C              Commitment control operation
D              Database file operation
E              Data area operation

I can do the same for the Journal Entry types:

01  SELECT JOURNAL_ENTRY_TYPE AS "Jrn type",
02         ANY_VALUE(JOURNAL_ENTRY_TYPE_DESCRIPTION) AS "Description"
03    FROM QSYS2.JOURNAL_CODE_INFO
04   GROUP BY JOURNAL_ENTRY_TYPE
05   ORDER BY JOURNAL_ENTRY_TYPE ;

Line 2: As I am using the GROUP BY clause the ANY_VALUE scalar function to include the Journal Entry Type Description.

The first few results from the above are:

Jrn type   Description
--------   --------------------------
AA         Change audit attribute
AC         Add RI constraint
AD         Change auditing attribute
AF         Authority failure
AJ         Start of apply

I can produce a list of the Audit Journal types the Audit journals contain on the server I am working upon using the following:

01  WITH T0 (JTYPE,COUNT) AS
02  (SELECT JOURNAL_ENTRY_TYPE,COUNT(*)
03     FROM TABLE(DISPLAY_JOURNAL('QSYS','QAUDJRN'))
04    GROUP BY JOURNAL_ENTRY_TYPE
05    ORDER BY JOURNAL_ENTRY_TYPE)
 
06  SELECT T0.JTYPE,JOURNAL_ENTRY_TYPE_DESCRIPTION
07    FROM T0,QSYS2.JOURNAL_CODE_INFO
08   WHERE JTYPE = JOURNAL_ENTRY_TYPE
09   ORDER BY T0.JTYPE ;

I have to break this into two parts, using a Common Table Expression, CTE, as I cannot GROUP BY a set of results from a Table expression and join it to a View.

Lines 1 – 5: Here I use the DISPLAY_JOURNAL Table function to get a list of the Journal Entry Types and a count of them.

Lines 6 – 9: This statement takes the results from the CTE Table T0 and joins them with the JOURNAL_CODE_INFO to add the description to the results.

The first few results from the partition I am using look like:

        JOURNAL_ENTRY_
JTYPE   TYPE_DESCRIPTION
-----   -------------------------
AD      Change auditing attribute
AF      Authority failure
AP      Program adopt
CA      Object authority changed
CD      Command string

I entered an IBM Idea for this, so you will not be surprised that I am happy we now have a list of all the Journal Entry Types in a format we can easily use in any SQL expression.

 

You can learn more about the JOURNAL_CODE_INFO SQL View from the IBM website here.

 

This article was written for IBM i 7.6 TR1 and 7.5 TR7.

No comments:

Post a Comment

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.