Challenge: the nightly claims intake
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 doesCLMCHECK'sLINKAGE SECTION. - Copybook
CLMCHKP,CLMCHECK's second parameter: the run date going in and a reason text coming back. - The compiled
CLMCHECKmodule, 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-CODEintoWS-RCstraight after theCALL, before anything else can change it. CLMCHECKsetsRETURN-CODEon 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-CLAIMcopies the whole 34-byte record in one group move, because both are the same copybook.- Put the
ON EXCEPTIONhandling in its own paragraph. A missingCLMCHECKis 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 dateYYYYMMDD.- DD
CLAIMIN: the day's claims, line sequential, layout from copybookCLMREC:
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
- Replace the placeholders:
COPY CLMRECwith prefixINforCLAIM-INandOUTforCLAIM-OUT, andCOPY CLMCHKPwith prefixWSinWORKING-STORAGE. ACCEPTthe run date intoWS-RUN-DATE.- For each claim,
CALL "CLMCHECK"withON EXCEPTION(displayCLMCHECK NOT AVAILABLE, set return code 16,STOP RUN). Then: - RC 0: count as accepted, write to DDCLAIMOK. - RC 4: count as referred, displayREFER <claim-id> <reason>(two spaces afterREFER), write toCLAIMOK. - RC 8: count as rejected, displayREJECT <claim-id> <reason>. - Add the amount of every claim written toCLAIMOKtoWS-AMOUNT-OUT. - After the summary, end with the highest RC
CLMCHECKreturned.
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