To journal a file in AS/400 (IBM i), you must first create a dedicated journal object, then attach that journal to the target physical file using the STRJRNPF command. This process ensures that every change made to the file’s records is captured for recovery and auditing purposes. You will need specific authority levels to perform these actions on your system.
This method fits when you need to protect critical business data from accidental deletion or corruption, or when compliance requires a historical record of all database modifications. It is essential for files that hold financial transactions, inventory counts, or customer records where data integrity is non-negotiable. Without journaling, a single erroneous update can permanently alter or erase information without a traceable path to restore it.
Prerequisites and Authority Checklist
Before you begin attaching a journal, ensure you have the necessary permissions and resources ready. Journaling is a system-level operation that impacts performance and storage, so preparation is key.
- Journal Object: A physical file named
*JRNmust exist in a library. If none exists, you must create one first. - Journal Receiver: The journal needs space to store data. Ensure the receiver file has sufficient disk space; typically, allocate at least 10-50 MB per day depending on transaction volume.
- Authority Levels: You need
*OBJMGT(Object Management) authority on the file being journaled and*ALL(All) authority on the journal object itself. - System Value Check: Verify that the system value
QJRNPGMQRYallows the query required to monitor the journal if you plan to use monitoring tools later.
If you lack any of these items, pause and consult your IBM i administrator. Attempting to start journaling without proper authority will result in an error message that halts the process immediately.
Step-by-Step: Creating the Journal Object
You cannot attach a journal to a file until the journal object exists. Follow these steps to create a standard journal object in your work library.
- Open a Command Line Interface: Navigate to the main menu and select option 16 (Run Command) or open a green-screen session (5250 emulator).
- Create the Journal: Enter the command
CRTPJRN PJD(YourLibrary/JournalName). ReplaceYourLibrarywith your actual library name andJournalNamewith a descriptive name likeSALES_JRN. - Set the Journal Type: When prompted or via parameters, specify
TYPE(*STD)for standard journaling. This captures basic insert, update, and delete operations. - Define the Initial Receiver: Specify a receiver file name, such as
SALES_RCV1. This file will physically hold the journal entries. Ensure it is created in the same library as the journal. - Confirm Creation: Press Enter. The system will create the journal object and the initial receiver file. Verify success by checking the job log for no error messages.
The journal object is now empty but active. It is ready to receive instructions to track changes in specific files.
Step-by-Step: Attaching the Journal to the File
With the journal created, you can now link it to the physical file you wish to protect. Use the STRJRNPF (Start Journaling Physical File) command.
- Enter the Command: Type
STRJRNPF FILE(YourLibrary/FileName) JRN(YourLibrary/JournalName). - Select Journaling Mode: Choose
UPDATE(*YES)to capture changes to existing records. ChooseDELETE(*YES)to capture deletions. For most critical files, set both to*YES. - Handle Existing Data: Decide how to treat records already in the file. Select
INITIAL(*NO)to only journal new changes. SelectINITIAL(*YES)if you need a full snapshot of current data, though this may take longer for large files. - Set the Start Time: You can start immediately (
*CURRENT) or schedule it for a future time. Immediate start is recommended for urgent protection. - Execute: Press Enter. The system will lock the file briefly to establish the journal connection. Once complete, the file is actively journaled.
At this point, any subsequent modification to the file is recorded in the journal receiver. You can verify this by performing a test update on a sample record and then browsing the journal receiver.
Worked Example: Protecting a Sales File
Consider a scenario where you manage a sales order file named SORDHDR in the library ACCTDATA. You want to journal updates and deletes to prevent data loss during a month-end close.
First, you create the journal: CRTPJRN PJD(ACCTDATA/SORD_JRN) TYPE(*STD) JRNRCV(ACCTDATA/SORD_RCV1). This creates the tracking mechanism. Next, you attach it: STRJRNPF FILE(ACCTDATA/SORDHDR) JRN(ACCTDATA/SORD_JRN) UPDATE(*YES) DELETE(*YES) INITIAL(*NO). Now, if a user accidentally deletes a sales order, you can recover it using the RTVJRNE (Retrieve Journal Entry) command or through backup software that reads the journal receiver. The specific measurements here are the library names and the flags set to *YES, which dictate exactly what changes are captured.
Common Mistakes and Their Consequences
Journaling is powerful but sensitive to configuration errors. Avoid these common pitfalls.
Mistake 1: Starting Journaling on a Live System Without Testing. If you start journaling on a high-volume production file without adjusting system values, the journal receiver can fill up quickly. This causes the system to suspend writes to the file, effectively freezing your application. Always test on a copy of the file first to estimate growth rates.
Mistake 2: Ignoring Receiver Space Limits. By default, journals do not automatically expand receivers. If the receiver file reaches its maximum size limit (often 1 GB or less depending on configuration), journaling stops. You must manually add more space or configure automatic expansion. Failure to do so results in lost audit trails.
Mistake 3: Using INITIAL(*YES) on Large Files. Initializing a journal on a file with millions of records forces the system to read every existing row. This can tie up CPU resources for hours and block access to the file for other users. Only use initialization if you specifically need a baseline snapshot; otherwise, stick to INITIAL(*NO).
Monitoring and Maintenance
Once journaling is active, you must monitor it to ensure data safety. Use the WRKJRN (Work with Journal) command to view the status of your journal objects. Check the receiver sizes regularly. If a receiver is nearing capacity, you can add a new receiver using ADDPJNRRCE or archive old data to free up space.
Remember that journaling does not replace backups. Backups capture the state of the file at a point in time, while journals capture the changes between those points. Use both together for a complete disaster recovery strategy. Regularly test your ability to retrieve journal entries to ensure your recovery procedures work as expected.
What happens if I stop journaling?
Stopping journaling with ENDJRNPF disconnects the file from the journal. No further changes will be recorded. However, previously captured entries remain in the receiver files and can still be used for recovery. You must restart journaling separately if you wish to resume tracking.
Can I journal a logical file instead of a physical file?
No. You can only journal physical files (PF). Logical files (LF) are views of physical files. Changes made through a logical file are actually changes to the underlying physical file, which is already journaled. Therefore, journaling the PF covers all activity.
How do I view the journal entries?
You can browse journal entries using WRKJRN and selecting option 10 (Display Journal Entries). You can filter by date, time, and file name to find specific changes. For detailed analysis, use SQL queries against the journal receiver files if they are converted to relational tables.
Related
- Journal for Birdwatching: What to Write and How to Start
- Nature Walk Journal: How to Start and Keep One
- Watercolor Painting Prompts for Daily Practice
General information for everyday wellbeing, not medical advice. If something affects your health, sleep or mood for more than a short while, talk to a qualified professional. Read more
Spotted an error? Tell us and we will correct it (corrections policy).