IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamic Allocation of Output Files of Unknown Record Lengths


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
stevedsmith

New User


Joined: 22 Dec 2010
Posts: 3
Location: Baltimore, Maryland, USA

PostPosted: Thu Jul 12, 2012 11:27 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 13, 2012 12:23 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 13, 2012 12:59 am
Reply with quote

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
View user's profile Send private message
stevedsmith

New User


Joined: 22 Dec 2010
Posts: 3
Location: Baltimore, Maryland, USA

PostPosted: Fri Jul 13, 2012 1:07 am
Reply with quote

Dick, what would generate the JCL? another Cobol program?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 13, 2012 1:22 am
Reply with quote

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 icon_smile.gif

d
Back to top
View user's profile Send private message
stevedsmith

New User


Joined: 22 Dec 2010
Posts: 3
Location: Baltimore, Maryland, USA

PostPosted: Fri Jul 13, 2012 1:25 am
Reply with quote

Thanks much for your comments and for the warm welcome to the forum.

Steve
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 13, 2012 1:26 am
Reply with quote

You're welcome - good luck icon_smile.gif

Someone will be here if there are questions.

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top