View previous topic :: View next topic
|
Author |
Message |
sudhakar1979
New User
Joined: 23 Aug 2005 Posts: 24
|
|
|
|
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
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 |
|
|
sudhakar1979
New User
Joined: 23 Aug 2005 Posts: 24
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
sudhakar1979
New User
Joined: 23 Aug 2005 Posts: 24
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Yes Arun. I too agree with that. Kolusu's solution was quite simple. |
|
Back to top |
|
|
|