To all the repliers, thanks for your ideas. I think the answer is that there's no *simple* way to do what I asked in COBOL. Most replies were to suggest other ways to do it, but they were not what I wanted.*
I've run a test of reading a file where the DD name is determined at runtime. This works: 1. The select/assign is to a dummy DD name. 2. The program does a DYNALLOC call to determine the DSN for the actual target DD name, i.e. it is finding how it was allocated in the JCL. I'm using a different DYNALLOC interface than BPXWDYN but the concept is the same. 3. The program uses the environment variable trick to assign the DSN determined in step #2 to the dummy DD name. 4. Open and read. I think this will work for writing with a disp of MOD. * the key here is I'm trying to do in z/OS what I can easily do in not-ZOS. So I don't want a different language, or 100 files in the program, or assembler assists, etc. -----Original Message----- From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Schmitt, Michael Sent: Friday, April 28, 2023 2:38 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: COBOL to dynamic DD name 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