View previous topic :: View next topic
|
Author |
Message |
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
In general, more like once you create it, then open it and, yes, just write....
And, by the way, welcome back..... |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 (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 |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 |
|
|
zensa
New User
Joined: 21 Feb 2007 Posts: 10 Location: India
|
|
|
|
We wish to hear the solution from you with examples. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 |
|
|
|