MODULE 11 · SUBPROGRAMS AND COPYBOOKS · 8/8

Challenge: the nightly claims intake

40 min60 XPExercise

Every evening an insurer's call centres and web forms have produced a file of new claims. Before any money moves, a batch job checks each one. The checking rules belong to the claims-validation team, who publish them as a subprogram, CLMCHECK, used by the intake batch, the online claim screens and the fraud system alike. Your job is the intake batch program, CLMBATCH.

This is how most real batch programs look: a fairly simple driver that reads a file, calls the shop's shared routines, acts on their return codes and writes the results, with every layout coming from a copybook.

What you're given

  • Copybook CLMREC, the claim record, written with a :PFX: tag. Both the input and the output file use it, and so does CLMCHECK's LINKAGE SECTION.
  • Copybook CLMCHKP, CLMCHECK's second parameter: the run date going in and a reason text coming back.
  • The compiled CLMCHECK module, called dynamically.

CLMCHECK's own LINKAGE SECTION is literally:

       LINKAGE SECTION.
       COPY CLMREC REPLACING ==:PFX:== BY ==LS==.
       COPY CLMCHKP REPLACING ==:PFX:== BY ==LS==.
       PROCEDURE DIVISION USING LS-CLAIM LS-CHECK-PARMS.

Because you COPY the same members, your record and parameter area are the same size and shape as the ones CLMCHECK expects, byte for byte, with different names. That is the whole point of interface copybooks.

Design notes

  • Save RETURN-CODE into WS-RC straight after the CALL, before anything else can change it.
  • CLMCHECK sets RETURN-CODE on every path, so you don't need to reset it between claims. You do need to set the program's final return code yourself, after the summary. Otherwise the step ends with whatever the last claim returned, not the worst.
  • Referred claims (RC 4) are still valid claims: they go to the output file and a claims handler reviews them in the morning. Only RC 8 claims are held back.
  • MOVE IN-CLAIM TO OUT-CLAIM copies the whole 34-byte record in one group move, because both are the same copybook.
  • Put the ON EXCEPTION handling in its own paragraph. A missing CLMCHECK is a severe error: display a message, set return code 16 and stop the run. Letting claims through unchecked is not an option.

On the job

Return code 16 for "a required module or file is missing" and 8 for "some records were rejected" are common conventions. The scheduler (TWS, Control-M) uses the step's return code to decide whether the downstream payment jobs run, so a batch program that always ends RC 0 is hiding problems from operations.

Your task

Write the nightly claims intake program CLMBATCH.

Input

  • SYSIN: one line, the business run date YYYYMMDD.
  • DD CLAIMIN: the day's claims, line sequential, layout from copybook CLMREC:
       01  :PFX:-CLAIM.
           05  :PFX:-CLAIM-ID     PIC X(8).
           05  :PFX:-POLICY-NO    PIC X(8).
           05  :PFX:-LOSS-DATE    PIC 9(8).
           05  :PFX:-TYPE         PIC X.
           05  :PFX:-AMOUNT       PIC 9(7)V99.

The validation module

       CALL "CLMCHECK" USING claim-record check-parms

where check-parms is copybook CLMCHKP:

       01  :PFX:-CHECK-PARMS.
           05  :PFX:-RUN-DATE     PIC 9(8).
           05  :PFX:-REASON       PIC X(20).

CLMCHECK sets RETURN-CODE to 0 (accept), 4 (refer to a claims handler) or 8 (reject), and puts the reason in REASON.

What to do

  1. Replace the placeholders: COPY CLMREC with prefix IN for CLAIM-IN and OUT for CLAIM-OUT, and COPY CLMCHKP with prefix WS in WORKING-STORAGE.
  2. ACCEPT the run date into WS-RUN-DATE.
  3. For each claim, CALL "CLMCHECK" with ON EXCEPTION (display CLMCHECK NOT AVAILABLE, set return code 16, STOP RUN). Then: - RC 0: count as accepted, write to DD CLAIMOK. - RC 4: count as referred, display REFER <claim-id> <reason> (two spaces after REFER), write to CLAIMOK. - RC 8: count as rejected, display REJECT <claim-id> <reason>. - Add the amount of every claim written to CLAIMOK to WS-AMOUNT-OUT.
  4. After the summary, end with the highest RC CLMCHECK returned.

With run date 20260924 and the sample file, the output is (step RC 8):

REJECT CLM00002 INVALID LOSS DATE
REJECT CLM00004 LOSS DATE IN FUTURE
REFER  CLM00005 OVER LIMIT
REFER  CLM00006 LATE REPORT
REJECT CLM00007 UNKNOWN CLAIM TYPE
REJECT CLM00008 ZERO AMOUNT
CLAIMS READ  009
ACCEPTED     003
REFERRED     002
REJECTED     004
AMOUNT OUT        46,900.75
fixed format
Run your program to see its output here. The first visible test's input and datasets are used.
Submit to grade your program against every test.