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
 

 

Cobol dynamic file creation and write to the file?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Mon Apr 02, 2007 5:25 am    Post subject: Cobol dynamic file creation and write to the file?
Reply with quote

Ok. I've seen all sorts of posts on creating files dynamically via cobol when the lrecl isn't known until runtime. What I don't see in any of those examples is the same program then writing to that file.

Do you just write to the file after creating it via one of the tools mentioned? Anyone got a code sample that does the creation and writing in the same cobol program?
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Apr 02, 2007 5:31 am    Post subject:
Reply with quote

In general, more like once you create it, then open it and, yes, just write....

And, by the way, welcome back..... icon_wink.gif
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Mon Apr 02, 2007 5:39 am    Post subject:
Reply with quote

Thanks.

I mean how does the cobol program work with the output recl not being known until runtime?

On the input coding 'record contains 0' and reading to a variable like
[code]
READ INPUT-FILE INTO WS-INPUT-REC(1:WS-LRECL)
[\code]
works fine if you move the proper lrecl to ws-lrecl but you can't code 'record contains 0' for an output file.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Apr 02, 2007 5:52 am    Post subject:
Reply with quote

jasorn wrote:
READ INPUT-FILE INTO WS-INPUT-REC(1:WS-LRECL)
works fine if you move the proper lrecl to ws-lrecl but you can't code 'record contains 0' for an output file.
As long as you do not specify beyond the actual length of the input record, all things are good.
I wouldn't use the above statement, but that's me.....
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Mon Apr 02, 2007 6:07 am    Post subject:
Reply with quote

William Thompson wrote:
jasorn wrote:
READ INPUT-FILE INTO WS-INPUT-REC(1:WS-LRECL)
works fine if you move the proper lrecl to ws-lrecl but you can't code 'record contains 0' for an output file.
As long as you do not specify beyond the actual length of the input record, all things are good.
I wouldn't use the above statement, but that's me.....


Think I got one of us confused icon_smile.gif(me, most likely) What I meant to say is I am able to read FB files without knowing the lrecl until runtime by using the combination of 'record contains 0' on the fd statement, coding an 01 level on the fd statement that's longer than any of the lrecls I'd be reading, and using (1:ws-lrecl) on the read statement.

But, I can't figure out how to accomplish the task of writing out an FB dataset when I don't know the lrecl until runtime.

The question I was asking was will using one of those tools to create the file override the length of the record in the fd statement.

Anyway, I'll try it now and post if I get errors.
----------------------------------------------------
As for not using the above statement on the input side:
What I do with it is read a list of dataset names and lrecls of datasets with different lrecls. Then I read each one and process the file. I found no other way to do this in cobol. All of the other ways I've seen to do this involve creating an FD for each possible lrecl.

If you know of another way, I'd be interested in seeing it.
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Tue Apr 03, 2007 12:33 pm    Post subject:
Reply with quote

The best I came up with was creating the file with dcb information I didn't ultimately want and then copying the file when I was finished with the attributes specific to the particular dataset.

Since my goal was to create a process that was cobol(or standard apps called from cobol) and could process different length files with one input ddname, I'll count this as a triple. I'll come back and post the solution from beginning to end as an example in case anyone wants to see it.
Back to top
View user's profile Send private message
zensa

New User


Joined: 21 Feb 2007
Posts: 10
Location: India

PostPosted: Wed Apr 11, 2007 3:44 pm    Post subject:
Reply with quote

We wish to hear the solution from you with examples.
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Wed Apr 11, 2007 4:01 pm    Post subject:
Reply with quote

OK. I'll try to post it tonight if I get home early enough. Nothing I didn't get from this forum. Maybe seeing it all together would help though.
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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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