Return to the RPG Tips
Use the QUSRJOBI API to determine if RPGLE program is Batch or Interactive.
Create a simple "IsIntJob" (Is interactive job?) procedure, and throw it into a "tools" service program.
Here's the subprocedure that I use, along with a quick example:
D IsIntJob PR 1N D Msg S 50A c if IsIntJob c eval Msg = 'Interactive job' c dsply Msg c else c eval Msg = 'Non-interactive job.' c Msg dsply c endif c eval *inlr = *on *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * IsIntJob -- Is this an interactive job? * returns *ON if job is interactive * or *OFF if job is not interactive. *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P IsIntJob B export D IsIntJob PI 1N D QUSRJOBI PR EXTPGM('QUSRJOBI') D RcvVar 32766A options(*varsize) D RcvVarLen 10I 0 const D Format 8A const D QualJob 26A const D InternJob 16A const D ErrorCode 32766A options(*nopass:*varsize) D dsJob DS D dsJobBytesRtn 10I 0 D dsJobBytesAvl 10I 0 D dsJobName 10A D dsJobUser 10A D dsJobNumber 6A D dsJobIntern 16A D dsJobStatus 10A D dsJobType 1A D dsJobSubtype 1A D dsJobReserv1 2A D dsJobRunPty 10I 0 D dsJobTimeSlc 10I 0 D dsJobDftWait 10I 0 D dsJobPurge 10A c callp QUSRJOBI(dsJob: %size(dsJob): 'JOBI0100': c '*': *blanks) c if dsJobType = 'I' c return *ON c else c return *OFF c endif P E
[report a broken link by clicking here]