apend last record in input file with the sum of two fields



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

Re: apend last record in input file with the sum of two fiel

Postby arya_starc » Wed Sep 28, 2016 6:48 pm

NicC wrote:perhaps because 20:TOT( overlaps 10:TOT=


I used length syntax also to avoid overlap but still not working

 SORT FIELDS=COPY                                                      
  OUTFIL REMOVECC,BUILD=(1:1,35),                                      
  TRAILER1(1:1C'TOTAL',                                                
          10:TOT=(11,9,ZD),LENGTH=9,                                    
          20:TOT=(20,15,ZD))
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Re: apend last record in input file with the sum of two fiel

 

Re: apend last record in input file with the sum of two fiel

Postby Aki88 » Wed Sep 28, 2016 6:55 pm

Hello,

You are almost there with the solution, LENGTH is required to specify the maximum length of the totals.
Here is a working card, you can tweak around with the positions:


----+----1----+----2----+----3----+----4----+----5----+----6
//SORTIN   DD *                                            
23/03/2016   10       34  /*FILE 1*/                        
24/04/2016   20       56  /*FILE 2*/                        
26/08/2016   30       85  /*FILE 3*/                        
/*                                                          
//SORTOUT  DD SYSOUT=*                                      
//*                                                        
//SYSIN    DD *                                            
 SORT FIELDS=COPY                                          
 OUTFIL REMOVECC,BUILD=(1,36),                              
        TRAILER1=(1:C'TOTAL',10:TOT=(11,5,ZD,M10,LENGTH=8),
                             20:TOT=(20,5,ZD,M10,LENGTH=8))
/*                                                           


Gives:


23/03/2016   10       34  /*FILE 1*/  
24/04/2016   20       56  /*FILE 2*/  
26/08/2016   30       85  /*FILE 3*/  
TOTAL          60       175          
 
Aki88
 
Posts: 286
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 31 times
Been thanked: 23 times

Re: apend last record in input file with the sum of two fiel

Postby arya_starc » Wed Sep 28, 2016 7:08 pm

thanks aki,

but now I submit this by adding EDIT function, to get masking and commas

but I getting max cc 16.

000017   SORT FIELDS=COPY                                                      
000018   OUTFIL REMOVECC,BUILD=(1:1,35),                                      
000019   TRAILER1(1:1C'TOTAL',                                                
000020            11:TOT=(11,9,ZD,M10,LENGTH=9),EDIT=(I,III,III),              
000021            20:TOT=(20,16,ZD,M16,LENGTH=16),EDIT=(I,II,III,III,III))    
 

ICE000I 1 - CONTROL STATEMENTS FOR 5650-ZOS, Z/OS DFSORT V2R1  - 20:35 ON WED SE
            SORT FIELDS=COPY                                                    
            OUTFIL REMOVECC,BUILD=(1:1,35),                                    
            TRAILER1(1:1C'TOTAL',                                              
                     11:TOT=(11,9,ZD,M10,LENGTH=9),EDIT=(I,III,III),            
                                                   $                            
ICE007A 1 SYNTAX ERROR                                                          
                     20:TOT=(20,16,ZD,M16,LENGTH=16),EDIT=(I,II,III,III,III))  
                     $                                                          
ICE007A 0 SYNTAX ERROR                                                          
ICE751I 0 C5-I21470 C6-BASE   C7-K96411 C8-I25275 E7-I22412                    
ICE052I 3 END OF DFSORT
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: apend last record in input file with the sum of two fiel

Postby arya_starc » Wed Sep 28, 2016 7:21 pm

Thanks all
it's done
I replace M10 and M16 with EDIT syntax.
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: apend last record in input file with the sum of two fiel

Postby Aki88 » Wed Sep 28, 2016 7:27 pm

You can do this <I have tweaked the data to show the commas>:


----+----1----+----2----+----3----+----4----+----5----+----6----+
//SORTIN   DD *                                                  
23/03/2016  110    47645  /*FILE 1*/
24/04/2016 9920     7867  /*FILE 2*/
26/08/2016 8930    96785  /*FILE 3*/
/*                                                              
//SORTOUT  DD SYSOUT=*                                          
//*                                                              
//SYSIN    DD *                                                  
 SORT FIELDS=COPY                                                
 OUTFIL REMOVECC,BUILD=(1,36),                                  
        TRAILER1=(1:C'TOTAL',10:TOT=(11,5,ZD,EDIT=(I,III,III)),  
                             20:TOT=(20,5,ZD,EDIT=(I,III,III)))  
/*                                                              
 


Gives:


23/03/2016  110    47645  /*FILE 1*/  
24/04/2016 9920     7867  /*FILE 2*/  
26/08/2016 8930    96785  /*FILE 3*/  
TOTAL       18,960   152,297          
 
Aki88
 
Posts: 286
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 31 times
Been thanked: 23 times

Re: apend last record in input file with the sum of two fiel

Postby arya_starc » Wed Sep 28, 2016 11:32 pm

yes thanks.
but the same is work without BUILD=(1,36),
i.e.

 SORT FIELDS=COPY                                                
 OUTFIL REMOVECC,                                
        TRAILER1=(1:C'TOTAL',10:TOT=(11,5,ZD,EDIT=(I,III,III)),  
                             20:TOT=(20,5,ZD,EDIT=(I,III,III)))  
/*                                                              

this also works.

Coded
Last edited by Akatsukami on Thu Sep 29, 2016 2:06 am, edited 1 time in total.
Reason: Added Code tags
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: apend last record in input file with the sum of two fiel

Postby BillyBoyo » Thu Sep 29, 2016 2:54 am

That is because your records present to OUTFIL are at least 36 bytes long. If your OUTFIL records are shorter than the HEADERn/TRAILERn output, you get a run-time failure.
BillyBoyo
Global moderator
 
Posts: 3759
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 256 times

Re: apend last record in input file with the sum of two fiel

Postby arya_starc » Thu Sep 29, 2016 4:44 pm

If there is commas in my input file, then can I get the sum.
As currently I am facing soc7.
like this
//SORTIN   DD *                                                  
23/03/2016  110    47,645  /*FILE 1*/
24/04/2016 9,920     7,867  /*FILE 2*/
26/08/2016 8,930    96,785  /*FILE 3*/
/*
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: apend last record in input file with the sum of two fiel

Postby Aki88 » Thu Sep 29, 2016 5:29 pm

Replace the ZD in TRAILER1 with SFF (Signed Free-Form) or UFF (Unsigned Free-Form), depending on your need.

Before you tread any further, would recommed you visit this link and understand the different data formats, so that you know what you're getting into.

Hope this helps.
Aki88
 
Posts: 286
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 31 times
Been thanked: 23 times

Previous

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post