View previous topic :: View next topic
|
Author |
Message |
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
Can I write a COBOL program that writes to a file where the record length is passed via the linkage section?
I would like to write a program that I don't have to hard code the record length.
Is this possible on an IBM mainframe platform. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Hello jcbrowser,
I think the answer to your question is yes. But how are you going to be able to write a record without knowing the length? How are you going to get the value through the linkage section? Is this program a called subroutine from a main program, or are you going to get the length via the PARM= |
|
Back to top |
|
|
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
Via a parm from the JCL. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
jcbrowser wrote: |
Can I write a COBOL program that writes to a file where the record length is passed via the linkage section?
I would like to write a program that I don't have to hard code the record length.
Is this possible on an IBM mainframe platform. |
If you want to be able to output records without concern for lrecl and recfm, yes, your COBOL program can, BUT, the actual I/O will (probably) need to be done outside of the COBOL program. You will need an assembler (or other suitable) program that can dynamically create and modify the control blocks. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
jcbrowser,
I see no reason this would not work. Is the size of the record going to vary? I'm having trouble visualizing why getting the record size from an external source would be better. Help me out on this. |
|
Back to top |
|
|
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
Dave,
Our system creates multiple files out of different jobs that may be empty. The idea is to have one program that can open the file and write a blank record to it.
These files are created in different jobs with different record lengths and are passed to other systems that can't handle an empty file.
We don't wan't to have to create multiple dummy files so I need a program or utility that can accomplish this. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
jcbrowser,
If you are going to write a generic 'blank' record to the file, how well is the receiving program, (the one that reads that file with the blank record) going to handle a record that does not conform to the specific file layout? I would expect unexpected/undesirable results to occur. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Ok the file exists, but has no records, right?
Was the file actually opened by an application or just allocated via JCL?
I'm thinking that if it was actually opened, its atributes would exist.
Doesn't DFSORT get those attributes if not provided by control cards or JCL?
Can't the sort output a record with padding/fill. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
William Thompson wrote: |
Doesn't DFSORT get those attributes if not provided by control cards or JCL?
Can't the sort output a record with padding/fill. |
I've already provided such a solution with DFSORT in another post.
I would also think that a simple REXX exec would be an easy-to-implement alternative (depending on the structure of these datasets). |
|
Back to top |
|
|
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
Dave,
The requirements have not been finalized on the receiving systems but they will be expecting either a record with spaces or low values.
They have stated that they will be able to handle a file with at leaset one record (blanks or low values - TBD).
For some reason, which I don't know at the moment, they can't handle and empty file. |
|
Back to top |
|
|
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
William Thompson,
Do you have an example of DFSORT to accomplish this?
Keep in mind that this step will have to be added to a proc.
The record length can be passed to the proc if needed, but the control card would have to be the same regardless of the input file. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
jcbrowser wrote: |
Do you have an example of DFSORT to accomplish this? |
Sorry, no. I was trying to recall some things I had read in the DFSORT forum, things Frank (the DFSORT guru) had mentioned, and knowing my memory, I may be wrong. But, recall that
superk wrote: |
William Thompson wrote: |
Doesn't DFSORT get those attributes if not provided by control cards or JCL?
Can't the sort output a record with padding/fill. |
I've already provided such a solution with DFSORT in another post. |
Have you looked there? I finally did and it is a response to you (with correction).....
Hey, superk, does your correction fix it???? |
|
Back to top |
|
|
|