DFSORT SUM Handling overflow - VLSHRT

DFSORT SUM: Suppressing duplicate records DFSORT SUM: Handling overflow - NOVLSHRT

Advertisements


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 VLSHRT
SORT FIELDS=sort_options
SUM FIELDS=sort_options

VLSHRT communicates DFSORT to ignore the records with short summary fields un-summed.

One of the two records involved in a summary operation has a shortsummary field, the records are kept unchanged; neither record is deleted.

By Default, NOVLSHRT is in effect.

Note: If NOVLSHRT is in effect or not specified, DFSORT terminates if it finds a shortsummary field in any VB record.

Example:

From the below data, sum the marks at department level.


Input:- MTH.SORT.INPUT

----+----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).

Job:

000100 //Jobcard
000400 //*                                                                     
000003 //*                                                                     
000004 //**********************************************************************
000005 //*                                                                     
000006 //* SORT SUM WITH OVERFLOW STATEMENT                                    
000007 //*                                                                     
000008 //**********************************************************************
000009 //STEP01   EXEC PGM=SORT                                                
000010 //SORTIN   DD DSN=MTH.SORT.INPUT02,DISP=SHR                    
000011 //SORTOUT  DD SYSOUT=*                                                  
000012 //SYSOUT   DD SYSOUT=*                                                  
000013 //SYSIN    DD *                                                         
000014      OPTION VLSHRT                                                      
000015      SORT FIELDS=(30,10,CH,A)                                           
000016      SUM  FIELDS=(45,03,ZD)                                             
000017 /*                                                                      
****** **************************** Bottom of Data ****************************

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
00001     student1            dept1          560                                 
00004     student4            dept1          540                                 
00003     student3            dept2          520                                 
00005     student5            dept2          500                                 
00002     student2            dept3          510                                 
******************************** BOTTOM OF DATA ********************************


Explaining Solution:

  1. The summing of the marks at department level was not happened because there is an overflow if 560 and 540 added.
  2. The total exceeds 999 which is the maximum value in 3 bytes. So the records are not summed and simply sorted.

DFSORT SUM: Suppressing duplicate records DFSORT SUM: Handling overflow - NOVLSHRT

Advertisements