String Searching Methods in a Mainframe

Embed Size (px)

Citation preview

Various Methods of String Search in Mainframes

Table of Contents1 2 INTRODUCTION ......................................................................................................................................... 1 SEARCH-FOR UTILITY (ISPF OPTION 3.14) .......................................................................................... 2 2.1 FOREGROUND SEARCH ................................................................................................................ 3 2.2 BACKGROUND SEARCH ................................................................................................................ 4 2.3 SEARCH USING ............................................................................................................................ 8 2.3.1 Specify Additional Search Strings ....................................................................................................8 2.3.2 Bypass Selection List .....................................................................................................................10 3 EXTENDED SEARCH-FOR UTILITY (ISPF OPTION 3.15).................................................................. 12 3.1 SEARCH USING OPTIONAL OPERANDS ......................................................................................... 15 3.1.1 Word..............................................................................................................................................15 3.1.2 Suffix .............................................................................................................................................16 3.1.3 Prefix .............................................................................................................................................17 3.1.4 C ....................................................................................................................................................18 3.2 PROCESS OPTIONS .................................................................................................................... 19 3.3 STATEMENTS DSN..................................................................................................................... 22 4 USING COMPARE OPTIONS IN SEARCH UTILITY............................................................................ 25 4.1 4.2 5 6 COLUMN CONSTRAINTS .............................................................................................................. 25 EXCLUDING LINES ...................................................................................................................... 26

SEARCH USING REXX ............................................................................................................................. 27 SEARCH USING FILE-AID....................................................................................................................... 28

Various Methods of String Search in Mainframes

1 INTRODUCTIONThis document explains the various methods in which string search can be carried out in mainframes. In general it explains search utility and extended search utility of ISPF, searching strings using REXX programs and FileAid in batch mode. Using the Search Utility and extended search utility, search can be carried out in different ways like searching for one or more strings of data, searching for one or more PDS, searching all the members or only particular members, searching in background or foreground mode, searching within a specific range of columns, excluding lines from being searched. The operands prefix, suffix, word can be used to restrict the strings to be searched.

page 1 of 28

Various Methods of String Search in Mainframes

2 SEARCH-FOR UTILITY (ISPF OPTION 3.14)The Search-For utility can be used to search strings of data from PS/members of a Partitioned Data Set. This utility can be accessed using the Option 3.14 from the ISPF main panel.

It provides string search to be carried out in both Foreground and Background modes.

page 2 of 28

Various Methods of String Search in Mainframes

2.1 Foreground SearchIt is an online search in which the string to be searched is provided in the Search String field, the dataset to be searched for is provided in the Data Set Name field and the output is stored in USERID.SRCHFOR.LIST dataset, where USERID is the tso userid. Execution mode must be set to 1. Only one dataset can be searched in this mode.

In the above example the string PGM=IKJEFT01 is being searched in the PDS ATEST.PAB015.JCLLIB.FMR.HOME. The asterisk is provided at the end of this PDS to indicate that all the members of this PDS are to be searched. The output gets stored in the dataset PAB015.SRCHFOR.LIST. This is the default dataset that gets created at runtime. Any dataset name can be provided to override the default dataset.

page 3 of 28

Various Methods of String Search in Mainframes

2.2 Background SearchThis search generates a JCL which can be submitted in batch mode. The string to be searched and datasets to be searched for will have to be provided in the same manner as in the foreground search. Execution mode must be set to 2.

When the enter key is hit the below screen appears.

page 4 of 28

Various Methods of String Search in Mainframes

This screen gives an option to direct the output to SYSOUT class or a dataset. The job statement information must be provided. If the output is to be directed to a SYSOUT, then option 1 must be selected under Generate Output Type and the output class must be mentioned in the field SYSOUT Class. If the output is to be directed for a dataset then option 2 must be selected under Generate Output Type and the dataset name must be given in the field Data Set Name. When the enter key is hit the below JCL gets generated.

page 5 of 28

Various Methods of String Search in Mainframes

If the output is to be directed for a dataset with the properties other than those shown in the above JCL then select option 3 under Generate Output Type.

page 6 of 28

