Previous Topic: How Information Is PassedNext Topic: Coding an Assembler Output Module


Coding a COBOL Output Module

The following example writes an 80-byte record.

Output Module

 IDENTIFICATION DIVISION.
 PROGRAM-ID. CULLUS96.
 INSTALLATION. COMPUTER ASSOCIATES
 DATE-WRITTEN. MONTH YYYY.
 REMARKS. THIS IS A TEST OF A COBOL OUTPUT MODULE
          FOR A CULPRIT JOB.
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
 SOURCE-COMPUTER. IBM-370.
 OBJECT-COMPUTER. IBM-370.
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT OUTPUT-FILE ASSIGN TO UT-S-SYS004.
***********************************************
* USE SYS004-UT-S FOR z/VSE
***********************************************
 DATA DIVISION.
 FILE SECTION.
 FD  OUTPUT-FILE
     RECORDING MODE IS F
     LABEL RECORDS ARE STANDARD
     RECORD CONTAINS 80 CHARACTERS
     BLOCK CONTAINS 0 RECORDS
     DATA RECORD IS RECORD-OUT.
 01  RECORD-OUT              PIC X(80).
 WORKING-STORAGE SECTION.
 77  CLOSE-STATUS            PIC X  VALUE ' '.
 77  OPEN-STATUS             PIC X  VALUE ' '.
*   CLOSE-STATUS = HEX 'FF'  OPEN-STATUS = HEX '00'
 LINKAGE SECTION.
 01  CULARG-INPUT            PIC X(80).
 01  CULARG-2                PIC X.
 01  CULARG-SW               PIC X.
 01  CULARG-3                PIC XX.
 01  CULARG-4   COMP         PIC 99.
 01  CULARG-5   COMP         PIC 99.
 01  CULARG-6                PIC X(8).
 01  CULARG-7                PIC X.
 01  CULARG-8                PIC X.
 PROCEDURE DIVISION USING CULARG-INPUT
                          CULARG-2
                          CULARG-SW
                          CULARG-3
                          CULARG-4
                          CULARG-5
                          CULARG-6
                          CULARG-7
                          CULARG-8.
0010-CONTROL.
    IF CULARG-SW = CLOSE-STATUS
        PERFORM 0020-OPEN THRU 0020-EXIT
    ELSE
        IF CULARG-SW = OPEN-STATUS
            PERFORM 0030-WRITE THRU 0030-EXIT
        ELSE
            PERFORM 0040-CLOSE THRU 0040-EXIT.
    GOBACK.
0020-OPEN.
    OPEN OUTPUT OUTPUT-FILE.
    MOVE OPEN-STATUS TO CULARG-SW.
    PERFORM 0030-WRITE THRU 0030-EXIT
0020-EXIT.
    EXIT.
0030-WRITE.
    WRITE RECORD-OUT FROM CULARG-OUTPUT.
0030-EXIT.
    EXIT.
0040-CLOSE.
    CLOSE OUTPUT-FILE.
    MOVE CLOSE-STATUS TO CULARG-SW.
0040-EXIT.
    EXIT.