> CLOSE will cause that DD to be ... taken out of the TIOT

I didn't know that!

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of John McKown
Sent: Wednesday, June 7, 2017 12:11 PM
To: [email protected]
Subject: Re: What Happens with Duplicate DD Cards in JCL?

On Wed, Jun 7, 2017 at 1:54 PM, George Rodriguez < 
[email protected]> wrote:

> I have this programmer that coded the following DD cards in JCL. I'm 
> not 100% sure what z/OS v1.13 does with the first DD card for a KSDS 
> VSAM file, but I think it gets replaced by the second. Here is an example of 
> the JCL:
>
> //PRTOUT    DD   SYSOUT=X
> //* VSAM FILES
> //PBGDD     DD   DSN=TM#TEST.FILE
> //PBSF1     DD   DSN=TM#PROD.FILE
> //PBSF1     DD   DSN=TM#TEST.FILE
>
> My thought, second PBSF1 (test file) replaces PBSF1 (production file).
>

​What happens is that the TIOT (internal representation of the DD statements 
for the step) will contain _both_ entries. The TIOT is a sequential list of 
entries. OPEN will search the TIOT from top to bottom looking for the requested 
DD name. It will therefore find the first
(production) one. You can use this for some really strange effects.
Consider the following:

//INPUT DD DSN=some.dsn,DISP=SHR,FREE=CLOSE //INPUT DD 
DSN=another.dsn,DISP=SHR,FREE=CLOSE


Now suppose the program does something like (pseudo code of course):

OPEN INPUT
...
CLOSE INPUT
OPEN INPUT
...
CLOSE INPUT
RETURN

The first OPEN INPUT will have the program access "some.dsn". The first CLOSE 
will cause that DD to be dynamically freed & taken out of the TIOT.
So the second OPEN INPUT will access "another.dsn". After the second CLOSE 
INPUT, the second TIOT entry will be released. So a 3rd OPEN INPUT would get 
"DD statement INPUT not found".

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to