Various Methods of String Search in Mainframes

Example: Suppose we would like the create a dataset with the space parameter as SPACE= (0,(100,150),RLSE), then provide the information as shown in the screen shot below. All the other parameters (DSN, DCB, DISP) must also be provided.

page 7 of 28

Various Methods of String Search in Mainframes

2.3 Search using2.3.1 Specify Additional Search Strings

When more than one string needs to be searched in a PDS, select the option Specify additional search strings from the Search-For Utility Panel as shown below.

Press the ENTER key and the following screen is displayed on which multiple strings can be entered.

page 8 of 28

Various Methods of String Search in Mainframes

page 9 of 28

Various Methods of String Search in Mainframes

2.3.2

Bypass Selection List

Normally when a string is searched in a PDS, all the members will be included in the search. Whenever only members following certain pattern have to be searched without displaying the member selection list panel then the Bypass selection list has to be selected. Example: Suppose we want to search the string INSURANCE in all the members of the PDS ATEST.PGB005.JCLLIB.FMR.HO which start with P and have the third and fourth letters as GD. Then ATEST.PGB005.JCLLIB.FMR.HO (P%GD*) has to keyed in Data Set Name field. Wild Card Characters

*

Multiple characters Single Character

%

By selecting the bypass selection list as shown below, all the members of the PDS which match the given the pattern will be included in the search without displaying the member selection list panel.

page 10 of 28

Various Methods of String Search in Mainframes

The JCL shows that only those members are being searched which have the pattern described above.

page 11 of 28

Various Methods of String Search in Mainframes

3 EXTENDED SEARCH-FOR UTILITY (ISPF OPTION 3.15)This is an extended search facility which gives more flexibility for string search than the conventional Search-For Utility. This utility can be accessed using the Option 3.15 from the ISPF main panel.

This search provides the flexibility of searching a string in more than one PDS even in foreground mode. See the example below.

page 12 of 28

Various Methods of String Search in Mainframes

When the enter key is pressed the below screen is displayed where more than one dataset name can be mentioned that needs to be searched

page 13 of 28

Various Methods of String Search in Mainframes

page 14 of 28

Various Methods of String Search in Mainframes

3.1 Search using Optional OperandsThe optional operands provide the flexibility of using the conditional search.

3.1.1

Word

The keyword WORD will search the string which is preceded and followed by non alphanumeric character.

Example: The HOWVISTA WORD will search all the occurrences of the word HOWVISTA.

page 15 of 28

Various Methods of String Search in Mainframes

3.1.2

Suffix

The keyword SUFFIX will search the string which is preceded by alphanumeric character and followed by non alphanumeric character.

Example: The VISTA SUFFIX will search all the occurrences of the string where VISTA is used as suffix like HOWVISTA.

page 16 of 28

Various Methods of String Search in Mainframes

3.1.3

Prefix

The keyword PREFIX will search the string which is preceded by non alphanumeric character and followed by alphanumeric character.

Example: The HOW PREFIX will search all the occurrences of the string where HOW is used as prefix like HOWVISTA.

page 17 of 28

Various Methods of String Search in Mainframes

3.1.4

C

The keyword C will search the string which is in the same line as that of the immediate previous keyword search string.

Example: Only those lines will be selected which have both LOAD and CUT in the same line.

page 18 of 28

Various Methods of String Search in Mainframes

3.2 Process OptionsSearch can be customized using this option.

Some of the options that can be used are: ANYC : ANYC stands for ANY CASE. Using this option causes the search not to be case sensitive. The lowercase strings will be converted to uppercase in the dataset to be searched before search begins. ALLMEMS : ALLMEMS stands for ALL MEMBERS. Using this option even the alias can be included in the search, which otherwise is not included. APNDLST : APNDLST stands for APPEND LIST. Using this option causes the output dataset to be appended with the earlier search. Hence if 3 different searches were carried out then all 3 searchs outputs would be present in the output dataset without erasing the earlier search output. COBOL : This option would be useful when the dataset to be searched is a COBOL program or a COBOL copybook. In this option the columns 1 6 would not be searched as these are used for line numbering in COBOL. DPACMT : DPACMT stands for DONT PROCESS ASTERISK COMMENTS. This option can be useful when the dataset to be searched is an Assembler program. In this option the line that has asterisk (*) in column 1 will be skipped from being searched as this line is a comment inpage 19 of 28

