IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

I want to sum the fields which are present in my output

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
View previous topic :: View next topic  
Author Message
rakeshnaredlla



Joined: 04 Aug 2008
Posts: 13
Location: Hyderabad

Posted: Wed Aug 06, 2008 2:23 pm    Post subject: I want to sum the fields which are present in my output  

HI,

I want to sum the fields in my Input and write that value in another file with record count and the summed amount.Here we have to use only DFSORT .The Input fields are declared as S9(9)v99. I need to sum this and write it into a new file. Please find the requirements.

Eg:

My Input

Record Box-1 Box-2 Box-3
1 30.00- 40.00 50.00
2 40.00 40.00 60.00

Required Output
Record Count = 2
Amount In Box-1 and Box-2 = 90.00(This amount should have only Box 1 and Box 2 )
Amount In Box-3 = 110.00 ( This amount should not be added into Box1 and Box2.It should be added seperatly and displayed in a different line)
Back to top  
Aaru



Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India

Posted: Wed Aug 06, 2008 4:59 pm    Post subject: Reply to: I want to sum the fields which are present in my o  

Rakesh,

Check this JCL which has 3 steps. You can also simplyfy this using ICETOOL to have 3 COPY/SORT with 3 control cards.

Else, wait for Frank/kolulsu for a better solution.

Code: //STEPS200 EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
1 30.00 -40.00 50.00                                                   
2 40.00  40.00 60.00                                                   
/*                                                                     
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  OUTFIL REMOVECC,NODETAIL,                                             
   SECTIONS=(2,1,                                                       
   TRAILER3=(1:C'AMOUNT IN BOX-1 =',                                   
                           18:TOT=(3,5,SFF,EDIT=(STTT.TT),SIGNS=(,-)),/,
    1:C'AMOUNT IN BOX-2 =',18:TOT=(9,6,SFF,EDIT=(STTT.TT),SIGNS=(,-))))
/*                                                                     
//*ORTOUT  DD SYSOUT=*                                                 
//SORTOUT  DD DSN=XXXX.SRT1.AZA2,DISP=(,CATLG,DELETE),                 
//             SPACE=(90,(10,5),RLSE),AVGREC=K,                         
//             LRECL=80,RECFM=FB                                       
//STEPS201 EXEC PGM=ICEMAN                                           
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=xxxx.SRT1.AZA2,DISP=SHR                           
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  OUTFIL REMOVECC,NODETAIL,                                         
   SECTIONS=(40,1,                                                   
   TRAILER3=(1:C'AMOUNT IN BOX-1 AND BOX-2 =',                       
                     31:TOT=(18,7,SFF,EDIT=(STTT.TT),SIGNS=(,-))))   
/*                                                                   
//SORTOUT  DD DSN=xxxx.SRT2.AZA2,DISP=(,CATLG,DELETE),               
//             SPACE=(90,(10,5),RLSE),AVGREC=K,                     
//             LRECL=80,RECFM=FB                                     
//*                                                                 
//STEPS202 EXEC PGM=ICEMAN                                           
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
1 30.00 -40.00 50.00                                                 
2 40.00  40.00 60.00                                                 
/*                                                                   
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTFIL REMOVECC,NODETAIL,                                           
   SECTIONS=(2,1,                                                     
   TRAILER3=(1:C'AMOUNT IN BOX-3 =',18:TOT=(16,5,SFF,EDIT=(TTT.TT)),/,
             1:C'RECORD COUNT =',15:COUNT=(M11,LENGTH=2)))           
/*                                                                   
//SORTOUT  DD DSN=xxxx.SRT2.AZA2,DISP=MOD                             

Intermediate Output:

Code: ***************************** Top of Data ******************************
AMOUNT IN BOX-1 = 070.00                                               
AMOUNT IN BOX-2 = 000.00                                               
**************************** Bottom of Data ****************************

Final Output:

Code: ***************************** Top of Data ******************************
AMOUNT IN BOX-1 AND BOX-2 =    070.00                                   
AMOUNT IN BOX-3 =110.00                                                 
RECORD COUNT =02                                                       
**************************** Bottom of Data ****************************
Back to top  
arcvns



Joined: 17 Oct 2006
Posts: 762
Location: Chennai, India

Posted: Wed Aug 06, 2008 7:25 pm    Post subject:  

Hello rakeshnaredlla,

You may try out these.

Input
Code: RECORD   BOX-1         BOX-2         BOX-3       
1/AN     11/SNUM       11/SNUM       11/SNUM     
(1-1)    (2-12)        (13-23)       (24-34)     
1------- 2------------ 3------------ 4------------
********************************* TOP OF DATA ****
1                30.00        -40.00         50.00
2                40.00         40.00         60.00

Output
Code: Record Count              =        2
Amount In Box-1 and Box-2 =   +70.00
Amount In Box-3           =  +110.00

Sort Card
Code: //SYSIN    DD *                                                       
  INREC FIELDS=(2,11,ZD,ADD,13,11,ZD,TO=ZD,LENGTH=11,24,11,C'0001A')   
  SORT FIELDS=(27,1,CH,A)                                             
  SUM FIELDS=(1,11,ZD,12,11,ZD,23,4,ZD)                               
  OUTFIL OUTREC=(C'Record Count              =',23,4,ZD,M10,LENGTH=9,/,
                 C'Amount In Box-1 and Box-2 =',1,11,ZD,M4,LENGTH=9,/,
                 C'Amount In Box-3           =',12,11,ZD,M4,LENGTH=9) 
/*   


Thanks,
Arun
Back to top  
Frank Yaeger



Joined: 15 Feb 2005
Posts: 4613
Location: San Jose, CA

Posted: Wed Aug 06, 2008 11:28 pm    Post subject:  

rakeshnaredlla,

You can use a DFSORT job like the following to do what you asked for. I wasn't exactly sure where your numbers were located or what they looked like (you seem to imply they're ZD but you show decimal points in the example), so I used the most general approach (SFF). It also wasn't clear how you wanted the count and totals formatted for output, so I guessed at that too. Adjust as needed. In the future, please give complete details so people don't have to guess.

Code:
//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
     1          -30.00       40.00       50.00
     2           40.00       40.00       60.00
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(81:12,11,SFF,ADD,24,11,SFF,TO=ZD,LENGTH=11)
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
    TRAILER1=('Record Count = ',COUNT=(M10,LENGTH=3),/,
      'Amount In Box-1 and Box-2 = ',
         TOT=(81,11,ZD,EDIT=(SIIT.TT),SIGNS=(,-)),/,
      'Amount In Box-3 = ',
         TOT=(36,11,SFF,EDIT=(SIIT.TT),SIGNS=(,-)))
/*


SORTOUT would have:

Code:
Record Count =   2                   
Amount In Box-1 and Box-2 =   90.00   
Amount In Box-3 =  110.00             
Back to top  
rakeshnaredlla



Joined: 04 Aug 2008
Posts: 13
Location: Hyderabad

Posted: Fri Aug 08, 2008 12:18 am    Post subject: Reply to: I want to sum the fields which are present in my o  

Thanq all I am getting the Required output Now...... :P.Thanks for your help.
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM