Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Getting mainframe applications to compile

If you move programs to the Windows-based workstation from the mainframe and compile them in the new environment, you need to choose the right compiler options and allow for language features of mainframe COBOL. You can also use the COPY statement to help port programs.

Choosing the right compiler options: One mainframe COBOL compiler option is not applicable under COBOL for Windows, and is treated as a comment. It might yield unpredictable results. The compiler flags it with a W-level message:

NOADV
Programs that require the use of NOADV are sensitive to device control characters and almost certainly are not portable. If your program relies on NOADV, revise the program such that language specification does not assume a printer control character as the first character of the level-01 record for the file.

Allowing for language features of mainframe COBOL: The following language features are valid in mainframe COBOL but can create errors or unpredictable results in compilation with COBOL for Windows. Where possible, the following table provides a solution to the potential problem.

Table 64. Language features that differ from mainframe COBOL
Language feature on mainframe COBOL for Windows behavior Solution or restriction
ACCEPT and DISPLAY statements Determines the targets of DISPLAY or ACCEPT statements by checking COBOL environment variables If your mainframe program expects host ddnames as the targets of ACCEPT or DISPLAY statements, define these targets by using equivalent environment variables with values set to appropriate file-names.
ASSIGN clause Uses a different syntax and mapping to the system file-name based on assignment-name See ASSIGN clause (COBOL for Windows Language Reference).
CALL statement Does not support file-name as a CALL argument  
CLOSE statement Treats phrases FOR REMOVAL, WITH NO REWIND, and UNIT/REEL as comments Avoid use of these phrases in portable programs.
LABEL RECORD clause Treats phrases LABEL RECORD IS data-name, USE. . . AFTER. . . LABEL PROCEDURE, and GO TO MORE-LABELS as errors You cannot port programs that depend on the user-label processing that z/OS QSAM supports.
PROCEDURE-POINTER data item Is 4 bytes (8 bytes on the mainframe)  
RERUN clause Treats RERUN clause as a comment  
SHIFT-IN, SHIFT-OUT special registers Puts out an E-level message when encountering these registers unless the CHAR(EBCDIC) compiler option is in effect Use the CHAR(EBCDIC) compiler option.
SORT-CONTROL special register Follows the file-naming conventions for the system file-name identified by this register Be aware of differences in naming conventions between the Windows workstation and the mainframe.
STOP RUN Not supported in a multithreaded program Replace STOP RUN with a call to the C exit() function
WRITE statement Ignores ADVANCING phrase if you specify WRITE. . . ADVANCING with the environment-names C01-C12 or S01-S05  

Using the COPY statement to help port programs: In many cases, you can avoid potential portability problems by using the COPY statement to isolate platform-specific code. For example, you can include platform-specific code in a compilation for a given platform and exclude it from compilation for a different platform. You can also use the COPY REPLACING phrase to globally change nonportable source code elements, such as file-names.

related references
Runtime environment variables
Appendix A. Summary of differences with host COBOL
COPY statement (COBOL for Windows Language Reference)


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)