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

Add amounts in the file based on the duplicates


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

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Mon Dec 22, 2008 4:43 am
Reply with quote

Hi,

I have below situation. Any help would be greatly appreciated.

the input vsam file is as below.

00000000010005810042000
00000000010005810044482
00000000020004568350000
00000000030002354243482

in the above layout first 10 bytes is sequence number (0000000001,0000000002 and 0000000003) and next nine bytes are identification number(000581004,000456835,000235424) and last 4 bytes are amounts(20.00,44.82,00.00,34.82)

I want to add the amounts if we have same sequence number and identification number.

the o/p file should be like this.

00000000010005810046482
00000000020004568350000
00000000030002354243482

Thanks in Advance.

Regards,
Sudhakar.
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon Dec 22, 2008 12:01 pm
Reply with quote

Hi Sudhakar,

Hope this code gives you desire output

Code:
//STEP01   EXEC PGM=ICEMAN                 
//*                                       
//SYSOUT       DD  SYSOUT=*               
//*                                       
//SORTIN    DD DSN= Input VSAM file, 
//             DISP=(SHR)   
//*               
//SORTOUT  DD  SYSOUT=*                   
//*                                       
//SYSIN DD *                               
  SORT FIELDS=(1,10,A,11,9,A),FORMAT=CH   
  SUM FIELDS=(20,4,ZD)                     
  OUTREC OVERLAY=(20:20,4,ZD,EDIT=(TTTT)) 
/*


Output:
Code:
00000000010005810046482
00000000020004568350000
00000000030002354243482
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Mon Dec 22, 2008 7:27 pm
Reply with quote

Thank you for the quick reply nelson.pandian. Is there anyway that I can do with sort utility. Please let me know.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Mon Dec 22, 2008 7:46 pm
Reply with quote

Quote:
Is there anyway that I can do with sort utility
sudhakar1979,

The solution posted here with 'PGM=ICEMAN' invokes nothing but your site's SORT utility. You can use 'PGM=SORT' instead.
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Mon Dec 22, 2008 8:38 pm
Reply with quote

Hi thank you very much for the reply. I have tested this jcl. But I am getting some mismatch in the o/p

here is the data i have given.

00000000010005810048000
00000000010005810044482
00000000020004568352500
00000000020004568352500
00000000030002354243482
00000000030002354243482

the after I ran the jcl I got the following o/p

00000000010005810048000
00000000010005810044482
00000000020004568355000
00000000030002354246964

if you see first 2 records also need to be added, and the o/p should be only 3 records as per the requirement, Could you please suggest me what needs to be done in the jcl.

Thanks in advance.

sudhakar.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Dec 22, 2008 10:04 pm
Reply with quote

sudhakar1979,

If you looked at your sysout messages closely you would have found this

Code:

ICE152I 0 OVERFLOW DURING SUMMATION - RC=0


Here you are summing 8000 + 4482 = 12482 which takes 5 bytes and you only have 4 bytes to accommodate that. It is an overflow condition.

If you just want the sum of the records then use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=ICEMAN                   
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                               
00000000010005810048000                       
00000000010005810044482                       
00000000020004568352500                       
00000000020004568352500                       
00000000030002354243482                       
00000000030002354243482                       
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  OPTION EQUALS                               
  SORT FIELDS=(1,19,CH,A)                     
  OUTFIL REMOVECC,NODETAIL,                   
  SECTIONS=(1,19,                             
  TRAILER3=(1,19,TOT=(20,4,ZD,M11,LENGTH=8)))
//*


The output from this job is
Code:

000000000100058100400012482
000000000200045683500005000
000000000300023542400006964


Now the sum is 8 bytes starting from pos 20.
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Dec 23, 2008 9:31 am
Reply with quote

Hallo sudhakar,

This DFSORT JCL will also give the desire output.

Code:
//S1       EXEC PGM=ICEMAN                   
//*                                           
//SYSOUT       DD  SYSOUT=*                   
//*                                           
//SORTIN    DD *                             
00000000010005810048000                       
00000000010005810044482                       
00000000020004568352500                       
00000000020004568352500                       
00000000030002354243482                       
00000000030002354243482                       
/*                                           
//*                                           
//SORTOUT  DD  SYSOUT=*                       
//*                                           
//SYSIN DD *                                 
  INREC BUILD=(1,19,20:C'0000',24:20,4)       
  SORT FIELDS=(1,19,A),FORMAT=CH             
  SUM FIELDS=(20,8,ZD)                       
  OUTREC OVERLAY=(20:20,8,ZD,EDIT=(TTTTTTTT))
/*


Output:
Code:
000000000100058100400012482
000000000200045683500005000
000000000300023542400006964
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Dec 23, 2008 9:58 am
Reply with quote

nelson.pandian,

I believe you'll get the same results without the OUTREC statement shown above. I would go for Kolusu's solution as you would not need an INREC pass to pad the input with zeroes.
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Dec 23, 2008 3:38 pm
Reply with quote

Yes Arun. I too agree with that. Kolusu's solution was quite simple. icon_smile.gif
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