Various Methods of String Search in Mainframes

Assembler. Hence if the comments have to be excluded from the search in Assembler this option can do that. DPFTCMT : DPFTCMT stands for DONT PROCESS FORTRAN COMMENTS. This option can be useful when the dataset to be searched is a FORTRAN program. In this option the line that has C in column 1 will be skipped from being searched as this line is a comment in FORTRAN. Hence if the comments have to be excluded from the search in FORTRAN this option can do that. DPCBCMT : DPCBCMT stands for DONT PROCESS COBOL COMMENTS. This option can be useful when the dataset to be searched is a COBOL program. In this option the line that has asterisk (*) in column 7 will be skipped from being searched as this line is a comment in COBOL. Hence if the comments have to be excluded from the search in COBOL this option can do that.

DPCPCMT : DPCPCMT stands for DONT PROCESS C++ COMPILER COMMENTS. This option can be useful when the dataset to be searched is a C++ program. In this option the line that has // (end of line) will be skipped from being searched as this line is a comment in C++. Hence if the comments have to be excluded from the search in C++ this option can do that. FINDALL : When multiple strings are being searched using this option ,if all the strings are found the return code of the Job will be 1 and if any/none of the strings are found then the return code will be 0.FMSTOP : When the first occurrence of the string to be searched is found in the dataset /member of a PDS the search terminates for that dataset/member, and the next dataset/ member of the PDS is selected for searching. IDPFX : IDPFX stands for ID Prefix. Using this option causes the member name to be prefixed to the line that has the string being searched in the output dataset. LMTO : LMTO stands for LIST MEMBER TOTAL. Using the option causes the members searched, the number of lines in which string has been found and the total number of lines searched in that member will be displayed in the output dataset. This option does not display the actual line that contains the string. LNFMTO : LNFMTO stands for LIST NOT FOUND MEMBER TOTAL ONLY. This option is opposite to LMTO. Here only those member names are displayed which are searched and the string has not been found. LTO : LTO stands for LIST TOTAL ONLY. This option causes only the number of members in which the string was found, the number of members in which the string was not found, number of lines in which the string was found, number of lines in which the string was not found to be displayed. It does not display the member names, the actual lines in which the string was found. LPSF : LPSF stands for LAST PREVIOUS SEARCH-FOR. This option causes the preceding 6 lines and following 6 lines to be displayed along with the line that contain the string being searched, provided the same line should have been present in the previous search also.page 20 of 28

Various Methods of String Search in Mainframes

SEQ : SEQ stands for SEQUENTIAL. This option excludes the dataset that has RECFM = FB, LRECL= 80 and RECFM = VB, LRECL= 255 from being searched. NOSEQ : NOSEQ stands for NO SEQUENTIAL. This option searches the dataset that has RECFM = FB, LRECL= 80 and RECFM = VB, LRECL= 255. NOSUMS : NOSUMS stands for NO SUMMARY LISTING SECTION. This option causes the summary section in the output dataset from not being displayed. The summary section consists of the number of members in which the string was found, the number of members in which the string was not found, number of lines in which the string was found, number of lines in which the string was not found SDUPM : SDUPM stands for SEARCH DUPLICATE MEMBERS. This option causes the duplicate member names to be searched whenever multiple PDS are searched for a string.

page 21 of 28

Various Methods of String Search in Mainframes

3.3 Statements DSNUsing Statements DSN all the control cards can be placed in a dataset and when the search is carried out in a batch mode these control cards are copied into the SYSIN DD * statement .To place a control card type E on the Extended Search-For Utility Panel.

Then hit the Enter Key. A dataset by name USERID.SRCHFOR.STMTS will be created as shown below. Here we can enter the control card that is needed for the search.

page 22 of 28

Various Methods of String Search in Mainframes

