Skip to content

Program Status Data Structure

danlong005 edited this page Aug 30, 2026 · 3 revisions

Program Status Data Structure

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.

Clone this wiki locally