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
 

 

Add amounts in the file based on the duplicates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Add amounts in the file based on the duplicates
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    Post subject:
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    Post subject:
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: 2238
Location: @my desk

PostPosted: Mon Dec 22, 2008 7:46 pm    Post subject:
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    Post subject: Reply to: Add amounts in the file based on the duplicates
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    Post subject:
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    Post subject:
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: 2238
Location: @my desk

PostPosted: Tue Dec 23, 2008 9:58 am    Post subject:
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    Post subject:
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    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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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