Re: variable length records under fujitsu cobol (COBOL.NET)



ari wrote:
> I have created a small test COBOL program to produce a variable length
> file in Fujitsi Cobol.NET.
>
> I wanted to see how are the records stored. I was expecting to see
> each record with leading 2 or 4 byte field holding the record length.
> I was astonished to find the record had BOTH leading AND trailing 4
> byte field holding the record length.
>
> Here is my program:
>
> 000010 IDENTIFICATION DIVISION.
> 000020
> 000030 PROGRAM-ID. Program1 AS "aritest.Program1".
> 000040
> 000050*=================================================================
> 000060
> 000070 ENVIRONMENT DIVISION.
> 000080
> CONFIGURATION SECTION.
> 000090 INPUT-OUTPUT SECTION.
> 000100
> 000110 FILE-CONTROL.
> 000120
> 000130 SELECT TEST-FILEV
> 000150 ORGANIZATION SEQUENTIAL
> ASSIGN TO MYFILEV.
>
> 000160
> 000170
> 000180
> 000190 DATA DIVISION.
> 000200
> 000210 FILE SECTION.
> 000220
> 000360
> 000230 FD TEST-FILEV
> 000240
> 000250 LABEL RECORDS STANDARD
> 000260
> 000270 RECORDING MODE V
> 000290 BLOCK CONTAINS 0.
> 000300
> 000310 01 TST-RECV.
> 05 VAR-TXT.
> 10 PIC X OCCURS 0 TO 100 DEPENDING ON VAR-LEN.
> 000320
> 000360
> 000370 WORKING-STORAGE SECTION.
> 000380 01 VAR-LEN PIC 9(2) COMP.
> 000390 01 KUKU PIC X(10).
> 01 DISP-NUM PIC 9(4).
> 01 II PIC S9(4) COMP.
> 000400
>
>
> 000430 PROCEDURE DIVISION.
> 000440
> 000450**************************************************************
> 000460
> 000470 A-PROGRAM-CONTROL SECTION.
> 000480
> 000490*----------------------------------------------------------------
> 000500
> 000510 DISPLAY "TEST PROGRAM COMMENCING".
> 000520
> 000580
> 000610 OPEN OUTPUT TEST-FILEV.
> MOVE 5 TO VAR-LEN
> MOVE 'ABCDEF' TO VAR-TXT
> WRITE TST-RECV.
> SUBTRACT 1 FROM VAR-LEN.
> WRITE TST-RECV.
> 000690 CLOSE TEST-FILEV.
>
> 000710 END PROGRAM Program1.
> 000720
> 000730
>
> Here is a dump of the output file:
>
> 0000000 005 000 000 000 101 102 103 104 105 005 000 000 000 004 000
> 000 005 \0 \0 \0 A B C D E 005 \0 \0 \0 004
> \0 \0 0000020 000 101 102 103 104 004 000 000 000
> \0 A B C D 004 \0 \0 \0
> 0000031
>
>
> (I use an equivalent of the unix dump program, od -b -c)
>
> Is there any way I can get rid of those trailing record lengths? They
> are a real problem.

=======
Assuming you don't ever want to OPEN REVERSED (which is probably the reason
the record/block lengths are appended), one way would be to emulate the
variable record logic manually. We do that with large files.

What's the nature of the problem? (Ours is the need to access the file
randomly).


.