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
 

 

dynamic handling of record length in a COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: dynamic handling of record length in a COBOL program
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    Post subject: Re: dynamic handling of record length in a COBOL program
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 2:21 am    Post subject: Re: dynamic handling of record length in a COBOL program
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    Post subject: Re: dynamic handling of record length in a COBOL program
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    Post subject:
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    Post subject: Re: dynamic handling of record length in a COBOL program
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: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 2:52 am    Post subject:
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

Moderator Team Head


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

PostPosted: Thu Jan 11, 2007 2:53 am    Post subject:
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    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 3:46 am    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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