View previous topic :: View next topic
|
Author |
Message |
stevedsmith
New User
Joined: 22 Dec 2010 Posts: 3 Location: Baltimore, Maryland, USA
|
|
|
|
My project has me develop a batch Cobol/DB2 program to dynamically create multiple output files each of different fixed length (RECFM=FB) at runtime. All the records in one file will have the same lrecl but the lrecls of the different fixed length files can be different (ranging from 130 to 9999) depending on which customer is to receive the file. The lrecl, and other file attributes, for each file is taken from a DB2 database table at runtime, so the lrecl is not known at compile time. So far, I have been able to make this work with variable length files by defining one FD statement in my program that has RECORD IS VARYING clause and which has one DD name that is reused for all files because each file is processed seperately and freed before processing the next file. I have access to an in-house Assembler module that dynamically allocates files at runtime. So dynamically creating output files all of the same fixed length is no problem. And dynamically creating output files each of different variable lengths is no problem. But dynamically creating output files each of different fixed length is the problem as the lrecl is not known until run time. I have researched the IBM ENTERPRISE COBOL FOR Z/OS 4.2.0 User Guide, IBM ENTERPRISE COBOL FOR Z/OS 4.2.0 Reference Manual and this forum and it looks like this can only be done with variable length records (RECFM=VB,LRECL=10003 (9999 plus 4 bytes added for the RDW)) instead of with fixed length records (RECFM=FB,LRECL=nnnn (where nnnn is actual fixed length lrecl). Can this be done with fixed length records without defining separate FDs for each file? How?
StevedSmith |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The only way to do what you want is to use an assembler module. A COBOL program must have the file record length known at compile time, period. For a fixed length file, you cannot use COBOL I/O statements unless you know the record length when you compile the program |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One alternative would be to define the "output" file with an lrecl longer than anything anticipated. Write to this "fixed length" file the data for "the customer" with trailing spaces.
Then, using the info from the database generate the jcl to copy the "output" to the new lrecl for that customer.
Rather easy to do and no need for more assembler (unless your organization wants to continue using assembler - many do not). |
|
Back to top |
|
|
stevedsmith
New User
Joined: 22 Dec 2010 Posts: 3 Location: Baltimore, Maryland, USA
|
|
|
|
Dick, what would generate the JCL? another Cobol program? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Steve,
Could be done w/ COBOL. As you want to access the database to get the parameters for the output file, i believe using COBOL to generate the sort step would be rather straight forward.
Oh, yeah - welcome to the forum
d |
|
Back to top |
|
|
stevedsmith
New User
Joined: 22 Dec 2010 Posts: 3 Location: Baltimore, Maryland, USA
|
|
|
|
Thanks much for your comments and for the warm welcome to the forum.
Steve |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
Someone will be here if there are questions.
d |
|
Back to top |
|
|
|