Fixing an S0C7
Part of the Batch Jobs with JCL section of Coddy's COBOL Programming journey. Lesson 14 of 19.
S0C7 is among the ABENDs COBOL programmers meet most often. Arithmetic found bytes that are not digits in a number field. It has two usual causes: a field that was never given a value, and bad input data.
The message shows the field's bytes. \000 is a byte of binary zeros, what a field with no VALUE holds here:
libcob: COUNTTX.cob:25: error: 'TX-N' (Type: NUMERIC DISPLAY) not numeric: '\000\000\000'The fix is in the program: give the counter a starting value.
01 TX-N PIC 9(3) VALUE ZERO.Bad data needs a guard: test a field before arithmetic and set the bad record aside.
IF S-AMOUNT IS NUMERIC
ADD S-AMOUNT TO TOTAL
ELSE
ADD 1 TO BAD-N
END-IFA guarded program never ABENDs on its input. It reports what it skipped and ends with a return code, such as 4, that later steps can test with COND or IF.
Challenge
EasyStep COUNT ABENDs S0C7 on its first record. Read the SYSOUT, then fix COUNTTX.cob so the step prints SALES 003 TOTAL 2,625.
Try it yourself
//COUNTJOB JOB (ACCT),'CODDY',CLASS=A,MSGCLASS=X
//COUNT EXEC PGM=COUNTTX
//SALESIN DD DSN=CODDY.SALES.NORTH,DISP=SHR
//SYSOUT DD SYSOUT=*
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Batch Jobs with JCL
Practice on your own: Online COBOL compiler