View previous topic :: View next topic
|
Author |
Message |
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
Hi,
Can anyone of you help me to solve my following query?
I need to search for a string in a PS file(Record format : FS and Block size : 4566) and to write only the first occurence of the string in output file.
The string I am searching can be anywhere in the input PS file multiple times. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Cartinga, Welcome..
What is SORT product you are using?
Do you want whole record to be written into output where search string is found for first time? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Cariga,
Here's an example of a DFSORT job that will do what I think you asked for. I assumed your input file has RECFM=FB and LRECL=80 and the string you are looking for is 'TARGET', but the job can be changed appropriately for other LRECLs and target strings.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCC TARGET CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEE TARGET EEEEEEEEEEEEEEEEEEE
FFFFFFFFF TARGET FFFFFFF TARGET EEEEEEEEEEEEEEEEEEE
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,STOPAFT=1
INCLUDE COND=(1,80,SS,EQ,C'TARGET')
/*
|
For this example, SORTOUT would have:
Code: |
CCCCCCCCCCC TARGET CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
|
|
|
Back to top |
|
|
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
Hi Frank... I got the expected output from your help. Thank you Very much!!!
Hi Sambhaji... Thanks for your response! |
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
Hi Yaeger,
I have a similar requirement , the difference is instead of whole record , I need TO WRITE only the search string in the SORTOUT.E.g the output should be :
TARGET
how can i change this SORT to achive this ..please ? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Huh? That makes no sense. Your requirement is to search for 'TARGET' and write out 'TARGET'? There must be more to it than that or you could just write one record with 'TARGET' without searching anything.
Please do a better job of explaining your real requirement. |
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
oops ..I missed to mention that there might be more than one search word in INCULDE COND and I want to write that word which gets a hit in the file . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you show some sample input including any/all situations and the output you want from that sample input. . . |
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
My requirement is as follows:
I have few key words ( approx 5 ) TARGET1,TARGET2,TARGET3,TARGET4,TARGET5
I need to search these key words in a file ( PS , RECL=80) , The string (Key word) can be present anywhere in the file . ( same way as it was asked in the intial question)
If, lets say TARGET1 is present int the file , My output should have :
TARGET1
If TARGET1 is not found ..then dont write it in output. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Your requirement is still not completely clear.
What output do you want if TARGET1 and TARGET2 are present in the file?
What output do you want if TARGET1 is present twice in the file and TARGET3 is present three times in the file? |
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
Those string which are found should come in OUTPUT , If TARGET1 and TAGET2 both are present then output should contain :
TARGET1
TARGET2
Multiple occurence or only 1 occurence both has to treated as HIT .TARGET1 may appear 100 times in file , My requirement is to just check if TARGET1 ( and other key words) are present in file or not irrespective of their occurence .
Sorry for not being so clear in my requirement |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's one way to do what you asked for with DFSORT/ICETOOL:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/80)
//TOOLIN DD *
SPLICE FROM(IN) TO(T1) ON(1,1,CH) WITHANY -
WITH(2,7) WITH(9,7) WITH(16,7) WITH(23,7) WITH(30,7) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,80,SS,EQ,C'TARGET1',OR,
1,80,SS,EQ,C'TARGET2',OR,
1,80,SS,EQ,C'TARGET3',OR,
1,80,SS,EQ,C'TARGET4',OR,
1,80,SS,EQ,C'TARGET5')
INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(STARTAT=C'TARGET1',FIXLEN=7)),
HIT=NEXT),
IFTHEN=(WHEN=INIT,PARSE=(%02=(STARTAT=C'TARGET2',FIXLEN=7)),
HIT=NEXT),
IFTHEN=(WHEN=INIT,PARSE=(%03=(STARTAT=C'TARGET3',FIXLEN=7)),
HIT=NEXT),
IFTHEN=(WHEN=INIT,PARSE=(%04=(STARTAT=C'TARGET4',FIXLEN=7)),
HIT=NEXT),
IFTHEN=(WHEN=INIT,PARSE=(%05=(STARTAT=C'TARGET5',FIXLEN=7)),
BUILD=(X,%01,%02,%03,%04,%05))
OUTFIL FNAMES=T1,BUILD=(2,7,/,9,7,/,16,7,/,23,7,/,30,7)
/*
//CTL2CNTL DD *
OMIT COND=(1,7,CH,EQ,C' ')
/*
|
|
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
Thanks much Frank for your support and time .
A small doubt .. Can i extend the control carrd ( CTL1CNTL ) for a large number of key words (TARGET's) ( lets say more than 500) ..just wondering if there is any practical limit which could restrict my requirement for going beyond 5 key words .
Thanks a lot ! |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The limit would be 100 keywords due to the limit of 100 %nn parse fields (%00-%99). |
|
Back to top |
|
|
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
Hi everybody,
Can you tell me how we can search a first occurence of a string of a file1 one by one in a file2(which is a PS as in this post) and print the string in a file3(O/P) if the string exist once in file2 and print the string in file4(O/P) if the string is not present in file2.
File1:
AIIP1120D
AIIP010I
BIIBMCTG
CIF300IA
BI300I9BC
etc...
Actually i want to know how we can pass the string in file1(I/P) one by one to a search process!!??
Can anyone of you please help! |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I don't understand what you're trying to do.
Are you trying to use DFSORT to do this? If so, you need to do a better job of explaining what it is exactly you want to do.
Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example. |
|
Back to top |
|
|
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
Hi Frank,
I have an inptut file(file1) which is a PS of recfm=fB, BLKSIZE=0, and LRECL=10 and it contains strings of 8 or 9 characters. There is no dupliactes in the input file(file1).
I want to search these strings of file1 in file2 which is a PS of RECFM=FS, BLKSIZE=4566, and LRECL=0 which can have the strings of file1 more than once. That is file2 in which I am searching the strings can have duplicates.
Say I am searching the first string of file1 in file2 and if it is present in the file2, I need to print the only teh first occurance of the string in output(file3) which is also a PS of recfm=fB, BLKSIZE=0, and LRECL=10.
If the string is not present, I need to print the string in output(file4) which is also a PS of recfm=fB, BLKSIZE=0, and LRECL=10.
Ex of file1 :-
AIIP1120D
AIIP010I
BIIBMCTG
,etc...
I want to take the strings in file1 one by one and search in file2.
Ex of file2:-
sjkfkfkghdfkhgkhgdjglnfr,0dfbgj98-45=bfd09ojl AIIP1120D kfhghkfb,49-jioh5y47585y AIIP1120D 9870igjgg0[tp==jouhr/.lpfldkkhkghkhfhighfighfihg[jy97jiAIIP010I87gh8t23879yg=-0-587o8ekdy8,m.lk;;.ds,jk AIIP010I iuyi7kgggggggggggggggggggggygjgjgj
Ex of File 3 and File 4 :-
File3
-----
AIIP1120D
AIIP010I
File4
-----
BIIBMCTG
Hope my requirement is clear. Please tell your thoughts and let me know if my requirement is still not clearThanks. |
|
Back to top |
|
|
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
I am trying to develop this in DFSORT and also trying in REXX. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
cartiga wrote: |
Hi Frank,
I have an inptut file(file1) which is a PS of recfm=fB, BLKSIZE=0, and LRECL=10 and it contains strings of 8 or 9 characters. There is no dupliactes in the input file(file1).
I want to search these strings of file1 in file2 which is a PS of RECFM=FS, BLKSIZE=4566, and LRECL=0 which can have the strings of file1 more than once. That is file2 in which I am searching the strings can have duplicates. |
Catiga,
LRECL of 0 for FS file? or was it a typo? |
|
Back to top |
|
|
cartiga
New User
Joined: 27 Jan 2010 Posts: 6 Location: Chennai
|
|
|
|
Hi SKolusu,
I have a PS file of FS and record length 0. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
I have a PS file of FS and record length 0. |
????? How can you have a record length of 0? |
|
Back to top |
|
|
milind suman Warnings : 1 New User
Joined: 19 Aug 2009 Posts: 55 Location: Pune
|
|
|
|
Hi Frank ,
I assume the File2 Has Record length of 80 and FB . Could you suggest the solution. The record length attritube can be altered once the basic logic is understood .
Thanks ! |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
What is the maximum number of records you can have in file1? |
|
Back to top |
|
|
|