Page 2 of 2

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

PostPosted: Wed Sep 28, 2016 6:48 pm
by arya_starc
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))

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

PostPosted: Wed Sep 28, 2016 6:55 pm
by Aki88
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          
 

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

PostPosted: Wed Sep 28, 2016 7:08 pm
by arya_starc
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

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

PostPosted: Wed Sep 28, 2016 7:21 pm
by arya_starc
Thanks all
it's done
I replace M10 and M16 with EDIT syntax.

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

PostPosted: Wed Sep 28, 2016 7:27 pm
by Aki88
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          
 

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

PostPosted: Wed Sep 28, 2016 11:32 pm
by arya_starc
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

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

PostPosted: Thu Sep 29, 2016 2:54 am
by BillyBoyo
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.

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

PostPosted: Thu Sep 29, 2016 4:44 pm
by arya_starc
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*/
/*

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

PostPosted: Thu Sep 29, 2016 5:29 pm
by Aki88
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.