View previous topic :: View next topic
|
Author |
Message |
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi ,
I have an requirement as below
Code: |
A B C D(B+C)
1 5.10 5.10 10.20
2 10.52 11.00 21.52
2 15.00 9.00 24.00
A B C D(B+C)
1 5.10 5.10 10.20
2 15.00 11.00 26.00
|
How to acheive the same using DFSORT/ICETOOL |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Does your sample data fully represent your actual data? The main point being, can there be only two records with the same key? |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
No,There can n number of records with same key values. From that i need the max of B and C and compute the same to get value of D |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, post some data that reflects that then please. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
And also post the expected output in code tags your post doesnt say anything at all |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Input
Code: |
----+----1----+----2----+----3----+--
***************************** Top of
20130804 112101527R 10.12 14.02 24.14
20130804 112101527R 15.00 14.00 29.00
20130804 112740002R 07.00 09.00 16.00
20130804 112740002R 08.00 14.00 24.00
20130804 112740002R 08.00 11.00 18.00
20130804 112748371R 01.01 02.02 03.03
20130804 112749532R 00.97 02.03 03.00
|
Expected Output
Code: |
----+----1----+----2----+----3----+--
***************************** Top of
20130804 112101527R 15.00 14.02 29.02
20130804 112740002R 08.00 14.00 22.00
20130804 112748371R 01.01 02.03 03.04
|
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Why is this record not in output?
Code: |
20130804 112749532R 00.97 02.03 03.00 |
|
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi ,
Sorry its my mistake. Please find below the expected output
Code: |
----+----1----+----2----+----3----+--
***************************** Top of
20130804 112101527R 15.00 14.02 29.02
20130804 112740002R 08.00 14.00 22.00
20130804 112748371R 01.01 02.02 03.03
20130804 112749532R 00.97 02.03 03.00 |
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
1.You could achieve the solution by sorting the file 21,5 descending removing duplicates for Key 1,20 -> File 1
2.Then sorting the file 27,5 descending removing duplicates for Key 1,20 -> File 2
3.Join File 1 & File 2 and do the sum after reformat |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Is there any way to acheive the same in single step? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Yes through ICETOOL |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, it is possible, in one step, with SORT. But no-one is going to just drop everything to do your work.
I'd start with this. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Ideally I would Use a 2 pass approach instead of sort.
1. Get the max of both fields using Sections and Trailer3 with Max function.
2. Perform the Arithmetic of max values |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi,
I got the solution using ICETOOL in 3 steps.
Thanks all for your response. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Since Kolusu outlined how to do it in two steps, without ICETOOL, do you want to show us what you have?
A COPY operation.
OUTFIL with REMOVECC,NODETAIL and SECTIONS for your key, with MAX for each of your values.
A second COPY operation, with INREC OVERLAY doing the additions. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
I was trying the two step solution as suggested by Kolusu and Bill..just as a learning exercise..and posting the code here..hope this helps..feel free to share any suggestion.
Code: |
//STEP01 EXEC PGM=SORT
//SORTIN DD *
20130804 112101527R 10.12 14.02 24.14
20130804 112101527R 15.00 14.00 29.00
20130804 112740002R 07.00 09.00 16.00
20130804 112740002R 08.00 14.00 24.00
20130804 112740002R 08.00 11.00 18.00
20130804 112748371R 01.01 02.02 03.03
20130804 112749532R 00.97 02.03 03.00
//SORTOUT DD DSN=&&TEMPDD,DISP=(NEW,PASS),
// SPACE=(TRK,(10,10),RLSE),DCB=*.SORTIN
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,20,
TRAILER3=(1,20,MAX=(21,5,SFF,EDIT(TT.TT)),
26,1,MAX=(27,5,SFF,EDIT(TT.TT))))
/*
//STEP02 EXEC PGM=SORT
//SORTIN DD DSN=&&TEMPDD,DISP=(OLD,DELETE)
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC BUILD=(1,32,(21,5,SFF,ADD,27,5,SFF),EDIT=(TT.TT))
/* |
Output is:
Code: |
20130804 112101527R 15.00 14.02 29.02
20130804 112740002R 08.00 14.00 22.00
20130804 112748371R 01.01 02.02 03.03
20130804 112749532R 00.97 02.03 03.00 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
About how I thought it should be. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks Bill :-) |
|
Back to top |
|
|
|