Page 1 of 1

Addition using DFsort

Posted: Mon Jan 02, 2012 6:20 pm
by raulravi
Hello Frank,

Code: Select all

My file looks like

----+--
*******
1501   
1588   
1598   
1600   


I want to add the position1 + position2 +position3 +position4.
Eg:
1+5+0+1 = 7
1+5+8+8 = 22==> 2+2 = 4.
1+5+9+8 = 23==> 2+3 = 5.
1+6+0+0 = 7
Can we do this kind of operation in DFSORT?

Raul

Posted: Tue Jan 03, 2012 5:56 am
by Frank Yaeger
You can use a DFSORT job like the following:

Code: Select all

//S1 EXEC PGM=SORT                                                    
//SYSOUT DD SYSOUT=*                                                  
//SORTIN DD *                                                         
1501                                                                  
1588                                                                  
1598                                                                  
1600                                                                  
//SORTOUT DD SYSOUT=*                                                 
//SYSIN DD *                                                          
  OPTION COPY                                                         
  INREC IFTHEN=(WHEN=INIT,                                            
    BUILD=(1,1,ZD,ADD,2,1,ZD,ADD,3,1,ZD,ADD,4,1,ZD,TO=ZD,LENGTH=2)),  
   IFTHEN=(WHEN=INIT,                                                 
    BUILD=(1,1,ZD,ADD,2,1,ZD,TO=ZD,LENGTH=1))                         
SORTOUT will have:

Code: Select all

7      
4      
5      
7