Repository navigation
Program Status Data Structure
danlong005 edited this page Aug 30, 2026
·
3 revisions
The PSDS (PSDS) keyword on a DCL-DS declares the Program Status Data Structure.
OpenRPG populates it at startup with process and environment information, mirroring
the IBM i layout at the well-known POS offsets.
DCL-DS PgmInfo PSDS QUALIFIED;
PgmName CHAR(10) POS(81); // program name (source file stem)
UserID CHAR(10) POS(91); // current OS user
JobNum CHAR(8) POS(101); // process ID (zero-padded)
RunDate CHAR(8) POS(109); // YYYYMMDD
RunTime CHAR(6) POS(119); // HHMMSS
END-DS;| POS | Length | Content |
|---|---|---|
| 1 | 10 | Current procedure name |
| 11 | 5 | Current status code (PACKED 5,0) |
| 81 | 10 | Program name |
| 91 | 10 | User profile / OS username |
| 101 | 8 | Job number (PID, zero-padded) |
| 109 | 8 | Run date (YYYYMMDD) |
| 119 | 6 | Run time (HHMMSS) |
IF %TRIM(PgmInfo.UserID) <> '';
DSPLY 'Running as: ' + PgmInfo.UserID;
ENDIF;
DSPLY 'Started: ' + PgmInfo.RunDate + ' ' + PgmInfo.RunTime;The PSDS also syncs before every ON-ERROR handler fires, so you can read
StatusCode inside MONITOR blocks to identify the error.
- Installation
- Quick Start
- CLI Reference
- Language Basics
- Data Types
- Variables and Constants
- Data Structures
- Arrays
- Varying-Dimension Arrays
- Control Flow
- Procedures
- Procedure Overloading
- Built-In Functions
- Error Handling
- Operation Extenders
- Enumerations
- Program Status Data Structure
- Data Areas
- SND-MSG
- Embedded SQL
- Record-Level Access
- Display Files (WORKSTN)
- Program-Described Files (I-Specs and O-Specs)
- DATA-INTO and DATA-GEN
- XML-INTO
- Fixed-Format Source
- Database Connections
- Multi-Module Programs
- Environment Variables
- Testing
- Complete Example: Employee Report
- IBM i Conformance Results
- IBM i Execution Results