|
On Mon, 16 Apr 2001 tomh@simas.com wrote:
> Is there some way for me to determine if my RPGLE program is running in
> batch or interactive mode, from within the program itself?
There's an API that'll do this. The API is "QUSRJOBI" (Retrieve Job
Information). The way I handled this was to 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
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.