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

[Solved]Including a VARIABLE Qualifier in a File


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Sat Mar 12, 2005 3:50 am
Reply with quote

Hi there,

This is Anran. I am working as a mainframe developer. I am working on some JCL stuff and have some problem with figuring out how to include a variable qualifier in my file name.

I need to take the rundate that is a parm from user's input and based on the rundate to determine what backup version of my library I can use.

For example.

if rundate is on or after 20050101, then I'll use. XX.LOAD.VERSION1
if rundate is between 20040101 and 20050101, then I'll use XX.LOAD.VERSION2,

I want to add a step to determine if VERSION1 or VERSION2 and then it could automatically fill in my libary in the next step. Is it possible or not???

Any thought would be great appriciated!!

Thanks

Anran
Back to top
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 237
Location: USA

PostPosted: Sat Mar 12, 2005 10:58 am
Reply with quote

Hi Anran,

There are 3 ways to do it:

1) Code REXX to create a JCL step and submit it
2) Create 2 steps with different STEPLIBS. Chek the date with IF ELSE and direct the processing to either of the step
3) Use symbolic parameter overriding for STEPLIB

Hope this helps

Regards
Mayuresh
Back to top
View user's profile Send private message
kingofmf

New User


Joined: 02 Mar 2005
Posts: 13
Location: Bangalore

PostPosted: Sat Mar 12, 2005 2:02 pm
Reply with quote

your Q is not clear,you are rceiving input date from user,obviously it should be in your cobol program ,assuming this i am giving one solution-

define one symbolic parameter VAR with no value,ie VAR=
now pass the reference to cobol like this PARM='&VAR'
now depending on the user input date set value of this (in linkage section)
as VERSON1 or VERSON2 ,this automatically set the value in VAR in your JCL, now give DSN=XX.LOAD..&VAR,

if you want to pass the date from jcl you have to code another Symbolic parameter DATE=20050101 and move this to cobol along with VAR through like this PARM='&DATE&VAR'
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Sat Mar 12, 2005 9:35 pm
Reply with quote

Hi, Mayuresh and Kingsuk,

I want to say thanks to both of you for your answers. I am using PL/I, not Cobol, but I know the logic should be the same.

I would like to declare a variable VAR as Kingsuk suggested and write a little PL/I program and return the value of VAR back from the program and give DSN=XX.LOAD..&VAR. If it could work, that would be wonderful!!

One more question, if I also want to fill &VAR in a new dataset name in the next step. I mean DSN=XX.SHARE..&VAR will be NEW, not SHR, it should work or not??

Thanks a lot!!!

Anran
________________
Canada
Back to top
View user's profile Send private message
Prandip

New User


Joined: 04 Mar 2005
Posts: 84
Location: In my tiny cubicle ...

PostPosted: Sun Mar 13, 2005 5:44 am
Reply with quote

How about you have your PL/I program determine the value of the input variable, and then set the return-code to one of two different values, depending on the value of the variable.

Then, in the job, check for the value of the return-code, and take the appropriate course of action:
Code:

//MYSTEP EXEC PGM=MYPROG
//*
// IF (MYSTEP.RC = 1) THEN
//NEXT#1 EXEC PGM=NEXTPROG
//MYLIB DD DSN=XX.LOAD.VERSION1
// ELSE IF (MYSTEP.RC =2) THEN
//NEXT#2 EXEC PGM=NEXTPROG
//MYLIB DD DSN=XX.LOAD.VERSION2
// ELSE
//NEXT#3 EXEC PGM=OTHER
// ENDIF
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Sun Mar 13, 2005 8:40 pm
Reply with quote

Hi, Prandip

Thank you very much for your reply. I got some ideas from all of your guys' answers. I'll try to see if I could solve my problem.

Have a great day!!

Anran
Back to top
View user's profile Send private message
Prandip

New User


Joined: 04 Mar 2005
Posts: 84
Location: In my tiny cubicle ...

PostPosted: Sun Mar 13, 2005 9:28 pm
Reply with quote

kingofmf, there is no possible way that your proposed solution can work. Any value that you set to a variable in the JCL, i.e.:
Code:

// SET VAR=

remains the same throughout the entire JCL execution, as all variables are resoved during the scan phase on the Internal Reader. There is nothing within a job stream that can change this. Programs cannot pass parameter information BACK into the executing JCL stream.

I for one would like to see a sample of code (JCL and COBOL) that would prove me wrong.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Mar 14, 2005 12:13 am
Reply with quote

Hi Prandip,

Kingsuk has presented this technique in another thread. I think that it might work (I plan to test it Monday) if you use the &VAR solely as a PARM in another step. I say this because the &VAR value is probably stored in memory somewhere and its address is made available to the pgm via the USING stmt.

You are correct that it can't work when used as a JCL parameter. The total of the JOB JCL is interpreted before the 1st jobstep execution is begun, so it's too late to use it in a DD stmt or some such.
Another caution, that while the technique is clever and can be useful (I intend to use it if my test works), IBM has been known to close these kinds of loopholes without notice. Their resoning? They never told you to use it. So I intend to use it only for "personal" pgms; utils and such.
Back to top
View user's profile Send private message
kingofmf

