Challenge: the batch run sheet
Time to put the module together. Every night, the operations team at a
bank runs dozens of batch jobs. For each one, the job prints a run
sheet to SYSOUT so the morning shift can see what ran, who was on
duty, and sign it off.
You'll write the program that prints it. It uses everything from this module:
- all four divisions in the right order, with a comment block at the top
- fixed-format layout: headers in Area A, statements in Area B
WORKING-STORAGEfields with the rightPICfor each valueACCEPTto read four lines ofSYSINDISPLAYmixing literals and fields, including a literal that contains quotes
Watch the padding
The job name is held in a PIC X(8) field, because z/OS job names are at
most eight characters. A shorter name such as GLPOST is padded with
spaces to eight, and those spaces show up whenever the field is displayed
in the middle of a line:
IDENTIFICATION DIVISION.
PROGRAM-ID. PADDING.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-JOB-NAME PIC X(8).
PROCEDURE DIVISION.
ACCEPT WS-JOB-NAME.
DISPLAY "JOB " WS-JOB-NAME " DONE".
STOP RUN.
With input GLPOST this prints JOB GLPOST DONE. That is exactly what
a real COBOL report does, and the expected output of this challenge
includes that padding. Don't try to remove it.
On the job
Run sheets like this are why operators can answer "did last night's payroll finish, and who ran it?" in seconds. Clear, fixed-layout output is a feature, not an afterthought.
Your task
Print the nightly batch run sheet. SYSIN has four lines, in this order:
| Line | Content | Field to use |
|---|---|---|
| 1 | Job name, up to 8 characters | WS-JOB-NAME PIC X(8) |
| 2 | Operator name, up to 20 characters | WS-OPERATOR PIC X(20) |
| 3 | Number of steps run, 1–99 | WS-STEPS PIC 9(2) |
| 4 | Run date as YYYYMMDD |
WS-RUN-DATE PIC 9(8) |
For the input
PAYRUN01
JANE DOE
7
20260924
the output must be exactly:
*----------------------------------------*
* NIGHTLY BATCH RUN SHEET *
*----------------------------------------*
RUN DATE : 20260924
OPERATOR : JANE DOE
JOB PAYRUN01 COMPLETED IN 07 STEPS
OPERATOR'S SIGN-OFF: "________"
Requirements:
- Add the missing
ENVIRONMENT DIVISIONso the program has all four. - Read all four values with
ACCEPTbefore displaying anything. - The job name keeps its padding: a 6-character job name is followed by
two extra spaces before
COMPLETED.