IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to use SETVAR in JCL?


IBM Mainframe Forums -> IBM Tools
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Fri Feb 22, 2019 1:19 am
Reply with quote

Dear all,

my code:
Code:

//DMDSPKCT JOB (@INF,FF31),'DMDSPKCT',                     
//         USER=SPARKID,MSGCLASS=X,TIME=1440,REGION=0M     
//        JCLLIB ORDER=(TFMS.F.DD.PROCLIB,TFMS.DD.PROCLIB)
//*                                                       
//*                                                       
//*                                                       
//FMSSYM   INCLUDE MEMBER=FMS#SYM       * DEFAULT SYMBOLICS
//         SET JOBNAME=FMSSPKCT                           
//*%OPC SCAN                                           
//      SET TRIGNAM=%OETEVNM                           
//*%OPC SETVAR TVAR2=SUBSTR(&TRIGNAM,3,2)               
//*%OPC BEGIN ACTION=NOSCAN                             
//STEP001  EXEC PGM=IEFBR14                             
//FILE02   DD DSN=ABC,                               
//            SPACE=(TRK,(1,1)),DISP=(MOD,DELETE,DELETE)


this jcl is in a file trigger opc, as long as i remove line of SETVAR, job run fine. But i need the SETVAR working, so you plz help on this?

thank you!
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Fri Feb 22, 2019 1:23 am
Reply with quote

forgot to mention: there is no error log in spool, can only see job 'Ended in error' in OPC
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Feb 22, 2019 2:14 am
Reply with quote

First, you are using an OPC (Tivoli Workload Scheduler) construct which has NOTHING to do with JCL -- so do NOT call it "SETVAR in JCL".

Second, did you look at the SETVAR in the TWS manual? The syntax diagram says at publib.boulder.ibm.com/tividd/td/TWS/SC32-1263-00/en_US/HTML/EQQR1MST342.htm
Code:
>-//*%OPC SETVAR----------------------------------------------->

>--Tname=(-date variable +/- nnnTT-)-+---------------------+---><
                                     |          .-SUBMIT-. |
                                     '-,PHASE=--+-SETUP--+-'
and I don't see anything in the syntax diagram about using SUBSTR. You cannot just make up what you want to do -- you have to follow the rules as described in the syntax diagrams.

And there would not be any error in the spool -- you don't have a JCL error, you have a TWS error.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Fri Feb 22, 2019 6:41 am
Reply with quote

Robert Sample wrote:
First, you are using an OPC (Tivoli Workload Scheduler) construct which has NOTHING to do with JCL -- so do NOT call it "SETVAR in JCL".

Second, did you look at the SETVAR in the TWS manual? The syntax diagram says at publib.boulder.ibm.com/tividd/td/TWS/SC32-1263-00/en_US/HTML/EQQR1MST342.htm
Code:
>-//*%OPC SETVAR----------------------------------------------->

>--Tname=(-date variable +/- nnnTT-)-+---------------------+---><
                                     |          .-SUBMIT-. |
                                     '-,PHASE=--+-SETUP--+-'
and I don't see anything in the syntax diagram about using SUBSTR. You cannot just make up what you want to do -- you have to follow the rules as described in the syntax diagrams.

And there would not be any error in the spool -- you don't have a JCL error, you have a TWS error.


thanks for the reply Robert.

actually i am seeing this:
Code:

>>-//*%OPC SETVAR----------------------------------------------->

>--+-Tname=--(--date time variable +/- nnnTT1 nnnTT2 nnnTT3--)-+-><
   +-Tname=--SUBSTR--(--variable--,--n--,--length--)-----------+   
   +-Tname=--(--numeric value / 'alphanumeric value'--)--------+   
   +-Tname=--(--variable1 +/- variable2--)---------------------+   
   |               .--------------------.                      |   
   |               V                    |                      |   
   '-Tname=--(--'----concatenation item-+--'--)----------------' 

www.ibm.com/support/knowledgecenter/SSRULV_9.5.0/com.ibm.tivoli.itws.doc_9.5/distr/src_sazos/awsszsetvar.htm

this is the correct one?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 22, 2019 3:45 pm
Reply with quote

Quote:
VAR1 is a variable defined in a JCL variable table

Is your resolved variable &TRIGNAM so defined?
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Mon Feb 25, 2019 3:46 pm
Reply with quote

Robert's syntax diagram does indeed seem to be incomplete, the SUBSTR directive is valid according to the v9.3 manual.

Why are you specifying the variable as %OETEVNM rather than &OETEVNM? % variables are used to form compound variables. I would imagine that would be the problem. I'm also curious as to why you're setting TRIGNAM to %OETEVNM and then getting a substring of that. Why not just get a substring of &OETEVNM?

If that doesn't help, then review the error in TWS. For jobs that fail in TWS before submission to JES, TWS will insert appropriate error messages in to the JCL.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Tue Feb 26, 2019 7:47 am
Reply with quote

David Robinson wrote:
Robert's syntax diagram does indeed seem to be incomplete, the SUBSTR directive is valid according to the v9.3 manual.

