使用 Cobol 5 编译器编译 Cobol 4

Compile Cobol 4 with a Cobol 5 compiler

我需要在 z/OS UNIX 上使用 Cobol 4 编译器编译 Cobol 源代码,但我只有 Cobol 5 编译器。是否有将 Cobol 5 限制为 Cobol 4 编译的选项? 我正在使用我在 z/OS 上安装到我的 Cobol 安装的 IGY520.HFS PDS 的 cob2 命令。 我在 IBM 文档中进行了搜索,但没有找到任何内容。

COBOL 5 程序向后兼容 COBOL 4(它们可以相互调用),但 COBOL 5 不生成 COBOL 4 对象模块。为什么需要 COBOL 4 编译?

我不知道。我看到以下内容可能有用。

CMPR2, FLAGMIG, and NOCOMPILE compiler options

The COBOL CMPR2, FLAGMIG, and NOCOMPILE options identify source statements that need to be converted to compile under Enterprise COBOL. The CMPR2 and FLAGMIG options are not available in Enterprise COBOL, but you can use your older compilers with these options to flag the statements that need to be changed in order to compile with Enterprise COBOL.

Enterprise COBOL> V4.2 FLAGMIG4 compiler option

A new compiler option, FLAGMIG4, is available with APAR PM93450 for Enterprise COBOL V4.2 to help you migrate to Enterprise COBOL V5 or V6. It is also recommended that you install PTFs for APARs PI12240, PI26838, and PI58762 as these contain updates to the FLAGMIG4 option. The FLAGMIG4 option identifies language elements in Enterprise COBOL V4 programs that are not supported, or that are supported differently in Enterprise COBOL V5 or V6. The compiler generates a warning diagnostic message for all such language elements.

COBOL 6.2 Migration Guide

没有。我强烈建议您研究 the migration guide 和任何 SHARE 关于迁移主题的演示文稿 遗憾的是,SHARE 不再向非会员提供其优秀内容。

报告的最常见问题与旧编译器容忍的无效数据有关。引用汤姆罗斯的 SHARE 演示文稿 以上链接...

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

还要注意打包数据处理方式的差异,see this recent question

NUMCHECK 编译选项可以在这些情况下为您提供帮助,但请注意,编译选项无法在编译时检测无效数据,它们只能在 运行 时生成代码来检测无效数据。