.st0{fill:#FFFFFF;}

How do we Check for Batch or Interactive in CLLE 

 February 21, 2020

By  NickLitten

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.

For example:

  • Stinky Code : if cond(&INTERACTIVE = ‘1’) then(do stuff)
  • Sniffy Code : if cond(&INTERACTIVE) then(do stuff)

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.

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad 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 remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!

>