Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic Allocation of Output Files of Unknown Record Lengths

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Dynamic Allocation of Output Files of Unknown Record Lengths
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: 8118
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jul 13, 2012 12:23 am    Post subject:
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

Site Director


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

PostPosted: Fri Jul 13, 2012 12:59 am    Post subject:
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    Post subject: Reply to: Dynamic Allocation of Output Files of Unknown Reco
Reply with quote

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

Site Director


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

PostPosted: Fri Jul 13, 2012 1:22 am    Post subject: Reply to: Dynamic Allocation of Output Files of Unknown Reco
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    Post subject: Reply to: Dynamic Allocation of Output Files of Unknown Reco
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

Site Director


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

PostPosted: Fri Jul 13, 2012 1:26 am    Post subject: Reply to: Dynamic Allocation of Output Files of Unknown Reco
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts JES2 doesn't honor the priority of th... Aron Lendvai JCL & VSAM 7 Thu Jun 29, 2017 1:41 pm
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us