Use the Retrieve Job Attribute (RTVJOBA) command to snaffle the job’s run type from the attributes. Seems pretty obvious right?
One little niggle was that the RTVJOBA passes back a char(1) value for the jobtype where ‘0’ means batch and ‘1’ means interactive. But, I want to be able to neatly compare a logical value to see if its interactive or not.
Luckily its quite easy to code in IBM i Control Language:
PGM DCL VAR(&JOBTYPE) TYPE(CHAR) LEN(1) VALUE('0') /* Sadly the RTVJOBA command wants a CHARACTER value as a parameter (even though we want to use a logical *ON or *OFF) */ DCL VAR(&INTER) TYPE(LGL) STG(DEFINED) DEFVAR(&JOBTYPE) /* So lets define our logical variable but define it as the char(1) value so it inherits its value */ RTVJOBA TYPE(&JOBTYPE) /* grab the job runtype and let the *DEFINED overlay the character value &JOBTYPE into our logical value &INTER */ IF COND(&INTER) THEN(DO) SNDPGMMSG MSG('this is interactive') ENDDO ELSE CMD(DO) SNDPGMMSG MSG('this is batch') ENDDO RETURN ENDPGM
Pretty sniffy I might say.
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
Developerworks Connections Sunset – How to Extend RDi
Why use IBM i RDi?
How to Install IBM Access Client Solutions (ACS)
IBM i Data Obfuscation – Making Data Foggy Murky and Squinty
How to rename Fresche (BCD) Presto Library – XL_PRESTO
What is AS400 modernization?
IBM i ACS 5250 EMULATOR FONT – and other ridiculous mumbo jumbo
IBM i SQL statement to convert or compare hundred year date format
How to compare ‘100 Year Date’ to a Timestamp – aka – Weird AS400 iSeries Date formats