Page 1 of 1

Using &SYSNAME to determine if a step should be run

PostPosted: Sat Jan 28, 2017 2:08 am
by tcpipman
I am trying to create some JCL that will create a set of datasets with displays. Depending on the LPAR they are going to be different displays. I want to make it so particular job steps in a JCL will only run on that LPAR. I have tried using an IF THEN ENDIF statements but it seems that it requires a numerical value.

Saying my LPAR name was BATMAN I tried the following

IF (&SYSNAME EQ BATMAN) THEN


ENDIF

But it fails with the error BATMAN is not a valid value.

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Sat Jan 28, 2017 2:19 am
by Akatsukami
The IF-THEN-ELSE construct works only with return and completion codes. You cannot do what you are attempting. This functionality ought to be incorporated into the program(s) being run.

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Sat Jan 28, 2017 2:37 am
by Robert Sample
I want to make it so particular job steps in a JCL will only run on that LPAR.
First, you can route JOBS to an LPAR -- you cannot run step 1 on LPAR A and then run step 2 on LPAR B; you can route the job to LPAR A or B (particularly if using JES3) but not individual steps.

Second, &SYSNAME and the other symbols are usually used in data set names (A.B.&SYSNAME..LAST, for example) -- as pointed out, you cannot use a system symbol in an IF statement in JCL.

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Sat Jan 28, 2017 3:16 pm
by willy jensen
This has been discussed a number of times before. If you want to control execution of steps based on anything but return code you need a step to set the return code based on some test.
My own method is this one-liner REXX program which I call SETCC:
Interpret "Exit (" arg(1) ")"  /* rexx */  

And used like this:
//TEST1   EXEC PGM=IKJEFT01,                  
//         PARM='SETCC MVSVAR(SYSNAME)=BATMAN'
//SYSTSPRT DD SYSOUT=*                        
//SYSEXEC  DD DISP=SHR,DSN=YOUR.REXX.LIB      
//SYSTSIN  DD DUMMY                            
// IF TEST1.RC EQ 1 THEN     IN SYSTEM BATMAN  
 

I have the JCL stored as a procedure to make it simpler.

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Mon Jan 30, 2017 1:34 pm
by Aki88
Hello,

As others have already suggested, going by what you already have, you'll need to test the region name, set an RC, and depending on it execute the step/PROC. You can also use ICETOOL to set the RC basis the SYSNAME or you can write a fairly small parameterized COBOL program which will test for SYSNAME and set an RC.

Lastly, if you have z/OS 2.x, explore the possibility of using JOBGROUP in a JCL, it allows you to group on the basis of SYSTEM as well.

Hope this helps.

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Mon Jan 30, 2017 8:52 pm
by tcpipman
Thanks, Its disappointing I can not do this without the extra step but that is life I guess...

Re: Using &SYSNAME to determine if a step should be run

PostPosted: Mon Jan 30, 2017 8:57 pm
by tcpipman
willy jensen wrote:This has been discussed a number of times before. If you want to control execution of steps based on anything but return code you need a step to set the return code based on some test.
My own method is this one-liner REXX program which I call SETCC:
Interpret "Exit (" arg(1) ")"  /* rexx */  

And used like this:
//TEST1   EXEC PGM=IKJEFT01,                  
//         PARM='SETCC MVSVAR(SYSNAME)=BATMAN'
//SYSTSPRT DD SYSOUT=*                        
//SYSEXEC  DD DISP=SHR,DSN=YOUR.REXX.LIB      
//SYSTSIN  DD DUMMY                            
// IF TEST1.RC EQ 1 THEN     IN SYSTEM BATMAN  
 

I have the JCL stored as a procedure to make it simpler.



This helps alot .. thanks ...