View Full Version : Determining Run Environment
Guest.Visitor
01-01-1995, 02:00 AM
We have an extremely usefull interactive program that I would like to call from a batch job. Is there any way I can determine withing the program if it running in BATCH? I have searched the PSDS but nothing is jumping out at me. Should I just clone the program and only use what I need for the batch runs?
Guest.Visitor
06-21-2000, 08:46 AM
You can determine how the job is running by using the command RTVJOBA and looking at the TYPE parameter.
nycsusan@hotmail.com
06-21-2000, 08:46 AM
One solution is to have the batch job create a data area when it begins and delete it when the job ends. The interactive job could check for the existence of the data area to determine if the job is running in batch or not. Or leave the data area there at all times, but change the value back and forth from "LOCKED" to "UNLOCKED" (or whatever) as your batch job begins and ends.
D.Handy
06-21-2000, 08:55 AM
Joe, <font color=blue>Is there any way I can determine withing the program if it running in BATCH?</font> From a CLP, the easiest way is to use RTVJOBA TYPE(&pgmvar), but you probably knew that. From RPG, you can either call a short CL program which does the RTVJOBA and returns the result, or you can use APIs to get the job information. Here is a link to a program on News/400 to do it from RPG: http://www.as400network.com/communities/rpgprogrammer/rpgcode/Interact.zip Doug
Guest.Visitor
06-21-2000, 09:58 AM
Do you happen to have any RPG/400 code examples?
Guest.Visitor
06-21-2000, 10:16 AM
Joe, Here is an example, look at the rtntyp. <pre> ************************************************** ****************************** ************** * Module - RTVJOBINF * * By - David Morris * * Purpose - Retrieve Job Information * ************************************************** ****************************** ************** * Date Programmer Description * * -------- ---------- -------------------------------------------------------------------- * ************************************************** ****************************** ************** H NoMain /COPY QRPGLESRC,APIErr /COPY QPROTOSRC,CEEDOD /COPY QPROTOSRC,CEETSTA /COPY QPROTOSRC,DatTim /COPY QPROTOSRC,MsgTkt /COPY QPROTOSRC,RtvJobInf /COPY QSYSINC/QRPGLESRC,QUSRJOBI Define API format. DAPIQUsrJobI PR EXTPGM(QUSRJOBI) Rtv job information. D PR_RtnJobI 5000A OPTIONS(*VARSIZE) Return information. D PR_LenRtnObjD 10I 0 CONST Information length. D PR_RtnFmt 8A CONST Information format. D PR_QJob 26A CONST Qualified job. D PR_IJob 16A CONST Internal job. D PR_APIErr LIKE(APIErr) OPTIONS(*NOPASS) Error structure. /TITLE RtvJobInf - Retrieve job information. ************************************************** ****************************** ************** * *RtvJobInf Retrieve object description and return in parameters passed. * ************************************************** ****************************** ************** PRtvJobInf B EXPORT DRtvJobInf PI LIKE(RtnErr) D OptJob 10A CONST OPTIONS(*OMIT) D OptUsr 10A CONST OPTIONS(*OMIT) D OptNbr 6A CONST OPTIONS(*OMIT) D RtnJob 10A OPTIONS(*OMIT) Job. D RtnUsr 10A OPTIONS(*OMIT: *NOPASS) User. D RtnNbr 6A OPTIONS(*OMIT: *NOPASS) Number. D RtnTyp 1A OPTIONS(*OMIT: *NOPASS) Type. D RtnSubTyp 1A OPTIONS(*OMIT: *NOPASS) Sub-Type. D RtnSts 10A OPTIONS(*OMIT: *NOPASS) Status. D RtnPty 10I 0 OPTIONS(*OMIT: *NOPASS) Priority. D RtnTimSlc 10I 0 OPTIONS(*OMIT: *NOPASS) Time slice. D RtnWat 10I 0 OPTIONS(*OMIT: *NOPASS) Wait time. D RtnPrg 10A OPTIONS(*OMIT: *NOPASS) Purge. **************** * Return Error * **************** DRtnErr S N INZ(*OFF) Return flag. ********************* * Working Variables * ********************* DQJob DS D Job LIKE(OptJob) Optional Job. D Usr LIKE(OptUsr) Optional user. D Nbr LIKE(OptNbr) Optional number. DRtnLen S 10I 0 INZ(%LEN(QUSI010000)) Information length. C EXSR SubSetPrm Setup input parms. C* C CALLP APIQUsrJobI( C QUSI010000: C RtnLen: C 'JOBI0100': C QJob: C *BLANKS: C APIErr) C EVAL RtnErr = SndAPIErr(APIErr) No error. C* C IF RtnErr = *OFF C EXSR SubRtnPrm Set return parms. C END RtnErr=*OFF C* C RETURN RtnErr C************************************************* ************************* C* *SubRtnPrm - Set return parameters. * C************************************************* ************************* C SubRtnPrm BEGSR C CALLP CEETSTA(ArgPas:4:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnJob = QUSJN01 Returned value. C END ArgPas=1 C* C IF %PARMS >= 5 C CALLP CEETSTA(ArgPas:5:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnUsr = QUSUN01 Returned value. C END ArgPas=1 C* C IF %PARMS >= 6 C CALLP CEETSTA(ArgPas:6:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnNbr = QUSJNbr01 Returned value. C END ArgPas=1 C* C IF %PARMS >= 7 C CALLP CEETSTA(ArgPas:7:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnTyp = QUSJT02 Returned value. C END ArgPas=1 C* C IF %PARMS >= 8 C CALLP CEETSTA(ArgPas:8:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnSubTyp = QUSJS02 Returned value. C END ArgPas=1 C* C IF %PARMS >= 9 C CALLP CEETSTA(ArgPas:9:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnSts = QUSJS01 Returned value. C END ArgPas=1 C* C IF %PARMS >= 10 C CALLP CEETSTA(ArgPas:10:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnPty = QUSRP Returned value. C END ArgPas=1 C* C IF %PARMS >= 11 C CALLP CEETSTA(ArgPas:11:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnTimSlc = QUSTS Returned value. C END ArgPas=1 C* C IF %PARMS >= 12 C CALLP CEETSTA(ArgPas:12:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnWat = QUSDW Returned value. C END ArgPas=1 C* C IF %PARMS >= 13 C CALLP CEETSTA(ArgPas:13:*OMIT) Parm omitted? C IF ArgPas = 1 Not omitted. C EVAL RtnPrg = QUSPurge Returned value. C END ArgPas=1 C END %PARMS>=13 C END %PARMS>=12 C END %PARMS>=11 C END %PARMS>=10 C END %PARMS>=9 C END %PARMS>=8 C END %PARMS>=7 C END %PARMS>=6 C END %PARMS>=5 C ENDSR C************************************************* ************************* C* SubSetPrm - Set input parameter values. * C************************************************* ************************* C SubSetPrm BEGSR C CALLP CEETSTA(ArgPas:1:*OMIT) Parm passed? C IF ArgPas = 1 Yes. C EVAL Job = OptJob C ELSE C EVAL Job = '*' Use default. C END ArgPas=1 C CALLP CEETSTA(ArgPas:2:*OMIT) Parm passed? C IF ArgPas = 1 Yes. C EVAL Usr = OptUsr C ELSE C EVAL Usr = *BLANKS Use default. C END ArgPas=1 C CALLP CEETSTA(ArgPas:3:*OMIT) Parm passed? C IF ArgPas = 1 Yes. C EVAL Nbr = OptNbr C ELSE C EVAL Nbr = *BLANKS Use default. C END ArgPas=1 C ENDSR PRtvJobInf E</pre> David Morris
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.