Why are you specifying the variable as %OETEVNM rather than &OETEVNM? % variables are used to form compound variables. I would imagine that would be the problem. I'm also curious as to why you're setting TRIGNAM to %OETEVNM and then getting a substring of that. Why not just get a substring of &OETEVNM?

If that doesn't help, then review the error in TWS. For jobs that fail in TWS before submission to JES, TWS will insert appropriate error messages in to the JCL.


thanks David.

in TWS it only says ERROR IN JCL.

As of OETEVNM , i also tried substring of OETEVNM , but still ERROR IN JCL and no log.
it seems the SETVAR only works only variable contain DATE or TIME parms like MM, DD, or OCDATE etc
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Tue Feb 26, 2019 3:14 pm
Reply with quote

When you say that in TWS, it only says ERROR IN JCL, where are you looking? In the JCL? I can't imagine that you would see ERROR IN JCL if you browse the JCL. I have tried the same thing and I get this -

Code:
====== //*>OPC SCAN
======  //      SET TRIGNAM=%OETEVNM
=NOTE= //*>EQQJ535E 02/26 09.36.28
=NOTE= //*>         UNDEFINED VARIABLE OPC LINE 00011 OF ORIG JCL
======  //*%OPC SETVAR TVAR2=SUBSTR(&TRIGNAM,3,2)
======  //*%OPC BEGIN ACTION=NOSCAN
======  //STEP001  EXEC PGM=IEFBR14


You need to be clear about the difference between variables that TWS will resolve prior to submission and those that JES will resolve after submission. The SET statement is a JCL statement. So although TWS will resolve the OETEVNM variable, it will not know that TRIGNAM has that same value, and hence will not be able to get a SUBSTR of it.

So, as per my previous note, what are you trying to achieve by setting a new variable TRIGNAM to the value of OETEVNM? If you just use the OETEVNM variable, you will not have this issue.
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Tue Feb 26, 2019 3:19 pm
Reply with quote

I have successfully obtained a substring of the OETEVNM variable, it definitely does work.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Tue Feb 26, 2019 6:54 pm
Reply with quote

David Robinson wrote:
I have successfully obtained a substring of the OETEVNM variable, it definitely does work.


OETEVNM will be the value of file trigger name.

do you mean you are able to substr the file trigger name??

could you plz share the code here?

thank you very much!
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Tue Feb 26, 2019 6:55 pm
Reply with quote

David Robinson wrote:
I have successfully obtained a substring of the OETEVNM variable, it definitely does work.


and also plz share your substr result?
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Wed Feb 27, 2019 4:46 pm
Reply with quote

What problem are you now getting? And what is the point of sharing my SUBSTR result, it will clearly be different to yours as the trigger name is different.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Wed Feb 27, 2019 4:54 pm
Reply with quote

David Robinson wrote:
What problem are you now getting? And what is the point of sharing my SUBSTR result, it will clearly be different to yours as the trigger name is different.


the problem i am getting right now is i need to substr the trigger name in my JCL and give it to another newly created file as its file name.

could you plz show me? so i can use it in my JCL.

thank you very much
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Feb 27, 2019 7:38 pm
Reply with quote

The OPC statements are processed withi OPC before the job is submitted. The SET sttements is a JCL control statement and it is executed by the reader/interpreter after (or as) the job is submitted. Therefore OPC cannot substr the value set by the SET statement.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Thu Feb 28, 2019 6:40 am
Reply with quote

Nic Clouston wrote:
The OPC statements are processed withi OPC before the job is submitted. The SET sttements is a JCL control statement and it is executed by the reader/interpreter after (or as) the job is submitted. Therefore OPC cannot substr the value set by the SET statement.


thanks Nic!

is there any way i can substr OETEVNM(which is trigger file name) by using SETVAR? or any other way?
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Thu Feb 28, 2019 3:05 pm
Reply with quote

I'm not going to code it all for you. You have not adequately explained why you are trying to set a new TRIGNAM variable to the value of OETEVNM and then get the SUBSTR of that. Both myself and Nic have explained why that will not work.

As I have said previously, I have successfully obtained a SUBSTR of OETEVNM.

If you post what you have coded and explain how it's not working then I'm sure somebody will try and help.
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Thu Feb 28, 2019 3:34 pm
Reply with quote

David Robinson wrote:
I'm not going to code it all for you. You have not adequately explained why you are trying to set a new TRIGNAM variable to the value of OETEVNM and then get the SUBSTR of that. Both myself and Nic have explained why that will not work.

As I have said previously, I have successfully obtained a SUBSTR of OETEVNM.

If you post what you have coded and explain how it's not working then I'm sure somebody will try and help.


sorry for the inconvenience caused.

I am from a non-English-speaking country and my english is not so good, sometimes i tried to explain myself clearly but unfortunately am not able to do that, especially when it's complicated.

will explain as much clear and i can as possible later....need to rush to home
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> IBM Tools

 


Similar Topics
Topic Forum Replies
No new posts Using SETVAR in OPC Tivoli Workload S... JCL & VSAM 1
Search our Forums:

Back to Top