As an expert RPG programmer, How can you tell if an RPG program runs in
Batch or Interactive (PSDS?)
I got the following
Using PSDS to Detect Batch vs Interactive Mode
The PSDS (Program Status Data Structure) contains information about the
program's execution environment. The key field for determining batch vs
interactive mode is at positions 244-253, which contains the job name.
Method 1: Check Job Type Field (Position 244-253)
Here's how to implement this in free-format RPGLE:
**FREE// Define PSDSDcl-Ds PSDS Qualified; PgmName Char(10)
Pos(1); Status Zoned(5:0) Pos(11); PrevStatus Zoned(5:0)
Pos(16); LineNum Char(8) Pos(21); Routine Char(8)
Pos(29); Parms Zoned(3:0) Pos(37); ExcpType Char(3)
Pos(40); ExcpNum Char(4) Pos(43); PgmLib Char(10)
Pos(81); ExcpData Char(80) Pos(91); ExcpId Char(4)
Pos(171); Date Char(8) Pos(191); Year Zoned(2:0)
Pos(199); LastFile Char(8) Pos(201); LastFileLib Char(10)
Pos(209); JobName Char(10) Pos(244); // Job name UserId
Char(10) Pos(254); // User profile JobNumber Zoned(6:0)
Pos(264); // Job number JobDate Zoned(6:0) Pos(270); // Job
date RunDate Zoned(6:0) Pos(276); // Run date (YYMMDD) RunTime
Zoned(6:0) Pos(282); // Run time (HHMMSS)End-Ds;Dcl-S JobType
Char(1);// Determine if batch or interactiveIf
%Subst(PSDS.JobName:1:1) >= '0' and %Subst(PSDS.JobName:1:1) <=
'9'; JobType = 'B'; // Batch job (starts with number)Else; JobType
= 'I'; // Interactive job (starts with Q)EndIf;
This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.