Page 1 of 2

Trying to search a word in the file

PostPosted: Sat Jul 18, 2009 8:05 pm
by rajas.abcdefg
Hi,

I am trying to search a word in the file of record lenth 150, if the word encounters it had to display the complete line. I have used an utility but the constraint of this is it will check between 1:72 columns and display the record upto 114 characters, but I want my output with all the characters in the encountered record..

Plz help me in achieving this....

Re: Trying to search a word in the file

PostPosted: Sun Jul 19, 2009 2:58 am
by dick scherrer
Hello,

When you have a new question, you need to start a new topic for the new question rather than posting a reply to some unrelated, existing topic.

Which utility are you using? Which utility do you want to use?

You can probably get whay you want using the sort product on your system. WHich sort is used? If you are not sure, run a sort and the product/release info should be shown in the output.

Re: Trying to search a word in the file

PostPosted: Mon Jul 20, 2009 8:47 pm
by Frank Yaeger
rajas,

Please give an example of the records in the input file and what you expect for output. Is the "word" always the same (if so, what is it) or does it vary (if so, give examples)? Will the word be in a specific place in the record (what positions) or can it be anywhere in the record? What is the RECFM of the input file?

Re: Trying to search a word in the file

PostPosted: Sun Jul 26, 2009 6:04 am
by rajas.abcdefg
Hi Frank,

Sorry for the delayed response ..!

The word I am searching is same all the time. like " TIME" WHICH IS UNIQUE IN MY FILE
Most of the times the word will be at the row 15 and the length of the row is 150 characters.

But on very rare occsaions the row might shift to some few other rows but the word remains the same.


One more question:
In my file, I have another word " IN " same word occurrences for many times, but I need the first occured record. Will this be possible.
If so, sample code is appreciable.

Thanks Raj

Re: Trying to search a word in the file

PostPosted: Mon Jul 27, 2009 8:39 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for. Just plug in the word you need to find.

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input (FB/150)
//SORTOUT DD DSN=...  output (FB/150)
//SYSIN    DD    *
  OPTION COPY,STOPAFT=1
  INCLUDE COND=(1,150,SS,EQ,C' IN ')
/*

Re: Trying to search a word in the file

PostPosted: Mon Aug 03, 2009 8:22 pm
by rajas.abcdefg
Thanks a bunch Mr Frank.

Could you please clarify my queries below.

1. what does 'ss' in the Include cond statement represents? and its importance.

Re: Trying to search a word in the file

PostPosted: Mon Aug 03, 2009 8:40 pm
by Frank Yaeger
SS is substring search. For details, see:

http://publibz.boulder.ibm.com/cgi-bin/ ... 0528171007

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: Trying to search a word in the file

PostPosted: Sun Aug 09, 2009 9:09 pm
by rajas.abcdefg
Hi Frank,

As like 'IN' , I have two more words 'REPORT' AND 'OUTPUT' which occurs more than once, but I want to copy the first occurence of these two words also along with 'IN'.

will it be possible for me with a single sort step.

Thanks in advance

Re: Trying to search a word in the file

PostPosted: Mon Aug 10, 2009 9:17 pm
by Frank Yaeger
You want to copy the records with the first occurrence of 'IN', 'REPORT' and 'OUTPUT'? Are they in separate records or can they be in the same record?

Please show an example of the input records and expected output records for the various cases you have to deal with. You said the LRECL of the input file is 150. Is the RECFM FB or VB?

Re: Trying to search a word in the file

PostPosted: Sun Aug 16, 2009 9:52 am
by rajas.abcdefg
Hi Frank,

Thanks for your support.

Yes, I want to copy the first occurence of the words into a new file using single JCL.

The words will always be in separate records.

abcd
1234
sakfhhsfa IN54434
sajdfhsh543446454
asjdfj IN sahdfkh
askhdfhsaf REPORT ashf444
tweoruqwprqj IN ashfdlsdfwqr
werqiouelrj REPORT 653744135
ioweuqr237869450 OUTPUT6879777977
sakfhhsfa IN54434
sajdfhsh543446454
asjdfj IN sahdfkh
askhdfhsaf REPORT ashf444
tweoruqwprqj IN ashfdlsdfwqr
werqiouelrj REPORT 653744135