Trying to search a word in the file



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Trying to search a word in the file

Postby rajas.abcdefg » Sat Jul 18, 2009 8:05 pm

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....
rajas.abcdefg
 
Posts: 38
Joined: Thu Jul 09, 2009 8:56 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trying to search a word in the file

Postby dick scherrer » Sun Jul 19, 2009 2:58 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Trying to search a word in the file

Postby Frank Yaeger » Mon Jul 20, 2009 8:47 pm

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?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Trying to search a word in the file

Postby rajas.abcdefg » Sun Jul 26, 2009 6:04 am

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
rajas.abcdefg
 
Posts: 38
Joined: Thu Jul 09, 2009 8:56 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trying to search a word in the file

Postby Frank Yaeger » Mon Jul 27, 2009 8:39 pm

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 ')
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Trying to search a word in the file

Postby rajas.abcdefg » Mon Aug 03, 2009 8:22 pm

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.
rajas.abcdefg
 
Posts: 38
Joined: Thu Jul 09, 2009 8:56 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trying to search a word in the file

Postby Frank Yaeger » Mon Aug 03, 2009 8:40 pm

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
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Trying to search a word in the file

Postby rajas.abcdefg » Sun Aug 09, 2009 9:09 pm

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
rajas.abcdefg
 
Posts: 38
Joined: Thu Jul 09, 2009 8:56 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trying to search a word in the file

Postby Frank Yaeger » Mon Aug 10, 2009 9:17 pm

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?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Trying to search a word in the file

Postby rajas.abcdefg » Sun Aug 16, 2009 9:52 am

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
rajas.abcdefg
 
Posts: 38
Joined: Thu Jul 09, 2009 8:56 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post