I need to compile Cobol sources, on z/OS UNIX, with a Cobol 4 compiler but I only have a Cobol 5 compiler. Is there options to restrict Cobol 5 to a Cobol 4 compilation ? I'm using the cob2 command which I mounted to the IGY520.HFS PDS of my Cobol installation on z/OS. I searched in the IBM documentation but didn't find anything.
No. I strongly recommend you study the migration guide and any SHARE presentations on the topic of migration sadly SHARE no longer makes their excellent content available to non-members.
The most common problems reported have to do with invalid data tolerated by older compilers. Quoting from Tom Ross' SHARE presentation linked above...
77 A1 PIC X(4) VALUE ’00 0’. *> x’F0F040F0’, third byte *> has x’4’ for zone bits. *> OK in PIC X, not valid in *> PIC 9 USAGE DISPLAY 77 A2 REDEFINES A1 PIC 9(4). PROCEDURE DIVISION. IF A2 = ZERO *> Compiler could do character DISPLAY ’ZERO‘ *> or numeric compare ELSE DISPLAY ’NOT ZERO‘ END-IF
Whether the program displays ‘ZERO’ or ‘NOT ZERO’ depends on the compiler options you use in COBOL V4 and earlier and in COBOL V6
Also be aware of differences in how packed data is treated, see this recent question.
The NUMCHECK compile option can assist you in these situations, but be advised that compile options cannot detect invalid data at compile time, they can only generate code to detect invalid data at run time.