We are converting from COBOL-74 to COBOL/370. We are facing the below issue, can someone guide us.

The COBOL-74 program is called twice in same PROC.
In the first case, the input file is VB and LRECL is 124. In the second case it is VB of LRECL 66. It was working fine in both scenarios.
In the program the FD clause has a record length of 120.

Now after converting its working fine for first case but for second case failing with ABEND U4038.

Error Message:
IGZ0035S There was an unsuccessful OPEN or CLOSE of file "FILENAME" in program "PROGRAM" at relative location X'1340'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 39.

The OPEN statement was unsuccessful because a conflict was detected between the fixed file attributes and the attributes specified for that file in the program. These attributes include the organization of the file (sequential, relative, or indexed), the prime record key, the alternate record keys, the code set, the maximum record size, the record type (fixed or variable), and the blocking factor.

After a record is READ, field WS-RECORD-LGTH will contain the length of the record just read. Note that WS-RECORD-LGTH must be defined as UNSIGNED, preferably as a fullword-binary (as illustrated), the most efficient definition.

You can then move from FILENAME-RECORD to WS-RECORD-AREA (when WS-RECORD-LGTH is the maximum of 120) or use WS-RECORD-LGTH as the 2nd-part (length) of a reference modification move (1:WS-RECORD-LGTH), clearing WS-RECORD-AREA to SPACES beforehand as a failsafe.

This same feature can be used for variable-length record WRITE's, by setting the RECORD-LGTH to the desired value beforehand.

It was introduced with COBOL II version 4.0, the predecessor to COBOL/370 and is valid in all other subsequent COBOL versions, right through the latest/greatest version of Enterprise.

The thing is, if this is going to work, all the other attempts would work. And they didn't, so thiis won't either.

However, thinking about that got me to the answer.

When reading the LRECL 66 file, the COBOL program still has the expectatin of receiveing a record with 120 bytes of data. When it sees the LRECL of 66 it says "oh no you don't, you musrt have given me the wrong file".

So, to test the theory, put LRECL=124 om your input ~DD when you specify the LRECL 66 file. When that works (which it will), you shoud permanently change the LRECL of 66 to 124, and document it so no-one changes it back. It causes no problem, uses no more space, it is just to allow it ot work in the COBOL program.

Let me see if I understand this correctly: (1) There is one program with one FD, defined with RECORD FORMAT V either explicitly or by default. (2) There are two variable length files; One with LRECL=66, the other with LRECL=124, (3) The program executes twice, first using the LRECL=124 file, then using the LRECL=66 file. (4) The program works fine with the LRECL=124 file, but abends trying to open the LRECL=66 file.

This makes perfect sense. RECORD FORMAT V requires a file with LRECL matching the largest 01 Level definition. If you try to read an LRECL=66 file using a program with a 120 byte 01 Level under the FD, you're going to blow. Doesn't mean you can't read a 66 byte record, just that the record has to come from a file with a matching [max] LRECL (i.e. 124).

Make both files LRECL=124, put the 124 byte record in one and the 66 byte record in the other, then read each file separately in two job steps. Problem should then go away.