VLR
The VLR
option affects the file status
returned from READ
statements for variable-length
records when the length of record returned is inconsistent with the
record descriptions. It eases your migration from earlier versions
to Enterprise COBOL V6, if your programs have READ
statements
that result in a record length conflict.
- Default
VLR=STANDARD
READ
statement:- If the number of character positions in the record that is read is less than the minimum size specified by the record description entries for the file, the portion of the record area that is to the right of the last valid character read is undefined.
- If the number of character positions in the record that is read is greater than the maximum size specified by the record description entries for the file, the record is truncated on the right to the maximum size.
In either of these cases, the READ
statement is successful, and the file status
is set to either 00
(with VLR=COMPAT
set,
hiding the record length conflict condition) or 04
(with
VLR=STANDARD
set, indicating that a record length conflict has occurred).
- COMPAT
VLR=COMPAT
checks the size of the read record against the "VARYING IN SIZE FROM min TO max" declaration of the FD clause. If you specifyVLR=COMPAT
, you get the status value of00
whenREAD
statements encounter a record length conflict.- STANDARD
- Important: You must add code to each READ statement to use
VLR=STANDARD
for testing file status.VLR=STANDARD
checks the size of the read record against the declaration of the FD level 01 clause. If you specifyVLR=STANDARD
, you get the status value of04
whenREAD
statements encounter a record length conflict.
VLR
option checks the size of
the read record against the declaration of the FD clause and FD level 01 clause,
with Table 1 below illustrating the resulting file status (FS)
of various lengths of records read. In this case a record read is a series of
strings.* The file contains two record definitions:
* REC-20: up to 20 characters
* REC-50: up to 50 characters
* The file must contain between 10 to 80 characters in total.
FD MYDD
block contains 0 records
record varying in size from 10 to 80
recording mode V.
01 REC-20
02 PIC X(20).
01 REC-50.
02 PIC X(50).
Length of record read | 5 | 15 | 40 | 70 | 85 |
---|---|---|---|---|---|
>= min varying (10) | ✘ | ✔ | ✔ | ✔ | ✔ |
<= max varying (80) | ✔ | ✔ | ✔ | ✔ | ✘ |
>= min level 01 (20) | ✘ | ✘ | ✔ | ✔ | ✔ |
<= max level 01 (50) | ✔ | ✔ | ✔ | ✘ | ✘ |
Valid data? | ✘ | ✘ | ✔ | ✘ | ✘ |
COBOL V4 | FS=04 ✘ | FS=00 ✔ | FS=00 ✔ | FS=00 ✔ | FS=00 ✔ |
COBOL V6
VLR(COMPAT) |
FS=04 ✘ | FS=00 ✔ | FS=00 ✔ | FS=00 ✔ | FS=00 ✔ |
COBOL V6
VLR(STANDARD) |
FS=04 ✘ | FS=04 ✘ | FS=00 ✔ | FS=04 ✘ | FS=04 ✘ |
Notes:
|
- A record length of 5 is represented as
follows:
[A][B][C][D][E][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?] |<---- 5 ---->|<------------- Undefined (15) ------------->|
The record length of 5 is less than the min varying 10 and less than the min level 01 of 20, so the record is invalid (✘) in any COBOL compiler version.
- A record length of 15 is represented as
follows:
[A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][?][?][?][?][?] |<------------------ 15 ------------------->|<Undefined(5)>|
The record length of 15 is larger than the min varying 10 and less than the min level 01 of 20, so the record is invalid (✘) under COBOL 6
VLR=STANDARD
. - A record length of 40 is represented as
follows:
[A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T] [U][V][W][X][Y][Z][1][2][3][4][5][6][7][8][9][0][1][2][3][4] |<------------------------ 40 ---------------------------->|
The record length of 40 is within the varying range 10-80 and meets the level 01 requirements, so the record is valid (✔).
- A record length of 70 is represented as
follows:
[A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T] [U][V][W][X][Y][Z][1][2][3][4][5][6][7][8][9][0][1][2][3][4] [5][6][7][8][9][0][1][2][3][4][5][6][7][8][9][0][1][2][3][4] [5][6][7][8][9][0] |<-------------------------- 70 -------------------------->|
The record length of 70 is within the varying range 10-80, but larger than the max level 01 of 50, so the record is invalid under COBOL 6
VLR=STANDARD
. - A record length of 85 is represented as
follows:
[A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T] [U][V][W][X][Y][Z][1][2][3][4][5][6][7][8][9][0][1][2][3][4] [5][6][7][8][9][0][1][2][3][4][5][6][7][8][9][0][1][2][3][4] [5][6][7][8][9][0][1][2][3][4][5][6][7][8][9][0][1][2][3][4] [5][6][7][8][9][0][1][2][3][4][5][6][7][8][9][0] |<------------------------- 80 --------------------------->|[X][X][X][X][X] |<--Truncated->|
The record length of 85 is larger than the max varying 80 and max level 01 of 50, so the record is truncated (✘).
Information message IGYPG3178
The information message IGYPG3178 can also help you avoid I/O problems by telling you if a
program has a possibility of a wrong length READ
. This message can be used to assist with
migration from VLR=COMPAT
to VLR=STANDARD
by indicating the
possible wrong length READ
that you can solve by correcting the File Definition (FD). You can
also raise the severity of the message so that the program must be corrected in order to run. To do
this, use the MSGEXIT
suboption of the EXIT
compiler option to
change the severity of message IGYPG3178 from I (RC=0) to S (RC=12), E (RC=8), or W (RC=4). If you
are not interested in seeing this message, you can suppress the message completely.