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

calculate total amount in one file and send to outfile


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

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Mon Dec 31, 2007 6:12 pm
Reply with quote

hi all,

before posting i search in the forum i did not get proper answer so i am posting

Code:

policy        amount
6064            1000
6064            4000
6064            2000
6064            3000
6064            4000
6065            4000
6065            5000
6065            6000
             -------
               29000
            --------


my requirement i want to calculate total from the amount field and need to send only total amount(29000) to another file

can any body give me an idea for this requirement
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Dec 31, 2007 6:47 pm
Reply with quote

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                           
6064 1000                                 
6064 4000                                 
6064 2000                                 
6064 3000                                 
6064 4000                                 
6065 4000                                 
6065 5000                                 
6065 6000                                 
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  SORT FIELDS=COPY                         
  OUTFIL REMOVECC,NODETAIL,               
         TRAILER1=(TOT=(6,4,ZD,LENGTH=7)) 
/*                                         
Back to top
View user's profile Send private message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Mon Dec 31, 2007 9:16 pm
Reply with quote

hi krisprems

your giving code is working fine i am getting total amount in the output file
but the total i am geeting in the 4th position in the out put file, i want the amount field to start in 73 coloumn, how can we do this, you have any solution for this.
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: Mon Dec 31, 2007 9:16 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80 and that's what you want for the output file as well, but the job can be changed appropriately for other attributes. I also assumed you wanted a 5-byte total with leading zeros, but that can be changed if appropriate as well.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
6064            1000
6064            4000
6064            2000
6064            3000
6064            4000
6065            4000
6065            5000
6065            6000
/*
//SORTOUT  DD DSN=...  output file (FB/80)
//SYSIN    DD *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(73:TOT=(17,4,ZD,EDIT=(TTTTT)))
/*


SORTOUT would have:

Code:

                                                                        29000
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 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
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top