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

dynamic handling of record length in a COBOL program


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

New User


Joined: 06 Oct 2005
Posts: 12

PostPosted: Thu Jan 11, 2007 1:59 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jan 11, 2007 2:08 am
Reply with quote

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
View user's profile Send private message
jcbrowser

New User


Joined: 06 Oct 2005
Posts: 12

PostPosted: Thu Jan 11, 2007 2:14 am
Reply with quote

Via a parm from the JCL.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Jan 11, 2007 2:21 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jan 11, 2007 2:23 am
Reply with quote

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
View user's profile Send private message
jcbrowser

New User


Joined: 06 Oct 2005
Posts: 12

PostPosted: Thu Jan 11, 2007 2:35 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jan 11, 2007 2:44 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Jan 11, 2007 2:52 am
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Jan 11, 2007 2:53 am
Reply with quote

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
View user's profile Send private message
jcbrowser

New User


Joined: 06 Oct 2005
Posts: 12

PostPosted: Thu Jan 11, 2007 3:01 am
Reply with quote

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
View user's profile Send private message
jcbrowser

New User


Joined: 06 Oct 2005
Posts: 12

PostPosted: Thu Jan 11, 2007 3:16 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Jan 11, 2007 3:46 am
Reply with quote

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? icon_eek.gif icon_eek.gif I finally did and it is a response to you icon_eek.gif icon_eek.gif (with correction).....
Hey, superk, does your correction fix it????
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 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top