View previous topic :: View next topic
|
Author |
Message |
madprasy
New User
Joined: 08 Apr 2008 Posts: 34 Location: Chennai
|
|
|
|
Scenario :
I have 10 files and my search string has 3 to 10 matching occurence in each of the file. Yet, I require only the first occurence of each file and ignore rest of them.
What would be the best way we can do it IBM mainframes.
1) If I use SORT, then that would lead to concatenating all the 10 files
2) If I use SRCHFOR in TSO, then I would get only the matching files but not the data inside it.
Please provide your knowledge on this. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can you clarify your task please. If you are searching for something, and you find it, then you know the content.
Show some sample data, and expected output, and explain better why you think neither SORT nor SRCHFOR are going to give you what you want. |
|
Back to top |
|
|
madprasy
New User
Joined: 08 Apr 2008 Posts: 34 Location: Chennai
|
|
|
|
A.TXT
BILL123
PRAS123
DBZ456
PRAS456
B.TXT
NEO123
PRAS890
JACK123
PRAS123
C.TXT
ABC123
PRAS789
XYZ123
PRAS789
Now, from the above three files, I need to fetch only the records containing with "PRAS" in the first occurence of each file into a seperate output file
OUT.TXT
PRAS123
PRAS890
PRAS789
Note: I have ignored,
PRAS456 from A.TXT
PRAS123 from B.TXT
PRAS789 from C.TXT
Whats the most optimum was we can achieve this ? |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
You can try something like below:
Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
BILL123
PRAS123
DBZ456
PRAS456
//IN2 DD *
NEO123
PRAS890
JACK123
PRAS123
//IN3 DD *
ABC123
PRAS789
XYZ123
PRAS789
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT) USING(CTL1)
COPY FROM(IN2) TO(OUT) USING(CTL1)
COPY FROM(IN3) TO(OUT) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY,STOPAFT=1
INCLUDE COND=(1,4,CH,EQ,C'PRAS') |
I don't have DFSORT, but SYNCSORT. Couldn't test it. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It'll need DISP=MOD on OUT when it has an actual DSN and will require that all inputs are either variable-length, or fixed-length of the same size.
Other than that, an efficient way to do it - until TS/OP comes up with a change to the requirement. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks Bill. I completely missed the DISP=MOD part . |
|
Back to top |
|
|
madprasy
New User
Joined: 08 Apr 2008 Posts: 34 Location: Chennai
|
|
|
|
Thank You! ICETOOL.. Thats the spark.. Thanks for it.. |
|
Back to top |
|
|
|