MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DFSORT : Find and replace

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Tue Jul 27, 2004 5:01 am    Post subject: DFSORT : Find and replace Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jul 27, 2004 5:22 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Tue Jul 27, 2004 5:53 am    Post subject: Reply with quote

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
View user's profile Send private message
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Tue Jul 27, 2004 6:04 am    Post subject: Reply with quote

>>>>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
View user's profile Send private message
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Tue Jul 27, 2004 4:15 pm    Post subject: Reply with quote

Sad 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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Jul 28, 2004 5:35 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Wed Jul 28, 2004 6:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jul 28, 2004 10:52 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
mfjin
Beginner


Joined: 26 Apr 2003
Posts: 94
Topics: 17

PostPosted: Wed Aug 18, 2004 3:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Aug 18, 2004 3:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group