Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating large unstructured files using COBOL

269 views
Skip to first unread message

Guy Greenwood

unread,
Feb 10, 2014, 8:13:26 AM2/10/14
to
I need to write out large records (200KB) to an unstructured file using a COBOL program.
I have tried getting the program to create the file (the preferred method) but this failed with error 579 - The record size specified is too large for the given block size, file type and format.
I have also tried creating a file before running the program. This caused the program to abend with "environment corrupt".

Surely this can't be too difficult can it ??

Keith Dick

unread,
Feb 10, 2014, 8:33:07 AM2/10/14
to
Which COBOL compiler are you using? COBOL85, NMCOBOL, or ECOBOL?

Please post the SELECT and FD for the file.

Can't be too difficult? Maybe not, but remember you are working with a system that was created in the days of 16-bit architecture and when 64KB of memory was big. It has progressed beyond those limits since then, but some of the defaults are left over from those early days -- the curse of compatibility. One of the defaults may be what is causing the problem.

wbreidbach

unread,
Feb 10, 2014, 8:36:07 AM2/10/14
to
For an unstructured file there is no recsize parameter, recsize is only valid for structured files.
I am not sure about COBOL, but the largest possible write is 56K for unstructured access.

Guy Greenwood

unread,
Feb 10, 2014, 8:53:50 AM2/10/14
to
On Monday, February 10, 2014 1:33:07 PM UTC, Keith wrote:
> Guy Greenwood wrote:
>
> > I need to write out large records (200KB) to an unstructured file using a COBOL program.
>
> > I have tried getting the program to create the file (the preferred method) but this failed with error 579 - The record size specified is too large for the given block size, file type and format.
>
> > I have also tried creating a file before running the program. This caused the program to abend with "environment corrupt".
>
> >
>
> > Surely this can't be too difficult can it ??
>
>
>
> Which COBOL compiler are you using? COBOL85, NMCOBOL, or ECOBOL?
>
>

ECOBOL

>
> Please post the SELECT and FD for the file.
>

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT LOG-FILE ASSIGN TO #DYNAMIC
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
FILE-STATUS IS WS010-FILE-STATUS.

DATA DIVISION.

FILE SECTION.

FD LOG-FILE.

01 LOG-FILE-RECORD.
03 LOG-FILE-BUFFER PIC X(189000).


>
>
> Can't be too difficult? Maybe not, but remember you are working with a system that was created in the days of 16-bit architecture and when 64KB of memory was big. It has progressed beyond those limits since then, but some of the defaults are left over from those early days -- the curse of compatibility. One of the defaults may be what is causing the problem.


I've tried compiling on S series and COBOL85 gives an error due to the size of the record:

23 01 LOG-FILE-RECORD.
24 03 LOG-FILE-BUFFER PIC X(189000).
25

** Error 189 ** 01 or 77 level data item too large for section: LOG-FILE-RECO


Keith Dick

unread,
Feb 10, 2014, 9:52:34 AM2/10/14
to
I am pretty sure you will not be able to get COBOL to work with a record that long on a disk file directly. I'm pretty sure you could work with 200KB records on a file to another process, but then you would have to make the other process break up the write into smaller chunks to get it out to disk, so you would just have moved the problem, not solved it.

I think the most straightforward way to get your program to work is to write a COBOL subprogram that takes the large record as one of its arguments, and have the subprogram write the record in sections to the disk file. If that would involve changing the program in more places than you would like, then making this program write to another process and having that process do the writes to the disk might be better. If this or another COBOL program has to read the file, too, then you would have to do a similar thing for the reads -- either a subprogram or another process.

If the file is not already created with the BUFFERED attribute, adding that likely would improve the performance. BUFFERED has some potential for data loss if the CPU running the diskprocess crashes, but if you would recover by rerunning the program and creating the file over again from the beginning, that would not be a problem. But if you need not to lose any of the data in the file if the diskprocess crashes, don't use BUFFERED.

wbreidbach

unread,
Feb 10, 2014, 10:09:51 AM2/10/14
to
You should be able to write at least 32k at once. So you would need 6 write statements the write the whole record. If the file is unstructured, this does not matter.
COBOL has a very effective way to deal with sequential I/O, have a look at the RESERVE clause of the SELECT clause. This is usually much faster than setting the buffered attribute for the file.
Please regard that the file itself has to be unstructured!

Guy Greenwood

unread,
Feb 10, 2014, 10:45:14 AM2/10/14
to
OK so I am going to split it into multiple writes.

My problem now is that the file doesn't already exist so I was going to assign to #DYNAMIC and OPEN OUTPUT to create the file from the Cobol program. How do I specify that I want an unstructured file ???

Keith Dick

unread,
Feb 10, 2014, 11:33:46 AM2/10/14
to
If you are going to use #DYNAMIC, you will be using COBOL_ASSIGN_ to assign the actual filename. One of the arguments to COBOL_ASSIGN_ is file type, which you can use to select between unstructured and entry-sequenced. I don't know whether that will make the OPEN create an unstructured file, though. The manual's description of OPEN does not seem to cover that case. In any event, COBOL_ASSIGN_ does not allow you to specify extent sizes or number of extents. You could use the SMU routines to create the equivalent of a TACL ASSIGN for the file, but I still don't see anything that says COBOL will create the unstructured file you want. You might have to call CREATE or FILE_CREATE_ to do it, or create the file before starting your program.

I've not used COBOL in the OSS environment. Some of these problems might be bypassed if you could run your program in OSS. You wouldn't have to specify extent sizes or maxextents for OSS files. I don't know whether the record size for a disk file can be larger in OSS. I'd guess not, since it is basically the same COBOL product, but I might be wrong about that. If running is OSS would be a possibility for you, we could look into the manuals with that in mind.

Guy Greenwood

unread,
Feb 11, 2014, 4:55:12 AM2/11/14
to
Brilliant - that's just the job. Works like a dream.

Thanks to Keith and Wolfgang for your help.

Keith Dick

unread,
Feb 11, 2014, 5:18:00 AM2/11/14
to
You're welcome. What did you need to do to get the file created the way you wanted it?
0 new messages