Verifying totals and sums within a record



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Verifying totals and sums within a record

Postby MitchellSTL » Tue Mar 10, 2015 11:42 pm

I'm not quite sure why I can't figure out such a trivial thing today... I'm trying to verify that several fields on the record match up to a summed total that is already on the record. If a record's summed total does not add up to the other 3 fields on the same record, I need it removed so it's not processed. The output data set will only show records that field "sum" equals the sum of columns #1, #2 and #3. For example...

Input data set
Sum | #1| #2| #3
0045|020|010|015
0800|350|200|250
0100|000|000|000
0020|010|010|000


Expected output dataset
Sum | #1| #2| #3
0045|020|010|015
0800|350|200|250
0020|010|010|000
MitchellSTL
 
Posts: 27
Joined: Wed Feb 16, 2011 8:57 am
Has thanked: 1 time
Been thanked: 0 time

Re: Verifying totals and sums within a record

Postby BillyBoyo » Wed Mar 11, 2015 2:16 am

So you add them together, subtract from the sum. If the result, in a temporary extension to the record, is zero, you keep it. Use INREC to do the calculation, and OUTFIL with INCLUDE= to get the ones which match and BUILD to cut the records back down to size.

These users thanked the author BillyBoyo for the post:
MitchellSTL (Sat Mar 14, 2015 1:00 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Verifying totals and sums within a record

Postby MitchellSTL » Fri Mar 13, 2015 10:31 pm

Thanks! Sorry for the delay in responding. Thanks for the hints/suggestions. I will use your suggestion and see what I come up with. If I get it working, I'll post the solution.
MitchellSTL
 
Posts: 27
Joined: Wed Feb 16, 2011 8:57 am
Has thanked: 1 time
Been thanked: 0 time

Re: Verifying totals and sums within a record

Postby MitchellSTL » Sat Mar 14, 2015 12:59 am

Again, thanks for sending me down the right path....

//S1 EXEC PGM=SORT                                             
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                                                   
0045|020|010|015                                               
0800|350|200|250                                               
0100|000|000|000                                               
0020|010|010|000                                               
/*                                                             
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                   
   OPTION COPY                                                 
   INREC OVERLAY=(1,16,                                         
        17:C'=',                                               
        18,4,ZD,ADD,6,3,ZD,ADD,10,3,ZD,ADD,14,3,ZD,SUB,1,4,ZD, 
        TO=ZD,LENGTH=4)                                         
*** SUPPRESS SUMMED VALUE                                       
   OUTFIL INCLUDE=(18,4,ZD,EQ,0),BUILD=(1,16)
*** TO SEE FIELDS IN THE RECORD SUMMED, USE BELOW   
*  OUTFIL BUILD=(1,22)                                                 
/*
MitchellSTL
 
Posts: 27
Joined: Wed Feb 16, 2011 8:57 am
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post