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

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


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

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Wed Aug 06, 2008 2:23 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 06, 2008 4:59 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Aug 06, 2008 7:25 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Aug 06, 2008 11:28 pm
Reply with quote

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
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Fri Aug 08, 2008 12:18 am
Reply with quote

Thanq all I am getting the Required output Now...... icon_razz.gif.Thanks for your help.
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
No new posts XDC SDSF output to temp dataset CLIST & REXX 4
Search our Forums:

Back to Top