Thank you! That example appears to have been removed from the COBOL 5.2
Migration Guide. :-(
It does explain the behavior, for sure.
It also helps me decide that I'm going to go with the new, correct, behavior
with VLR(STANDARD). If we have any program that has this issue I am fine with
getting an '04' instead of the '00'. This will probably cause the program to
treat this as an error, which is fine because the program really should be
corrected. We have few variable length files, and I am guessing no programs
that exhibit this behavior. (Famous last words.)
Frank
From: Greg Shirey <[email protected]>
To: [email protected]
Sent: Friday, April 3, 2015 2:50 PM
Subject: Re: migrating compiler versions
The COBOL 5.1.1 Migration Guide contains an example of how to test for it.
Compile this program 4.2 and message “Incompatible wrong length read behavior”
will display. (At least it did when I did it)
*********************************************************
** **
** DESCRIPTION: This testcase tests if a compiler exhibits **
** corrected COBOL V5 var length READ behavior. **
** **
*********************************************************
IDENTIFICATION DIVISION.
Program-id. READVAR.
Environment division.
Input-output section.
File-control.
Select File1
Assign to ddvar1
Access mode is sequential.
Select File2
Assign to ddvar1
Access mode is sequential
File status is fs2.
I-O-control.
Data division.
File section.
Fd file1
Record is varying
Recording mode V.
01 Record1a pic x(20).
01 Record1b pic x(40).
Fd file2
Record is varying 10 to 40
Recording mode V.
01 Record2a pic x(25).
01 Record2b PIC x(35).
Working-storage section.
01 fs2 pic 99.
01 fs3 pic 99.
01 Errflag pic x value "N".
Procedure division.
Display "Starting READVAR".
*--------------------------------------------------------
* Create file1 with 1 20-byte record and 1 40-byte record
*--------------------------------------------------------
Open output file1
Move all "a" to record1a
Write record1a
Move all "b" to record1b
Write record1b
Close file1.
*--------------------------------------------------------
* Read file2 with 25 and 35 byte records defined
* First READ should get FS=4 because 20 byte record is
* shorter than the smallest record description
* Second READ should get FS=4 because 40 byte record is
* longer than the longest record description
*--------------------------------------------------------
Open input file2
Read file2
If fs2 = 4 then
Display " Corrected COBOL V5 behavior"
Else
Display " Incompatible wrong length read behavior"
End-If
Read file2
If fs2 = 4 then
Display " Corrected COBOL V5 behavior"
Else
Display " Incompatible wrong length read behavior"
End-If
Close file2.
Goback.
HTH,
Greg Shirey
Ben E. Keith Company
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf
Of Frank Swarbrick
Sent: Friday, April 03, 2015 1:50 PM
To: [email protected]
Subject: Re: migrating compiler versions
The RECORD CONTAINS clause is not required in either V4 or V5. It (if not
present) is determined from the smallest and largest 01 level fields in the
FD.Both V4 and V5 give a compiler error if there is a RECORD CONTAINS clause
that does not match what would have been assumed had it not been present.
I cannot figure out how to create a situation where COBOL V4 returns status
'00' when there is a size mismatch. I always get '04'.
Frank
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN