Search for a string using SORT
- From: "mftips@xxxxxxxxx" <mftips@xxxxxxxxx>
- Date: 7 Feb 2006 18:32:01 -0800
To Search for a particular string within a file when the exact position
of that string within a record is not known and to write that record in
the Output file the following SORT card can be used.
Example 1:
SORT FIELDS=COPY
INCLUDE COND= (1, 80, SS, EQ, C'FIND STRING')
Here,
SS - Sub string,
1 - Starting position of the range
80 - Width of the search range
EQ - Comparison operators
The Sort card for this will need information like range of columns
within which you want the search to be performed. To search in the
whole file you can give the start position as 1 and LRECL of the file
as the width of the search range as done above. We can also replace the
'EQ' parameter by 'NE' which will fetch us all the records which don't
have the specified string. Only EQ & NE can be used for comparison. We
can even use OMIT COND instead of INCLUDE.
This can also be used to find the records with string that match one of
the strings in the COND.
Example 2:
SORT FIELDS=COPY
INCLUDE COND= (1, 80, SS, EQ, C'HDR,TRL')
The above sort card returns all records with the substring ' HDR' or
'TRL' occurring within the search range(1-80) of the record in the
input file.
Thanks,
MFTIPS
http://mftips.blogspot.com/
.
- Follow-Ups:
- Re: Search for a string using SORT
- From: Howard Brazee
- Re: Search for a string using SORT
- Prev by Date: Re: File declarations in the Environment and Data division
- Next by Date: Search for a string using SORT
- Previous by thread: IBM announces various "relase" withdrawals from support
- Next by thread: Re: Search for a string using SORT
- Index(es):
Relevant Pages
|