View previous topic :: View next topic |
Author |
Message |
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Tue Jul 27, 2004 5:01 am Post subject: DFSORT : Find and replace |
|
|
Input:
Code: |
ABCDEF AB CDE ABC LMNO ERTYU 10 AB
ABCDEF AB CDE ABC XXXX ERTYU 22 AB
ABCDEF AB CDE ABC XXXX ERTYU 34 AB
ABCDEF AB CDE ABC XXXX ERTYU 45 AB
WERTY DF TYU DFERYUIT OIUYP 23 SD
WERTY DF TYU XXXXYUIT OIUYP 34 XX
WERTY DF TYU XXXXYUIT OIUYP 56 XX
|
Output
Code: |
ABCDEF AB CDE ABC LMNO ERTYU 10 AB
ABCDEF AB CDE ABC LMNO ERTYU 22 AB
ABCDEF AB CDE ABC LMNO ERTYU 34 AB
ABCDEF AB CDE ABC LMNO ERTYU 45 AB
WERTY DF TYU DFERYUIT OIUYP 23 SD
WERTY DF TYU DFERYUIT OIUYP 34 SD
WERTY DF TYU DFERYUIT OIUYP 56 SD
|
Can anybody help me with some idea on how to accomplish this using
dfsort/icetool ?
As you can see what I am trying to do is identify the XX's and replace
them with the corresponding value in the previous record
The records are all unique. (The second column from the right makes them
unique) |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jul 27, 2004 5:22 am Post subject: |
|
|
mfjin,
Couple of questions.
1. how do you identify the replacing string? Is it always the record with lowest seqnum?(The second column from the right )
2. Is the value of xxx variable?. I see that you have xxx in 2 different positions.
3. What is the LRECL , RECFM of the input file?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Tue Jul 27, 2004 5:53 am Post subject: |
|
|
Kolusu
1. The string to be replaced is identified by XX. (can be XX or XXXX).
This has to be replaced by the value in the previous row at the same position. If u see my example , the first four records have the same values except the XXXX and the numeric field. so here xxxx should be
replaced by LMNO which is the field in the previous properly populated row at the same position. Yes the second column from the roght is sorted in ascending order
2. Yes the value of xxxx is variable for different sets. In the first four records the value of xxxx will be LMNO. iN THE NEXT three records value of XXXX will be DFER and that of XX will be SD.
3. 59 and FB
Thanks Kolusu |
|
Back to top |
|
|
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Tue Jul 27, 2004 6:04 am Post subject: |
|
|
>>>>Is it always the record with lowest seqnum?(The second column from the right )
Yes Kolusu. The XX's or XXXX's are always below the properly populated
row from where we pick up the values to replace the X's. |
|
Back to top |
|
|
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Tue Jul 27, 2004 4:15 pm Post subject: |
|
|
Looks like either my requirement was not clear enough or was I expecting a little too much from dfsort/icetool..??
anyways...Ill write an easytrive to do this.. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Jul 28, 2004 5:35 am Post subject: |
|
|
mfjin,
I had a solution with SPLICE in mind, but I cannot really test it as my version of syncsort does not support it.
Here is the thought.
1.Get the lowest seqnum record for every key with SELECT statement
2. Now SPLICE this file with the other records
Check this link for detailed explanation along with expamples on the SPLICE operator of DFSORT's ICETOOL
http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Wed Jul 28, 2004 6:37 am Post subject: |
|
|
SPLICE did come to my mind. But somehow I tend to avoid using SPLICE as I find it confusing.. I thought if there was a simpler method.
I shall try it out and let you know
Cheers Kolusu..
rgds. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Jul 28, 2004 10:52 am Post subject: |
|
|
mfjin,
The way you show the data, the only difference between the first record of each set and the other records of each set are the X's and the sequence number. Everything else is the same. If that's the way the data really looks, then this DFSORT/ICETOOL job would give you the output you're asking for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=... output file
//TOOLIN DD *
* IN->T1: Get first record with each key
SELECT FROM(IN) TO(T1) ON(1,6,CH) FIRST
* T1/IN->OUT: For each record, make a copy of the first
* record with that key and add in the sequence number
SPLICE FROM(CON) TO(OUT) ON(1,6,CH) WITHALL -
WITH(34,2)
/*
|
mfjin wrote Quote: | SPLICE did come to my mind. But somehow I tend to avoid using SPLICE as I find it confusing.. |
Yes, SPLICE can be a bit difficult to understand, but it's very powerful and well worth the effort. In the doc, I go through lots of examples in excruciating detail so if you read through those examples, you should get a good idea of how to use SPLICE for various tasks. The doc is at:
http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
mfjin Beginner
Joined: 26 Apr 2003 Posts: 94 Topics: 17
|
Posted: Wed Aug 18, 2004 3:15 pm Post subject: |
|
|
Frank,
I finally got to do this and looks like I have got what i wanted. Thanks a lot. Sorry for the delay in responding but i got to finish it off today itself. (At the place where I work you are expected to take on a second piece of work before u finish the first and then a third before the second and go back to the first when u have lost track of it)
Cheers. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Aug 18, 2004 3:43 pm Post subject: |
|
|
Good. Thanks for the feedback. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
|
|