Uncle Bob
Gad Miron <[email protected]>
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <CAFj_=c0baoXLQmcnyRboXXNmxd6Q+yBzb9TgiO3_V4TCC=eyrw@mail.gmail.com> |
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.