Here the control card SRCHFOR DATABASE, W is used to search the word DATABASE. In the below screen we can see that this control card is being placed in SYSIN DD * statement in JCL.

page 23 of 28

Various Methods of String Search in Mainframes

page 24 of 28

Various Methods of String Search in Mainframes

4 USING COMPARE OPTIONS IN SEARCH UTILITY4.1 Column ConstraintsIf a string has to be searched within a specified column range then this option will be useful. By entering the range of the column in control card (i.e. in the SYSIN DD *) the search will be limited within this column range. Example: Suppose we want to search the string Ohio within the column 10-15 and 30-45 then the control card CMPCOLM 10:15 30:45 has to be specified in the Statements DSN dataset.

page 25 of 28

Various Methods of String Search in Mainframes

4.2 Excluding linesWhenever certain lines having a particular string have to be excluded from being searched, then this option can be used. Example: Suppose we want to exclude the lines that contain the string Ohio within the column 10-15 and 3045 then the control card DPLINE Ohio 10:15 30:45 has to be specified in the Statements DSN dataset.

page 26 of 28

Various Methods of String Search in Mainframes

5 SEARCH USING REXXString can be searched using the REXX program as shown below. Enter the name of the PDS in which string is to be searched and enter the search string. This program will list the member names and line numbers where the search string is found.

/* REXX */ SAY "ENTER PDS NAME TO BE SEARCHED" PULL DSN SAY "ENTER STRING TO BE SEARCHED" PULL SEARCH_STR LINE.0 = 0 CALL OUTTRAP "LINE.","*" "LISTDS '"DSN"' MEMBERS" CALL OUTTRAP "OFF" NUM_MEMBERS = LINE.0 - 6 IF NUM_MEMBERS < 0 THEN NUM_MEMBERS = 0 SAY NUM_MEMBERS "MEMBERS PRESENT IN DATASET" DO I = 7 TO LINE.0 PARSE VAR LINE.I MEMER . CALL PROCESS_EACH_MEMBER MEMBER END I EXIT PROCESS_EACH_MEMBER: ARG MEMBER DATASET_PLUS_MEM = DSN"("MEMBER")" DATASET_PLUS_MEM = "'"DATASET_PLUS_MEM"'" "ALLOC DSN("DATASET_PLUS_MEM") DDN(INFILE01) SHR REUSE" "EXECIO * DISKR INFILE01 (STEM INFILE01. FINIS)" "FREE DDN(INFILE01)" DO J = 1 TO INFILE01.0 IF POS(SEARCH_STR,INFILE01.J) > 0 THEN DO SAY "SEARCHED STRING - " SEARCH_STR SAY "FOUND IN RECORD NUMBER " J SAY "OF " DATASET_PLUS_MEM END END J RETURN

page 27 of 28

Various Methods of String Search in Mainframes

6 SEARCH USING FILE-AIDString search can be carried out using file aid in batch mode. The JCL searches the string mangalore1 in the PDS ATEST.PAB015.JCLLIB.FMR.HOME, ATEST.PAB015.JCLLIB.FMR.FIRE. If the string is found in a member then the entire member is copied to output dataset

ATEST.PAB015.SCAN.FILE.

//PAB015FA JOB (AMI00-T1-HOS-3S),'FILE-AID',MSGLEVEL=(1,1), // CLASS=T,MSGCLASS=X,REGION=4M,NOTIFY=PAB015 //* TYPRUN=SCAN, //********************************************************* //SCANSTP2 EXEC PGM=FILEAID //DD01 DD DSN=ATEST.PAB015.JCLLIB.FMR.HOME, // DISP=SHR // DD DSN=ATEST.PAB015.JCLLIB.FMR.FIRE, // DISP=SHR //DD01O DD DSN=ATEST.PAB015.SCAN.FILE, // UNIT=SYSDA, // DISP=(,CATLG,CATLG), // SPACE=(CYL,(10,20,25),RLSE), // DCB=(*.DD01) //* DCB=ATEST.PAB015.SIMPLE //SYSPRINT DD SYSOUT=X //SYSIN DD * $$DD01 COPYMEM IF=(1,0,C'mangalore1')

page 28 of 28