f



Search for a string using SORT #2

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/

0
mftips (9)
2/8/2006 2:32:03 AM
comp.lang.cobol 4273 articles. 1 followers. Post Follow

6 Replies
874 Views

Similar Articles

[PageSpeed] 10

mftips@gmail.com wrote:
> 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.
>...

Your examples are actually incorrect.  Your control statements contain
blanks that will result in syntax errors.  For example 1, the INCLUDE
statement should be:

   INCLUDE COND=(1,80,SS,EQ,C'FIND STRING')

Your second example does NOT do what you say it does.

   INCLUDE COND=(1,80,SS,EQ,C'HDR,TRL')

will actually include records with the string 'HDR,TRL' in them.  To
include records with the string 'HDR' or the string 'TRL' in them, you
would use this DFSORT INCLUDE statement:

   INCLUDE COND=(1,80,SS,EQ,C'HDR',OR,
                1,80,SS,EQ,C'TRL')

To include records with the string 'HDR' or the string 'TRL' in
positions 11-13, you could use this DFSORT INCLUDE statement:

   INCLUDE COND=(11,3,SS,EQ,C'HDR,TRL')

For those who are 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:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
yaeger (25)
2/9/2006 5:51:29 PM
mftips@gmail.com wrote:
> 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.
>...

Your examples are actually incorrect.  Your control statements contain
blanks that will result in syntax errors.  For example 1, the INCLUDE
statement should be:

   INCLUDE COND=(1,80,SS,EQ,C'FIND STRING')

Your second example does NOT do what you say it does.

   INCLUDE COND=(1,80,SS,EQ,C'HDR,TRL')

will actually include records with the string 'HDR,TRL' in them.  To
include records with the string 'HDR' or the string 'TRL' in them, you
would use this DFSORT INCLUDE statement:

   INCLUDE COND=(1,80,SS,EQ,C'HDR',OR,
                1,80,SS,EQ,C'TRL')

To include records with the string 'HDR' or the string 'TRL' in
positions 11-13, you could use this DFSORT INCLUDE statement:

   INCLUDE COND=(11,3,SS,EQ,C'HDR,TRL')

For those who are 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:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
yaeger (25)
2/9/2006 5:51:33 PM
On 9 Feb 2006 09:51:33 -0800, yaeger@us.ibm.com wrote:

>For those who are 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:
>
>www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
>
>Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
>Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
>=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/


What happened to
HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
?
0
howard (6283)
2/9/2006 5:59:43 PM
Howard Brazee wrote:
> What happened to
> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
> ?

Howard,

Sorry, but I don't understand your question.  Are you looking for an
Appendix in a specific DFSORT book?  If so, which Appendix in which
book?  If not, please clarify.

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
yaeger (25)
2/9/2006 6:09:16 PM
On 9 Feb 2006 10:09:16 -0800, yaeger@us.ibm.com wrote:

>> What happened to
>> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
>> ?
>
>Howard,
>
>Sorry, but I don't understand your question.  Are you looking for an
>Appendix in a specific DFSORT book?  If so, which Appendix in which
>book?  If not, please clarify.

I had it as a link written in as documentation for a job.  It no
longer points to anything and I want to update my documentation with
wherever that old documentation was moved to.   Trouble is, I don't
remember what it said.
0
howard (6283)
2/9/2006 6:34:23 PM
Howard Brazee wrote:
> On 9 Feb 2006 10:09:16 -0800, yaeger@us.ibm.com wrote:
>
> >> What happened to
> >> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
> I had it as a link written in as documentation for a job.  It no
> longer points to anything and I want to update my documentation with
> wherever that old documentation was moved to.   Trouble is, I don't
> remember what it said.

Sorry, I don't know what that used to point to so I can't help.

If you're looking for the DFSORT books, you can access them all from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
yaeger (25)
2/10/2006 5:40:41 PM
Reply: