Using &SYSNAME to determine if a step should be run



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Using &SYSNAME to determine if a step should be run

Postby tcpipman » Sat Jan 28, 2017 2:08 am

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.
tcpipman
 
Posts: 18
Joined: Tue Sep 22, 2015 2:03 pm
Has thanked: 4 times
Been thanked: 0 time

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

Postby Akatsukami » Sat Jan 28, 2017 2:19 am

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

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

Postby Robert Sample » Sat Jan 28, 2017 2:37 am

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

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

Postby willy jensen » Sat Jan 28, 2017 3:16 pm

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.

These users thanked the author willy jensen for the post:
tcpipman (Mon Jan 30, 2017 8:57 pm)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

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

Postby Aki88 » Mon Jan 30, 2017 1:34 pm

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.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

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

Postby tcpipman » Mon Jan 30, 2017 8:52 pm

Thanks, Its disappointing I can not do this without the extra step but that is life I guess...
tcpipman
 
Posts: 18
Joined: Tue Sep 22, 2015 2:03 pm
Has thanked: 4 times
Been thanked: 0 time

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

Postby tcpipman » Mon Jan 30, 2017 8:57 pm

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 ...
tcpipman
 
Posts: 18
Joined: Tue Sep 22, 2015 2:03 pm
Has thanked: 4 times
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post