IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Calcualte monthwise subtotal from Input file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bhanupratap Natva

New User


Joined: 13 Jul 2007
Posts: 8
Location: Hyderabad

PostPosted: Tue May 05, 2009 9:38 pm
Reply with quote

Hi All,

I have a requirement as below

Input file is already sorted on date

PREM_DATE PREM_AMT
--------------- --------------
11/10/2007 2000.00
11/25/2007 2500.00
12/10/2007 300.00
12/15/2007 100.00
01/05/2008 1250.00
01/15/2008 520.00
02/19/2008 1250.00
02/28/2008 520.00

Now, I want to calculate the subtotals of for each-month and want to write it into an output file.

also, I want to calculate the AVG for the column PREM_AMT.

Could anyone suggest me the SORTCARD for the above.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 05, 2009 9:51 pm
Reply with quote

Bhanupratap Natva,

use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                     
11/10/2007 2000.00                                   
11/25/2007 2500.00                                   
12/10/2007 300.00                                   
12/15/2007 100.00                                   
01/05/2008 1250.00                                   
01/15/2008 520.00                                   
02/19/2008 1250.00                                   
02/28/2008 520.00                                   
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                   
  OUTFIL REMOVECC,                                   
  SECTIONS=(1,2,                                     
  TRAILER3=(/,'TOTAL FOR MONTH   ',1,2,' : ',       
             TOT=(12,10,UFF,EDIT=(IIIIIII.IT)),/,   
            'AVERAGE FOR MONTH ',1,2,' : ',         
             AVG=(12,10,UFF,EDIT=(IIIIIII.IT)),/))   
                                                     
/*


This will produce

Code:

11/10/2007 2000.00               
11/25/2007 2500.00               
                                 
TOTAL FOR MONTH   11 :    4500.00
AVERAGE FOR MONTH 11 :    2250.00
                                 
12/10/2007 300.00                 
12/15/2007 100.00                 
                                 
TOTAL FOR MONTH   12 :     400.00
AVERAGE FOR MONTH 12 :     200.00
                                 
01/05/2008 1250.00               
01/15/2008 520.00                 
                                 
TOTAL FOR MONTH   01 :    1770.00
AVERAGE FOR MONTH 01 :     885.00
                                 
02/19/2008 1250.00               
02/28/2008 520.00                 
                                 
TOTAL FOR MONTH   02 :    1770.00
AVERAGE FOR MONTH 02 :     885.00
                                 
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top