IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Searching a string in a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
arnab

New User


Joined: 13 Mar 2006
Posts: 59
Location: UK

PostPosted: Tue Jul 03, 2007 1:30 pm
Reply with quote

Hi,

I have a requirement to search a text in a file . for eg.
File 1 contains the list of strings which I want to search.
LRECL: 80, the strings are present in cols 1:8.

File 2 is also of LRECL 80 but it may/maynot contain the above strings but in any position.

I want to read each record from file 1( 1:8) and search the same in File 2.
If the record is found, write the string(1:8) into the o/p file.

Is it posiible o achive this using SORT/ICETOOL? If so please provide me the code. If you need any more details please let me know.

Thanks for your time and help.!
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Jul 03, 2007 1:37 pm
Reply with quote

Arnab,

Quote:
File 1 contains the list of strings which I want to search.
LRECL: 80, the strings are present in cols 1:8.


How many records/strings are you expecting? If the limit is within include cond using file1, we can prepare sort card in runtime and search the req string in file2.
Back to top
View user's profile Send private message
arnab

New User


Joined: 13 Mar 2006
Posts: 59
Location: UK

PostPosted: Tue Jul 03, 2007 1:45 pm
Reply with quote

File 1 contains around 1500 recs.. If this is an issue then we can split the file into lesser number of records and run also.

Thanks,
Arnab
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Jul 03, 2007 2:15 pm
Reply with quote

Arnab,

Quote:
If the record is found, write the string(1:8) into the o/p file.

Which file data? File1 or File2.
Back to top
View user's profile Send private message
arnab

New User


Joined: 13 Mar 2006
Posts: 59
Location: UK

PostPosted: Tue Jul 03, 2007 2:18 pm
Reply with quote

Murali,

Data from File 1 i.e the 8 bytes should come in the o/p.

Thanks again.!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jul 03, 2007 8:12 pm
Reply with quote

Arnab,

It's not clear what exactly what you're trying to do or what you want for output. Can there be duplicates within file1? Can a string from file1 be found in only one record in file2, or can it be found in multiple records in file2? Do you want only one instance of a string in the output file, or do you want one instance of the string for each record that has that string?

Do you want the output sorted by the string values or in the original order of the file2 records?

Please show an example of the records in each input file and what you expect for output.
Back to top
View user's profile Send private message
arnab

New User


Joined: 13 Mar 2006
Posts: 59
Location: UK

PostPosted: Wed Jul 04, 2007 9:00 am
Reply with quote

Hi Frank,

there can be no duplicates in FILE1 but there can be multiple occurences of the string in FILE2. My requirement is: IF there is even one occurence of the string from file1 in file2 , I should have the string as o/p . basically I have a list of jobs for an application in FILE1. File 2 contains all the schedules of this application. Now I have to find all the jobs which are there in the schedule. Instead of manually finding them I want to do it using a sort/ICETOOL.

for eg file1 contains:

PIUPDSD

in File 2:

JOB PIUPDSD
RUN TODAY;

Now File 3 should contain PIUPDSD.

Please let me know if you need any more information.

Also I would like to know How to create SORTCARDS a runtime.

Thanks and regards,
Arnab
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 04, 2007 8:58 pm
Reply with quote

Let's call what you're looking for the jobname:

Is the jobname always in the same place in file2 or can it be in different places in different records? Can a record in file2 have more than one jobname or can it only have one jobname?

Please give a better example of the input records (with more jobnames that are found and not found) and what you want for output. Showing one instance does not help much. Also, please use ubb code tags around the examples, e.g. <code> before the records and </code> after the records with [ instead of < and ] instead of > so we can see the spaces in the records.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top