Lesson 5 · July 2026 RPG Enhancements
RPG PSDS Job Type and Subtype
Learn how RPG can use the PSDS job type and subtype fields to understand how a program is running, with short practical examples.
The PSDS can now include job type and subtype information, giving RPG programs an easier way to understand how they are running.
The Program Status Data Structure, usually called the PSDS, is one of those RPG features that many developers know exists, but do not always use often.
It can provide useful runtime information about the current program and job.
With the July 2026 RPG enhancements, IBM lists job type and subtype in the PSDS as one of the new additions.
That gives RPG programs another simple way to understand their execution context.
What changed?
IBM added job type and job subtype information to the RPG Program Status Data Structure.
IBM documents job type at position 404 and job subtype at position 405. Subfield names are chosen by the program; their positions determine which PSDS values they read.
Conceptually, your program can use the PSDS to answer questions like:
What kind of job am I running in?
Is this an interactive job?
Is this a batch job?
Is this a special job subtype?
Simple way to remember
The PSDS tells your RPG program about its runtime context. Job type and subtype add more context about the job itself.
Why should you care?
Many RPG programs behave differently depending on where and how they run.
For example:
- Interactive programs may show messages to a workstation user.
- Batch programs may write more detail to a job log.
- Service programs or API-style jobs may need different error handling.
- Scheduled jobs may need different logging or notification behavior.
- Utility programs may need to detect whether they are running in the expected job context.
Before this enhancement, developers often used other approaches to find job information.
For example, they might call APIs, use SQL services, inspect job names, or depend on job descriptions and environment conventions.
Those approaches can still be valid.
But having job type and subtype available in the PSDS can make some RPG code simpler and more direct.
Simple PSDS shape
A PSDS is defined with psds.
**free
ctl-opt dftactgrp(*no);
dcl-ds PgmStatus psds qualified;
programName char(10) pos(1);
statusCode zoned(5 : 0) pos(11);
jobName char(10) pos(244);
userName char(10) pos(254);
jobNumber char(6) pos(264);
jobType char(1) pos(404);
jobSubtype char(1) pos(405);
end-ds;
*inlr = *on;
return;
The explicit positions are essential. Without them, these fields follow jobNumber at positions 270 and 271 and read unrelated PSDS bytes.
Validation status: the layout has been checked against IBM documentation. This revised example has not yet been compiled or run on IBM i. The following fragments belong before *inlr = *on and return in the sample above; comments describe application-specific logic to supply.
Example: choose different logging behavior
One common use case is logging.
A program may want to log differently when running in batch versus interactive mode.
if PgmStatus.jobType = 'B';
// Batch job:
// write detailed diagnostic information to a log table or job log.
elseif PgmStatus.jobType = 'I';
// Interactive job:
// keep the message short and useful for the user.
else;
// Other job type:
// use a safe default logging approach.
endif;
IBM documents 'B' for batch and 'I' for interactive jobs. These are common values, not an exhaustive list.
The main idea is simple:
Let the program use its job context to make better runtime decisions.
Example: guard a utility program
Some utilities should only run in batch.
For example, a cleanup process, archive process, or mass update program may not be intended for interactive use.
if PgmStatus.jobType <> 'B';
// Send an error message, log the issue, or return safely.
// This program is expected to run only in batch.
return;
endif;
This kind of check can prevent a program from being used in the wrong context.
It is not a replacement for authority, job control, or good operational design.
But it can be a useful safety check.
Example: different behavior for scheduled processing
Imagine a program used both manually and by a scheduler.
The job type and subtype can help the program decide how much output to create, where to log messages, or whether to send notifications.
select;
when PgmStatus.jobType = 'B';
// Batch/scheduled style processing.
// Write detailed operational logs.
when PgmStatus.jobType = 'I';
// Interactive usage.
// Keep output user-friendly.
other;
// Fallback behavior.
// Avoid assuming too much.
endsl;
A batch job is not necessarily a scheduled job. Use scheduler or application context when that distinction matters; do not infer it from 'B' alone.
When to use PSDS job type and subtype
Use these PSDS fields when the program needs to understand how it is running.
Good use cases include:
- changing logging behavior
- detecting batch versus interactive execution
- guarding programs that should only run in certain job types
- improving diagnostic messages
- supporting operational utilities
- making error handling more context-aware
When not to use it
Do not overuse job type checks.
If a program’s business logic should be the same regardless of job type, keep it the same.
Avoid scattering job-type logic all over the application.
It is usually better to centralize this kind of check in:
- utility procedures
- logging procedures
- message handling logic
- program entry checks
Also avoid using job type as a substitute for security.
Authority, adopted authority, object ownership, and operational controls still matter.
Practical advice
Use the PSDS job type and subtype where it makes the code more intentional.
For example, this is reasonable:
if isBatchJob();
writeDetailedLog();
else;
sendUserMessage();
endif;
This is better than repeating low-level PSDS checks everywhere.
The PSDS can provide the information.
Your application design should decide how to use it cleanly.
PTF / release note
IBM lists these 5770SS1 ILE RPG runtime PTFs for the new PSDS fields:
| IBM i release | Runtime PTF |
|---|---|
| 7.5 | SJ10448 |
| 7.6 | SJ10449 |
Confirm the applicable PTF or its superseding fix is applied on every system where the program runs. This example uses existing PSDS declaration syntax and contains no embedded SQL; the enhancement’s published prerequisites are runtime PTFs.
After confirming the runtime level, compile the sample and test it in an interactive job and a submitted batch job. Capture the job type and subtype in each run, along with the release, PTF level, and compile command. Expected common types are I and B; these are expectations, not captured results.
See IBM’s job type and subtype enhancement page for the documented positions, values, and prerequisites.
Final takeaway
The PSDS already helps RPG programs understand their runtime context.
Adding job type and subtype makes that context more useful.
Use it when the program needs to make clear runtime decisions based on how the job is running.
Keep it simple.
Keep it centralized.
And always verify the current IBM documentation before relying on the exact field layout or values.
References
Documentation and references used for this lesson.

Comments
Share your thoughts, questions, or real-world IBM i experiences related to this article.