Search using SRCHFOR Command

 

SRCHFOR primary command to search for one or more strings of data, this command can be used to search for a string in

  • Sequential data sets
  • Partitioned data sets
  • Individual members of partitioned data sets
  • Concatenated data sets

You can search for more than one string in a single pass. You can also search for strings that occur within the same line.

 

SRCHFOR   – Searches for a text string in the given data set(s)

SRCHFORC – Searches for a text string on the same input line as the previous                                   search command.

Command Syntax

 

SRCHFOR or SRCHFORC   ‘string’   [,t]   [,start position] [:stop position]

‘String’ – String to be searched

‘t’ –Type of Search

  • Blank (default) – search for any occurrence of the string
  • P (Prefix) – First part of a complete word , e.g. “off” can be first 3 bytes of official or office
  • S (Suffix) – Last part of a complete word , e.g. “ing” can be last 3 bites of rolling or calling
  • W (complete word) – A complete word separated by spaces or end of line

Start Position – Column where search should start , positions to be left are ignored

Stop Position – Column where search should end , positions to the right are ignored

 

Examples

  • SRCHFOR ‘Country’, 1:10

Searches for the word Country between columns 1 and 10

  • SRCHFOR ‘Country India’, W

Searches for the string ‘Country India’ as a word in any line

  • SRCHFOR ‘ling’, s

Searches for the string ‘ling’ as a word sufix

  • SRCHFOR ‘India’, 25

Searches for the string ‘India’ in columns 1 to 25

  • SRCHFOR ‘Name’ followed by SRCHFORC ‘Sara’

Searches for ‘Sara’ occurring on the same line having string ‘Name’

 

Batch Processing

 

//SRCHJOB    JOB,CLASS=A,NOTIFY=&SYSUID    

//SEARCH   EXEC PGM=ISRSUPC,PARM=(‘SRCHCMP,ANYC’)    

//NEWDD   DD   DSN=USERID.PDS1,DISP=SHR    

//        DD   DSN=USERID.PDS2,DISP=SHR

//        DD   DSN=USERID.PDS3,DISP=SHR    

//OUTDD   DD   SYSOUT=*    

//SYSIN   DD     *  

 SRCHFOR ‘NEEDLE’,W,10:20

/*    

//

This Job will search for the string ‘NEEDLE’ in all the PDS given in NEWDD and the output will be routed to SYSOUT (in this example) or the file given in OUTDD

 

Mainframe Wiki © 2015 Frontier Theme