Declare a file varibile length in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Declare a file varibile length in cobol

Postby cdavide1989 » Sun Apr 06, 2014 2:24 pm

I run a batch COBOL program BATCH sequential files of fixed length.
Since I only need one to run I was wondering it is possible to declare COBOL program in a file and from time to time decide the length of the record?
Same thing with the JCL.
Thanks
cdavide1989
 
Posts: 2
Joined: Sun Apr 06, 2014 2:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Declare a file varibile length in cobol

 

Re: Declare a file varibile length in cobol

Postby BillyBoyo » Sun Apr 06, 2014 4:35 pm

It is not really clear what you mean. Look at RECORD CONTAINS 0. If that is not what you want, please explain better with some examples.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Declare a file varibile length in cobol

Postby cdavide1989 » Sun Apr 06, 2014 6:06 pm

Thanks for the reply, I try to explain.
I have a program that accepts as input a parameter card and based on the value of the card I decide what file to use (each file has a different record lunquezza) I would like to declare a single file within the program and to vary its length records based on parameter to the card.
cdavide1989
 
Posts: 2
Joined: Sun Apr 06, 2014 2:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Declare a file varibile length in cobol

Postby Robert Sample » Sun Apr 06, 2014 6:24 pm

What you want to do CANNOT be done -- period. COBOL requires that the file record length be known at compile time; you are wanting to defer this determination until execution time, which cannot happen in COBOL. There are some ways to achieve the equivalent (such as writing an Assembler subprogram to handle the file operations), but using just COBOL your request is not possible.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Declare a file varibile length in cobol

Postby BillyBoyo » Sun Apr 06, 2014 7:11 pm

cdavide1989,

Should I assume that RECORD CONTAINS 0 didn't set you on your way? Define your maximum length for the 01 under the FD.

Define an 01 in the WORKING-STORAGE containing an OCCURS DEPENDING ON for the relevant record-length.

READ ... INTO your-WS-record.

I think it should give you have said you want.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post