New User


Joined: 02 Mar 2005
Posts: 13
Location: Bangalore

PostPosted: Mon Mar 14, 2005 12:22 pm
Reply with quote

I am very new to mainframe,i am a 2004 passed out graduate,now i am doing one a mainframe training for the last three months only , what answer i have given base on my thoughts and concept, becoz i think the forum is for sharing our knowledge as well as thoughts,
May be i should have test it before posting it, I will also try it in the lab if it will work or not, if it is a wrong answer then i apologize to all members for this inconvenience.
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Mon Mar 14, 2005 10:15 pm
Reply with quote

Hi, Guys,

Thanks so much for bringing up your thoughts in here. I really appreciate your helps. Can I code something in my JCL like

Code:

/ * I can easily get the rundate from the user's input  */
//  IF %RUNDATE >20050101 THEN
//  SET LOADLIB=XX.LOAD.VERSION1
//  ELSE  IF %RUNDATE >20040101 & %RUNDATE <= 20050101 THEN   
//  SET LOADLIB=XX.LOAD.VERSION1

//MYLIB  DD DISP=SHR,
//           DSN=&LOADLIB


I would like to create some dynamical dataset with the version1 or version 2 in the name convention as well. I think it would be harder than the load library.

Jack, can you let me know what you got form your testing if you have done it???

Thanks a lot!!

Anran
Back to top
View user's profile Send private message
Prandip

New User


Joined: 04 Mar 2005
Posts: 84
Location: In my tiny cubicle ...

PostPosted: Tue Mar 15, 2005 12:51 am
Reply with quote

Anran, these lines in your code:

IF %RUNDATE >20050101 THEN
SET LOADLIB=XX.LOAD.VERSION1
ELSE IF %RUNDATE >20040101 & %RUNDATE <= 20050101 THEN
SET LOADLIB=XX.LOAD.VERSION1

have to represent program logic that has to be done in a program. The output from your program COULD be either a member of a PARMLIB dataset with the SET statement:

// SET LOADLIB=XX.LOAD.VERSION1

that can be used in a subsequent job by using an INCLUDE statement, or, your program could just create the entire job with the appropriate LOADLIB statements already specified.

Now, everyone repeat after me: JCL is NOT a programming language. JCL is NOT a programming language. JCL is NOT a programming language...
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Tue Mar 15, 2005 5:41 am
Reply with quote

Thanks Prandip. Yes, you are right, JCL is not a programming language, but IF statement can be used in JCL. I can write a liitle program to do it, but I am not quite ure how to take the output (eg: version) to pass it along through my JCL. ..........Anran
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Wed Mar 16, 2005 12:21 am
Reply with quote

Hi, guys

I GOT IT!! Thanks everybody for your help!!!

I want to say thank you to Prandip. Actually your idea worked out my problem. THANKS A LOT!!!


Anran
Back to top
View user's profile Send private message
brahmanandareddy

New User


Joined: 16 Dec 2004
Posts: 44
Location: Hyderabad

PostPosted: Wed Mar 16, 2005 2:36 pm
Reply with quote

Hi Anran,

If u got the correct answer (did u test it?) why dont u post it here in the forum so that we can gain from it.

Thank You,
Brahmananda Reddy. K.
Back to top
View user's profile Send private message
Anran

New User


Joined: 12 Mar 2005
Posts: 14

PostPosted: Wed Mar 16, 2005 11:45 pm
Reply with quote

Yes, I tested it.

Code:

//*            -----------------------------------------               
//*            DETERMINE THE VERSION
//*            --------------------------------------------               
//CHEVER  EXEC PGM=MYPRGM                                             
//PARM DD *                                                         
%RUNDATE                                                               
/*                                                                     
//STEPLIB  DD  DSN=XXTEST.LOAD,DISP=SHR         
//SYSPRINT DD  SYSOUT=D                                                 
//*                                                                     
//*            -----------------------------------------               
//*            CREATE THE FILE                               
//*            -----------------------------------------               
//*                                                                     
// IF CHEVER.RC = 1  THEN                                               
// SET VAR='XX.DATA.VERSION1'     
// ELSE IF  CHEVER.RC = 2  THEN                                         
// SET VAR='XX.DATA.VERSION2'
// ENDIF
//*     
//SORT  EXEC PGM=SORT                                   
//SYSOUT   DD  SYSOUT=*                                   
//SORTIN   DD  DSN=XX.DATA.INPUT,
//             DISP=SHR                                   
//SORTOUT  DD  DSN=&VAR.,         
//             DISP=(,CATLG),                             
//             UNIT=DISK,SPACE=(80,(3,1),RLSE),         
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=)     



Anran
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Mar 17, 2005 1:50 am
Reply with quote

On my system (z/OS 1.4, JES2) it ALWAYS sets to VERSION2.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts how to eliminate null indicator value... DB2 7
No new posts CA7 count with DATE variable CA Products 0
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
Search our Forums:

Back to Top