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

Cobol dynamic file creation and write to the file?


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

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Mon Apr 02, 2007 5:25 am
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: 3156
Location: Tucson AZ

PostPosted: Mon Apr 02, 2007 5:31 am
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Mon Apr 02, 2007 5:39 am
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: 3156
Location: Tucson AZ

PostPosted: Mon Apr 02, 2007 5:52 am
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Mon Apr 02, 2007 6:07 am
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Tue Apr 03, 2007 12:33 pm
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
Reply with quote

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

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Wed Apr 11, 2007 4:01 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top