Is PL/I an option at your shop?

________________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of 
Schmitt, Michael <michael.schm...@dxc.com>
Sent: Friday, April 28, 2023 4:29 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: COBOL to dynamic DD name

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

----------------------------------------------------------------------
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