Classification: Confidential

Same answer as my previous post. Open/close/read/write as needed.
Nothing here need to be dynamic.

Am I missing something?

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Schmitt, Michael
Sent: Friday, April 28, 2023 3:30 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: COBOL to dynamic DD name

[CAUTION: This Email is from outside the Organization. Unless you trust the 
sender, Don’t click links or open attachments as it may be a Phishing email, 
which can steal your Information and compromise your Computer.]

I have an input file that contains thousands of records. They are in groups: 
header record, then a bunch of segments all for one database name, then another 
header, records for another database. But the same database can appear more 
than once in the input.

The step takes this input and creates one output file per database, with one 
header. And resequences the records so they go 1,2,3,4, for each output DD.

On z/OS this step is done using File Manager, with this code:

if fld(1,2,B) = 0 then do           /* if sort key is 0 then      */
   header_rec = inrec               /*    save the header record  */
   return 'drop'                    /*    get next record         */
   end

dd_name = overlay('N', fld(9,8), 4) /* get DD name from DBD name  */

if recsout(dd_name) = 0 then do     /* if 1st record for database */
   outrec.dd_name = header_rec
   write(dd_name)                   /*    write the header        */
   drop outrec.dd_name
   end

ovly_out(recsout(dd_name), 5,4,B)   /* resequence the records     */
write(dd_name)                      /* write the segment record   */
return 'drop'


That's the ENTIRE program!


On my PC I have a COBOL program, with a lot more logic, that does essentially 
the same thing. As it is reading the input, each time it gets to a different 
database name, it closes the file it has been writing to and opens the file for 
the appropriate DD name, extending it. So the program only needs to have one 
output file defined, even though it is writing to different DDs as it goes.


Now we're trying to replace the File Manager step. If it was possible to do 
this in z/OS COBOL we could use it, but it isn't worth a large effort because 
it would be an interim solution anyway.


-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Tom 
Marchant
Sent: Friday, April 28, 2023 3:18 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: COBOL to dynamic DD name

I don't know any Cobol syntax that would change the DDNAME in a DCB, but you 
could call an assembler routine to change the DDNAME before OPEN. Why would you 
want to do that?

I'm a bit baffled. In z/OS and its ancestors, the data set name isn't 
determined until runtime, via JCL.

Perhaps if you describe the problem you are trying to solve.

--
Tom Marchant

On Fri, 28 Apr 2023 19:37:39 +0000, Schmitt, Michael <michael.schm...@dxc.com> 
wrote:

>I know how to have a COBOL program on z/OS use a data set name that isn't 
>determined until runtime, via an environment variable. My question is can you 
>use one file (i.e. one select/assign and one FD) to write to different DD 
>names, that were already allocated in the JCL?
>
>I can't find a way, and in the manual the syntax for the environment variable 
>method requires a DSN or PATH, no option for a DD name.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN




----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN
::DISCLAIMER::
________________________________
The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only. E-mail transmission is not guaranteed to be 
secure or error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or may contain viruses in transmission. 
The e mail and its contents (with or without referred errors) shall therefore 
not attach any liability on the originator or HCL or its affiliates. Views or 
opinions, if any, presented in this email are solely those of the author and 
may not necessarily reflect the views or opinions of HCL or its affiliates. Any 
form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of this message without the prior written 
consent of authorized representative of HCL is strictly prohibited. If you have 
received this email in error please delete it and notify the sender 
immediately. Before opening any email and/or attachments, please check them for 
viruses and other defects.
________________________________

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to