RE: Uncle Bob

"Birgitta Hauser" <Hauser-bRAHsVz2yv4TVIZRl6KS/[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
I just run the same question though ChatGPT and CLAUDE.
Claude suggested to run the QUSRJOBI (which is one of the 2 Methods I know ... the other is calling a CL-Program that retrieves the Job attribute (RTVJOBA).
ChatGPT insisted to use the *INRT-Indicator or the %INRT() BIF which both do not exist.
None of them pointed to the program status data structure.

In either way the Program Status Data Structure, does not include a job type.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect  
IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them and keeping them!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (Albert Einstein)


-----Original Message-----
From: RPG400-L <[email protected]> On Behalf Of Gad Miron
Sent: Sunday, 25 January 2026 08:05
To: [email protected]
Subject: Uncle Bob

What am I missing?


I asked Bob the following question:

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;

txt1c1c-queryabapactionscript-3adaadocangular-htmlangular-tsapacheapexapl
applescriptaraasciidocasmastroawkballerinabashbatbatchbebeancountberrybibtex
bicepbladebslcc#c++cadencecairocdcclaritycljclojureclosure-templatescmakecmd
cobolcodeownerscodeqlcoffeecoffeescriptcommon-lispconsolecoqcppcqlcrystalcs
csharpcsscsvcuecypherddartdaxdesktopdiffdockerdockerfiledotenvdream-maker
edgeelispelixirelmemacs-lisperberlerlangff#f03f08f18f77f90f95fennelfish
fluentforfortran-fixed-formfortran-free-formfsfsharpfslftlgdresourcegdscript
gdshadergeniegherkingit-commitgit-rebasegjsgleamglimmer-jsglimmer-tsglsl
gnuplotgogqlgraphqlgroovygtshackhamlhandlebarshaskellhaxehbshclhjsonhlslhs
htmlhtml-derivativehttphxmlhyimbainijadejavajavascriptjinjajisonjljsjson
json5jsoncjsonljsonnetjssmjsxjuliakotlinkqlktktskustolatexleanlean4less
liquidlisplitllvmloglogolualuaumakemakefilemarkdownmarkomatlabmdmdcmdx
mediawikimermaidmipsmipsasmmmdmojomovenarnarratnextflownfnginxnimnixnu
nushellobjcobjective-cobjective-cppocamlpascalperlperl6phpplsqlpopolar
postcsspotpotxpowerquerypowershellprismaprologpropertiesprotoprotobufpsps1
pugpuppetpurescriptpypythonqlqmlqmldirqssrracketrakurazorrbregregexregexprel
riscvrsrstrubyrustsassassscalaschemescsssdblshshadershaderlabshell
shellscriptshellsessionsmalltalksoliditysoysparqlsplsplunksqlssh-configstata
stylstylussvelteswiftsystem-verilogsystemdtalontalonscripttasltcltempl
terraformtextftfvarstomltsts-tagstsptsvtsxturtletwigtyptypescripttypespec
typstvvalavbverilogvhdlvimvimlvimscriptvuevue-htmlvyvyperwasmwenyanwgslwiki
wikitextwitwlwolframxmlxslyamlymlzenscriptzigzsh文言
Method 2: Using Job Type from PSDS (Position 304)

In newer IBM i versions, there's a dedicated field:

**FREEDcl-Ds PSDS Qualified;  // ... other fields ...  JobType Char(1) Pos(304);  // 0=Batch, 1=InteractiveEnd-Ds;If PSDS.JobType = '1';  // Interactive jobElse;  // Batch jobEndIf;

txt1c1c-queryabapactionscript-3adaadocangular-htmlangular-tsapacheapexapl
applescriptaraasciidocasmastroawkballerinabashbatbatchbebeancountberrybibtex
bicepbladebslcc#c++cadencecairocdcclaritycljclojureclosure-templatescmakecmd
cobolcodeownerscodeqlcoffeecoffeescriptcommon-lispconsolecoqcppcqlcrystalcs
csharpcsscsvcuecypherddartdaxdesktopdiffdockerdockerfiledotenvdream-maker
edgeelispelixirelmemacs-lisperberlerlangff#f03f08f18f77f90f95fennelfish
fluentforfortran-fixed-formfortran-free-formfsfsharpfslftlgdresourcegdscript
gdshadergeniegherkingit-commitgit-rebasegjsgleamglimmer-jsglimmer-tsglsl
gnuplotgogqlgraphqlgroovygtshackhamlhandlebarshaskellhaxehbshclhjsonhlslhs
htmlhtml-derivativehttphxmlhyimbainijadejavajavascriptjinjajisonjljsjson
json5jsoncjsonljsonnetjssmjsxjuliakotlinkqlktktskustolatexleanlean4less
liquidlisplitllvmloglogolualuaumakemakefilemarkdownmarkomatlabmdmdcmdx
mediawikimermaidmipsmipsasmmmdmojomovenarnarratnextflownfnginxnimnixnu
nushellobjcobjective-cobjective-cppocamlpascalperlperl6phpplsqlpopolar
postcsspotpotxpowerquerypowershellprismaprologpropertiesprotoprotobufpsps1
pugpuppetpurescriptpypythonqlqmlqmldirqssrracketrakurazorrbregregexregexprel
riscvrsrstrubyrustsassassscalaschemescsssdblshshadershaderlabshell
shellscriptshellsessionsmalltalksoliditysoysparqlsplsplunksqlssh-configstata
stylstylussvelteswiftsystem-verilogsystemdtalontalonscripttasltcltempl
terraformtextftfvarstomltsts-tagstsptsvtsxturtletwigtyptypescripttypespec
typstvvalavbverilogvhdlvimvimlvimscriptvuevue-htmlvyvyperwasmwenyanwgslwiki
wikitextwitwlwolframxmlxslyamlymlzenscriptzigzsh文言
Method 3: Using API (Most Reliable)

For the most reliable method, use the QUSRJOBI API:





I see no such fields in RPG Reference Manual , PSDS section.

I must be missing something.


Gad
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.


-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.