Testing the Installation

This chapter describes how to preprocess and compile COBOL files.

1. OFCOBOL Preprocessing Example

The following are the steps for preprocessing a sample COBOL file using the ofcbpp command after installing OFCOBOL.

  1. Create a simple sample COBOL file.

           IDENTIFICATION DIVISION.
           PROGRAM-ID.     SAMPLE.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  WS-VAR.
               COPY WSVARCPY.
           PROCEDURE DIVISION.
    
               MOVE 'SAMPLE PROGRAM' TO WS-VAR-DAT.
               DISPLAY WS-VAR-DAT.
    
           END PROGRAM SAMPLE.
  2. Preprocess SAMPLE.cob.

    ofcbpp -i SAMPLE.cob -o ofcbpp_SAMPLE.cob

    For more information about using ofcbpp for preprocessing, refer to "2.2. ofcbpp" in OpenFrame COBOL User Guide.

  3. Confirm that the copybook specified using the COPY statement is inserted in ofcbpp_SAMPLE.cob, the preprocessing result.

           IDENTIFICATION DIVISION.
           PROGRAM-ID.     SAMPLE.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  WS-VAR.
          *    COPY WSVARCPY.
          *(/home/oframe/OFCOBOL/copybook/WSVARCPY)
               03  WS-VAR-LEN  PIC 9(04) COMP.
               03  WS-VAR-DAT  PIC X(16).
    
           PROCEDURE DIVISION.
    
               MOVE 'SAMPLE PROGRAM' TO WS-VAR-DAT.
               DISPLAY WS-VAR-DAT.
    
           END PROGRAM SAMPLE.

2. OFCOBOL Compilation Example

Use the ofcob command to compile COBOL programs.

  1. The following is an example of creating an executable file by compiling SAMPLE.cob.

    ofcob -x SAMPLE.cob

    For more information about using ofcob for compilation, refer to "3.1. ofcob" in OpenFrame COBOL User Guide.

  2. Confirm that an executable file is created with the program file name.

    $ ls
    SAMPLE  SAMPLE.cob
    $ ./SAMPLE
    SAMPLE PROGRAM
    $