Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: I want to sum the fields which are present in my output
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: 1288
Location: Chennai, India

PostPosted: Wed Aug 06, 2008 4:59 pm    Post subject: Reply to: I want to sum the fields which are present in my o
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: 2239
Location: @my desk

PostPosted: Wed Aug 06, 2008 7:25 pm    Post subject:
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 Moderator


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

PostPosted: Wed Aug 06, 2008 11:28 pm    Post subject:
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    Post subject: Reply to: I want to sum the fields which are present in my o
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us