SUM: Handling overflow - NOVLSHRT
SUM: Handling overflow - NOVLSHRT
Summary
- When a sum value becomes larger than the space/size available for it, overflow occurs.
- The summary fields in the two records involved are not added together if overflow occurs.
- The records are kept unchanged; neither record is deleted if overflow occurs.
Syntax -
OPTION NOVLSHRT
SORT FIELDS=sort_options
SUM FIELDS=sort_options
- NOVLSHRT communicates DFSORT to fail the job if overflow happened.
- By Default, NOVLSHRT is in effect.
- If NOVLSHRT is in effect or not specified, DFSORT terminates if it finds a short summary field in any VB record.
Example -
Scenario - From the below data, sum the marks at department level.
Input File - MTH.SORT.INPUT02
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001 student1 dept1 095
00003 student3 dept2 070
00004 student4 dept1 090
00005 student5 dept2 083
00002 student2 dept3 088
******************************** Bottom of Data ********************************
Input Record Layout -
01 INPUT-REC.
05 STD-ID PIC X(05).
05 FILLER PIC X(05).
05 STD-NAME PIC X(15).
05 FILLER PIC X(05).
05 STD-DEPT PIC X(10).
05 FILLER PIC X(05).
05 STD-MARKS PIC 9(03).
05 FILLER PIC X(32).
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card
//**********************************************************************
//*
//* SORT SUM WITH OVERFLOW STATEMENT
//*
//**********************************************************************
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=MTH.SORT.INPUT02,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION NOVLSHRT
SORT FIELDS=(30,10,CH,A)
SUM FIELDS=(45,03,ZD)
/*
**************************** Bottom of Data ****************************
Output -
DFSORT terminates the job because of the overflow
Explaining Example -
- The summing of the marks at department level was not happened because there is an overflow if 560 and 540 added.
- The total exceeds 999 which is the maximum value in 3 bytes. So the DFSROT terminates the job.