× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Exactly what I was going to suggest. However, we would need a host variable:

EXEC SQL
SELECT V_ACTIVE_JOB_TYPE
INTO*:this_job_type*
FROM TABLE(QSYS2.GET_JOB_INFO('*'));

Then check the THIS_JOB_TYPE RPG variable.

On 1/25/2026 4:37 AM, hasi@xxxxxxxxxxxx wrote:
Use SQL ?
SELECT V_ACTIVE_JOB_TYPE FROM TABLE(QSYS2.GET_JOB_INFO('*'))
herbert

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

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.