Search code examples
coboljclgnucobol

PC COBOL program to JCL


I have the following simple COBOL program - written for the PC. It simply reads a file from the computer and writes to the file:

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUSTOMER-FILE ASSIGN TO
"C:Customers.dat"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD CUSTOMER-FILE.
01 CUSTOMER-RECORD.
05 FIRST-NAME PIC X(20).
05 LAST-NAME PIC X(20).
WORKING-STORAGE SECTION.
01 WS-CUSTOMER-RECORD.
05 WS-FIRST-NAME PIC X(20).
05 WS-LAST-NAME PIC X(20).
01 WS-EOF PIC X.
PROCEDURE DIVISION.
OPEN OUTPUT CUSTOMER-FILE
PERFORM UNTIL CUSTOMER-RECORD = SPACES
DISPLAY "Enter the first and last name for the customer"
ACCEPT CUSTOMER-RECORD
WRITE CUSTOMER-RECORD
END-PERFORM
CLOSE CUSTOMER-FILE
DISPLAY "Output from the Customer File:"
OPEN INPUT CUSTOMER-FILE.
PERFORM UNTIL WS-EOF = 'Y'
READ CUSTOMER-FILE INTO WS-CUSTOMER-RECORD
AT END MOVE 'Y' TO WS-EOF
NOT AT END DISPLAY WS-CUSTOMER-RECORD
END-READ
END-PERFORM.
CLOSE CUSTOMER-FILE.
GOBACK.

My question: I'm not too familiar with JCL. So if I were to put this program on a mainframe, what would I do for the JCL?


Solution

  • I presume your Identification Division got lost in a cut & paste incident on its way to Stack Overflow; you'll need that.

    The current incarnation of IBM Enterprise COBOL does not allow free format source so in order to get your code to compile you would have to reformat and follow the traditional fixed format.

    Rather than referring to your data file by name, your Assign clause must refer to a name (limited to 8 characters) which corresponds to a DD name in your JCL. Pick something meaningful, to the extent you can in 8 characters, maybe CUSTOMER.

    Since you're running with JCL, your Accept statement will work a bit differently. Probably data will come from a SYSIN DD.

    Your JCL will look something like this...

    [job card, which is shop-specific]
    //TOMSPGM  EXEC PGM=yourProgramName
    //STEPLIB  DD  DISP=SHR,DSN=mainframe.dataset.where.you.bound.your.program
    //SYSIN    DD  *
    [your customer records]
    //CUSTOMER DD  DISP=(NEW,CATLG,DELETE),
    //             DSN=mainframe.dataset.where.your.data.should.end.up,
    //             LRECL=40,
    //             AVGREC=U,
    //             RECFM=FB,
    //             SPACE=(40,(10,10),RLSE) Adjust to your needs
    //SYSOUT       SYSOUT=*
    //CEEDUMP      SYSOUT=*
    

    I'm not sure how this will work with your creating the customer file and then reading it in the same program. In 30 years of mainframe work I've never seen that.