DCL-DS name PSDS; declares the Program Status Data Structure, whose subfields are
addressed by position (for example Status ZONED(5) POS(11)). In fixed-format, the
same structure is declared by an S in position 23 of the data-structure D-spec, with
each subfield located by its From/To byte positions (for example a subfield spanning
positions 11 - 15 is the status code). A subfield may instead name its location with a
special-word keyword: *PROC (program name, positions 1 - 10), *STATUS (status code,
11 - 15), *ROUTINE (routine name, 29 - 36), and *PARMS (number of parameters, 37 - 39).
In free-format the keyword replaces the type (procName *PROC;); in fixed-format it is
written in the From/To area (columns 26 - 39). Both the special-word and positional forms
are auto-populated identically. A *ROUTINE subfield is initialized to blanks. PSDS
subfields are auto-populated at program startup based on their positions:
| POS | Type | Content |
|---|---|---|
| 1 | CHAR(10) | Program name (class name, blank-padded) |
| 11 | ZONED(5:0) | Status code (0 initially; updated live on every error/clear) |
| 16 | ZONED(5:0) | Previous status (0 initially) |
| 37 | ZONED(3:0) | Number of parameters passed |
| 40 | CHAR(3) | Exception type - the 3-character prefix of the message ID (e.g. MCH for a machine exception, CPF for a system message, RPG for an RPG runtime error). Populated when an exception is caught by MONITOR or *PSSR; cleared on the next successful operation. |
| 43 | CHAR(4) | Exception number - the 4-character suffix of the message ID (e.g. 1211 for divide-by-zero MCH1211). Populated alongside POS 40. |
| 81 | CHAR(10) | Program library - on IBM i this is the library the program object resides in. On the JVM there is no object library, so this is initialized to blanks. |
| 91 | CHAR(80) | Exception data - additional error message text. Initialized to blanks. |
| 254 | CHAR(10) | User profile name - the logical IBM i user for the job. On IBM i this is the job user; on the JVM there is no IBM i user-profile system, so it is not taken from the host OS login. It defaults to *BLANKS unless an embedding host supplies the session user via RpgActivationGroup.setUserProfile(...) before the program runs. |
| 358 | CHAR(10) | Current user profile (same value as POS 254) |
The TEMPLATE keyword on DCL-DS or DCL-S declares a definition-only type reference
that allocates no storage. A template may be referenced via LIKEDS, LIKE, %SIZE,
or %ELEM, but cannot be used as a runtime variable (assigned to, read from, or passed
as a parameter). This enforces a clean separation between type layout and data.