Reading dataset into a JCL variable



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

Reading dataset into a JCL variable

Postby harryseldon » Thu Jul 29, 2010 12:45 am

I have a script that needs to read the contents of a dataset into a JCL variable. The contents of the dataset will change with every run of the job. I've tried sourcing it in and setting it equal to the variable and Zeke scheduling variables but can't get either to work. Is there a simple way to get this data into a variable?
harryseldon
 
Posts: 15
Joined: Thu Jul 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading dataset into a JCL variable

Postby dick scherrer » Thu Jul 29, 2010 1:23 am

Hello and welcome to the forum,

Suggest you show an example of what you have and what you want done with it.

You cannot change already running jcl "on the fly".

What you can do is read the dataset, use it to modify/create the needed jcl, then submit the generated jcl thru the internal reader.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Reading dataset into a JCL variable

Postby harryseldon » Thu Jul 29, 2010 2:36 am

I don't have a good example I can copy in but I can explain the process better. We have start with a dataset that contains information for a vendor. The vendor requires a date/time stamp in the filename when it's uploaded to their server. They also require encryption. The dataset with vendor information is sent to Megacryption for encryption and the resulting filename is pushed into a dataset. We need to use this filename to transmit the file to the vendor. This wouldn't be generating JCL on the fly; rather, it would be reading in a static DSN containing variable data to be used later in the script. What I need is the equivalent of a cat statement in Unix: variable=`cat file_containing_dynamic_filename`
harryseldon
 
Posts: 15
Joined: Thu Jul 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading dataset into a JCL variable

Postby dick scherrer » Thu Jul 29, 2010 2:47 am

Hello,

It will help if you post the "script" that is being used to transmit the file. De-sensitize as necessary (i.e. ip-address, host, userid, etc).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Reading dataset into a JCL variable

Postby Robert Sample » Thu Jul 29, 2010 3:19 am

We use various utilities (SAS and File Aid mostly) to customize the file names in a PDS member where the FTP step of the job that runs after the customization step points to that file member.
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: Reading dataset into a JCL variable

Postby MrSpock » Thu Jul 29, 2010 8:15 am

Read the dataset and generate a JCL SET statement for the output:

// SET DSN='SOME.DATASET.NAME'

and write that into a member of a PDS, i.e. 'PROD.PARMLIB(JCLPARM)'

then use that PDS in the subsequent job (a JCLLIB statement may be necessary):

//JOBNAME JOB (.....
//*
// JCLLIB ORDER=PROD.PARMLIB <= maybe
// INCLUDE MEMBER=JCLPARM
//*
...

INCLUDE STATEMENT.

JCLLIB STATEMENT.

SET STATEMENT.
Now you can properly use the variable &DSN anywhere in that job.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: Reading dataset into a JCL variable

Postby steve-myers » Thu Jul 29, 2010 9:38 am

JCL is fully expanded before the job actually starts. I get the sense that what harryseldon really wants is to resolve the data set name while the job is executing. This is not a JCL issue, because the JCL for the job has been fixed and cannot be altered. This is a dynamic allocation issue. There are several ways to handle this; the most popular is a function called BPXWDYN. BPXWDYN takes a character string that is similar to, though not identical to, the TSO ALLOCATE or FREE commands. The documentation for BPXWDYN is available in IBM documentation, though it is very hard to find, and I have found it to be incomplete at times.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Reading dataset into a JCL variable

Postby Schubie » Thu Jul 29, 2010 10:52 am

DYNALLOC (SVC99) can be used to allocate the output dataset with a name constructed by the program as opposed to hard coded in the JCL. Once the DYNALLOC is issued and a successful return is received, the dataset can then be OPENed, PUT to and CLOSEd. Deallocation will take place at the end of step automatically or accomplished using the SVC99 again. DYNALLOC is documented in the Authorized Assembler Services Guide. An online overview with links to the relevant information can be found at http://publib.boulder.ibm.com/infocente ... ynrtcd.htm
It's not too tricky but don't try to get overly creative.
If a bug is located in a program product which simply cannot be fixed, it becomes a 'feature'. (IBM)
User avatar
Schubie
 
Posts: 10
Joined: Wed Jul 21, 2010 9:16 am
Location: Blue Ridge, GA USA
Has thanked: 0 time
Been thanked: 0 time

Re: Reading dataset into a JCL variable

Postby steve-myers » Thu Jul 29, 2010 4:18 pm

Schubie's discussion about dynamic allocation is valuable, but it requires Assembler knowledge to use it. This is why I discussed BPXWDYN, which is readily available to high level or some ways Rexx can be used.
There are a few JCL constructions, such as relative generations, that are best avoided in dynamic allocation (including BPXWDYN), and some tape related combinations that can't be done at all. For example, JCL like this -
//SORTIN   DD  DISP=SHR,UNIT=(,2),DSN=a-multi-volume-tape-dataset
//SORTOUT  DD  DISP=(,CATLG),UNIT=AFF=SORTIN,DSN=a-new-sorted-dataset
can not be done in dynamic allocation. The SORTIN DD statement can be done in dynamic allocation, but the UNIT=AFF business in the SORTOUT DD statement to use the same drives as were uses by the SORTIN DD statement cannot be done in dynamic allocation. There are other tape related, though uncommon, things you can do in JCL that can't be done in dynamic allocation, though a clever Assembler programmer can replicate them.

Now I've been doing MVS dynamic allocation for more than 30 years, so it doesn't scare me, but most people (and organizations) are terribly afraid of Assembler, so it can't be used much of the time.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post