®

IBM Software Group Group IBM Developer for z Systems

IDz Search Options – Deep Dive

IDz Jon Sayles – jsayles@us..com ADFz RDz v9.5 IBM Trademarks and Copyrights © Copyright IBM Corporation 2008 through 2021.

All rights reserved – including the right to use these materials for IDz instruction.

The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates.

This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way.

IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBM Rational products and services are trademarks or registered trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others.

2 UNIT The IDz Workbench

Topics:

▪ z/OS Remote Search ▪ Program Search

3 Remote Systems Search – Options There are three Remote Search options:

0. Remote Index Search – not a recommended option • Can be expensive (mainframe resources) • Produces static search results • Not as powerful as other search options • May be deprecated in the near future

1. Context Menu Search – a Java 1. Remote Search - Invokes search that offers flexible search options. Use for: an z/OS Java Search engine • “Sandbox Library” search  under 1,000 members • Sequential Dataset search – even large QSAM files • Larger libraries (PDSs) – with a member name wildcard

2. Remote z/OS File Search – ISPF/SuperC File-Tailored and executed from within menu • Not quite as flexible as Remote Search • No Regular Expressions • Provides Hex & column-based search boundaries • Efficient with large libraries • Essentially, the ISRSUPC MVS Utility is invoked • Can be used to search GDGs

Because of these performance efficiencies use Remote 2. Remote z/OS File Search z/OS File Search with: Libraries > 1,000 PDS Members – unless you are filtering by member name pattern - Invokes ISRSUPC

4 Customizing the Search Dialog

Out of the box, IDz’s Search Dialog displays every installed search option. You will not need them all. ▪ Click Customize ▪ From the Search Page Selection  Click Deselect All  Check just those search options you want to see  Click OK ▪ Left-click / Hold and drag the left-hand margin of the Search page to make it a thin Rectangle (see next slide)

5 Remote z/OS Search – Options in the Search View

▪ Compact U.I.

▪ Hyper-text linked Search Results Type of Dataset ➔ ▪ Hover/Peek into Search Results Member name pattern ➔ ▪ Search specifically for: Search for text pattern ➔  Text patterns within libraries  Text patterns within sequential datasets  EBCDIC (hex) values  Specific library members  Specific data sets: ▪ QSAM (sequential) ▪ PDS members with a wildcard name What DSN or what selected pattern DSNs to search ➔ ▪ Can Filter result set lines ▪ Optimize (buffer) search results view build-out ▪ Search using Regular expressions ▪ Change "search for" criteria on-the-fly Searching Options ▪ Cancel long-running searches Note that, TSO/ISPF SuperC and SearchFor utilities do ▪ Save Search results not take into account Code Pages. IDz’s Remote z/OS ▪ Save combine with update for Search does (take Code Pages into account). Search/Replace Searches for non-English characters (i.e. German umlaut, Spanish inverted question and exclamation marks, ▪ Leverage the name and Results view DBCS characters) are more accurate using IDz for functionality

6 Search Results  Loads the source file, and positions the current-line

▪ When the search completes, a new Remote z/OS Search view will appear in Eclipse

▪ You can expand the entries to see individual source lines that match your search criteria  Double-Click a line

▪ Double-click a line to download and open the file in the Content Area

7 Search Result Set Filter – Logically "AND’ng“ Your Search Results

All search results for "PERFORM"

Client-Side Search result set filtering ➔

Show lines with PERFORM and EDIT

8 z/OS Remote Search Results view Preview

IDz provides an ability to peek at a few lines of code before downloading/opening the file that contains statements/records that match your search pattern text

▪ This (preview ability) provides context around the found result line, and can save time and machine resources

▪ You may not have to download file to find out if it contains what you need as per your requirement – you can just peek at the surrounding lines/records

9 9 Sorting Search Results – on Last Modified ▪ Once your Search finishes, you can sort by any category (column) in the results view. Last Modified is one of the more popular sorts

Or Created

10 Saving Remote Search Queries (all versions) – 1 of 3

▪ You can save a Remote z/OS® Search query and run it from the Remote Systems view. ▪ Before you can save a search query, you must first run a remote z/OS search and have the search results displayed in the Remote z/OS Search view. This option is limited to a single z/OS system under the following conditions:  You search for files using a resource name pattern and the file content search string is not specified.  The search scope is for a single z/OS system. The scope can be an entire z/OS system or multiple partitioned data sets on the same system.  The search scope does not include z/OS projects or MVS™ subprojects.

Step 1. Execute a Search

11 Saving Remote Search Queries – 2 of 3

▪ In the Remote z/OS Search view, display the results of the search query you want to save. If you have done more than one search, use the drop-down search history list to select the search query you want to save. ▪ Click the icon to save the search query. This icon is enabled only if the search scope is limited to a single z/OS system under the following conditions:  You search for files using a resource name pattern and the file content search string is not specified  The search scope is for a single z/OS system. The scope can be an entire z/OS system or multiple partitioned data sets on the same system  The search scope does not include z/OS projects or MVS™ subprojects ▪ The Add Query to Remote Systems View window opens.

▪ Type a name for the query and click OK. The search query is added to the My Search Queries list under the MVS Files subsystem ➔ 12 Saving Remote Search Queries – 3 of 3

▪ After you have saved a search query, you can do the following actions: To run a saved query, select it in the Remote Systems view and click Run Query from the pop-up menu.

To edit and run a saved query, select it in the Remote Systems view and click Edit and Run from the pop-up menu.

This action opens the Remote z/OS Search window, which you can use to change the search criteria and submit the search request.

▪ Note that in v9 and later the My Search Queries is renamed to: My Favorites

13 Search in Options

▪ Two options for searching: 1. Search inside the DSNs organized by Filters ▪ Convenient for "selection-based" searching ▪ Can select multiple DSNs

2. Search in "Other contexts:" ▪ Can type in any DSN and search

14 OPTIONAL: Search for a Specific Member

Sometimes you need to find a specific member across several libraries: ▪ Just the named/member (you’re not searching for contents) ▪ And you’re unsure of the PDS name

You can use IDz Filters to consolidate a list of libraries, then you can: ▪ Select a Filter within Remote Systems ▪ Right-Click and select Search ▪ Specify ONLY a member name (see below)

Note that this search does not hit z/OS to return results – it utilizes locally-cached member names

15 Optional Topic - IDz Search …vs… SRCHFOR (TSO/ISPF) ▪ "Why use IDz's Search... Why not just use SRCHFOR?". Here us a list – that - although it's not complete - paints a clear picture of what IDz's Search can do that SRCHFOR can not:

1. Search against multiple libraries – and/or GDG datasets 2. Specify multiple search conditions - ability to logically AND or OR conditions 3. Filter the search results - on the client 4. Expand each found member and use the Search Results list to navigate directly to the line that matched the search via hyper-link 5. Search across multiple LPARs 6. Filter at the member level (in your search, specify only certain member names) 7. Wave and reuse the Search Query 8. Sort by Last Modified 9. Search for Hex values – using the COBOL Editor 10. Compare found PDS members – directly from the Results list 11. Search results are compressed (no not-found PDS member names in the list) 12. Issue additional searches against initial search result (for compound search requirements) 13. Preview found-line-context, by hovering over the lines in Search results 14. Search against IDz “MVS File Filters” 15. Save off the PDS member names (only) 16. Invoke SRCHFOR and search JES Jobs using Menu Manager & REXX

16 Optional Topic - z/OS Search Dialog – EBCDIC Hex/Binary Search

Ability to search for EBCDIC (hex/binary) values

Utilize the same "regular expression" search techniques you learned for the Ctrl+F find functionality within the LPEX and COBOL editors

To search for Hex characters start the Content string off with: \x

17 Optional Topic - Search Results view toolbar options

▪ ‘Expand All’ and ‘Collapse All’ toolbar button

▪ Capability to customize table columns – order, show/hide, width

Expand/Collapse

‘Customize Table’ and ‘Preferences’ shortcut added to View Menu

18 18 Optional Topic – Global change based on output of Search

▪ Sometimes you need to make a global change – and it would be nice to use the “found” modules from an IDz Search ▪ It would also be nice to confine the changes you make into something like a “sandbox” environment – in order to not affect Production (or even Test ➔ trending towards Production)

▪ To do this: Issue Search

Copy the modules

Paste them into a Local Workstation Project Folder

Continued on next slide… 19 Optional Topic – Global change based on output of Search – 2 of 2

Right-click over the Folder you’ve copied the source files into and select: Search > File Search

From File Search  Enter your text  Click Selected resources  Click Replace…

From Replace Text Matches

Enter the replacement text Click OK …or… Click Preview > to verify each change 20 Preferences - z/OS Remote Search

Three input controls are configurable Inputs are disabled if preview checkbox is unchecked

21 21 Additional Use Cases – Remote Search with Regular Expressions

1. Using Search and Regular Expressions, find Examples out what COBOL programs in the libraries could be affected by a change to the DB2 tables (use your programs or the IDzClass code you copied up to your mainframe PDS)➔

WARD_DATA|HOSP_BED

2. Using Search and Regular Expressions, find out what COBOL programs in a library would be affected by a change to one or more copybook members ➔

3. Using Search and Regular Expressions, find out what batch JCL jobs in the JCL library would be affected by a change to datasets (you can search on the DD name of any part of the qualified DSN) ➔

22 Additional Use Cases – More Complex Regular Expressions

1. Search for COMPUTE statements in any module inside of .TEST.COBOL where the member name begins with: TR or BN.

Use the Regular Expression: (*TR.*|BN.*)

2. Right-click over any of your Datasets and select Search ▪ Specify: With name: C* Content strings: DISP=OLD

 Other contexts: SYS1.PROCLIB

23 Additional Use Cases – Search for the latest generation in a GDG

1. Select Sequential data set 2. Select Other contexts: 3. Type your file name in, and click Search

Sort the Datasets returned by clicking on the Name column

24 Leveraging the File Lists Created by Remote Search ▪ The search results list contains dataset and member names - which be: Copied/pasted (file transferred) to: ▪ Other LPARS – that you can set up as a connection in RSE, and to your workstation Added to MVS SubProjects: ▪ MVS SubProjects are topics covered in another module of this course Searched again: ▪ Issue a search within the results list - allowing you to AND multiple search patterns Compared with – Visual source compare (Note: Only 2 files can be selected)

25 Using Remote Search on Individual Members of a Library ▪ Remote Search is not limited to entire libraries at-a-time

▪ Remote Search can be used to find text patterns: In individual programs In selected programs And both individual and selected programs in the same or across multiple LPARs

26 Searching Through Sequential Datasets

▪ You can select one or more QSAM files, and search through them for Content Strings

And filter results 27 z/OS Remote Search Results view – and SCM Libraries

If you use CA-Endevor or CA-Panvalet/CA-Librarian – or Serena Changeman you can search through source files for content strings as follows:

CA Endevor: • Any 'Endevor target file' as written to by a Endevor processor (normally a PDS/PDSe) can be searched via IDz Remote z/OS Search • The internal Endevor file's such as the MCF, or BASE ELIBS can not be searched due to the internal structure of these by Endevor.

CA Panvalet / CA Librarian: • Search of these internal files is similar to CA Endevor. • If the output or control files is a PDS/PDSe then IDz SEARCH is available via Remote Search facility • The internal Panvalet/Librarian files are VSAM, and can only be searched using File Manager

Serena Changeman: • Changeman keeps all source within PDS/PDSe's file so normal IDz search available.

28 28 Searching Through Datasets Organized in MVS File Filters

▪ You can Filters to organize disparate DSNs – then Search through all of the datasets in the Filters with one action (Filters are in the next course module)

29 UNIT IDz for ISPF Developers

Topics: ▪ Code Search – The Find and Replace Dialog

30 Find/Replace Dialog – 1 of 4 – Alternative Searching Functionality

Besides the ISPF Find/Change command, there are other ways to search and replace text within a file

From anywhere inside your source, press: Ctrl+F …or… Ctrl+f

Brings up the following dialog with find options ➔

1. Enter Find and/or Find option checkboxes: Replace value ▪ Case sensitive – case sensitive search ▪ Whole word – finds your text delimited by spaces or dashes 2. Check one or more ▪ Regular expression – powerful search meta-language – for complex search search refinement ▪ Wrap – if starting mid-way through source, continue find from the top options ➔ ▪ Select found text – shows and selects found element ▪ Peek: Shows specified number of lines of source after the found element 3. Press a Find button ▪ Restrict search to columns – search between start and end columns only (covered on the next slide)

31 See Notes Find/Replace Dialog – 2 of 4 – Options

▪ Next – Find forward in the source – Does not find text inside copy or include files – Ctrl+n – finds next ▪ Previous – Find upwards (back) in the source from your current cursor position ▪ All – Finds all lines within the source – Additionally will exclude or filter all source not matching your Find string  Provides an intermediate set of lines to AND your search with – Press Ctrl+W to "show all" excluded lines …and/or to close the find dialog box – Clicking anywhere in the main body of your source file also closes the Find dialog – Click the pluses in the left-hand border to show filtered source ▪ Replace – Adheres to COBOL columns – If replace would push text past column 73 you will receive a warning ▪ Replace all – Changes "found" to replacement of values throughout file

▪ Note that whatever you enter the Find/Replace dialog persists This can be useful to do repeated searches within multiple files 32 Find/Replace Dialog – 3 of 4 – "ANDing" Search Results Sets

When you've completed a "Find ALL" search, the resulting set of statements can be searched through, providing a means of "AND" filtering – useful for complex search requirements

Process: • Perform an initial Find … ALL • Find any other string: • Press Next or Previous (not All)

33 Find/Replace Dialog – 4 of 4 – Find Dialog Preferences From: Window > Preferences > LPEX Editor > Find Text

… you can set workspace preferences for the Find Replace dialog.

 Consider: (for COBOL)  Incremental find dialog  Column restricted search 8 → 73

34 Regular Expressions in Ctrl+F (Find)

▪ Open WARDRPT.cbl ▪ Press Ctrl+F  To open the Find/Replace dialog ▪ Check  Regular expression

▪ Enter the following find expression: row-sub|records-written ▪ Click: All

Note that the single pipe separator | is a logical "OR" operator

To logically “AND” multiple search criteria separate them with: .*

See slide notes for additional Regular

Expression ideas 35 Data Flow Analysis – For Maintenance and Production Support Tasks

▪ Data Flow research is a complex analysis process that involves iterative searching and building of mental "dependency maps" for variables that are modified or referenced through statements within one or more programs ▪ On the mainframe, you either:  Utilize listing files/XREF entries – or –  Using ISPF you access option 3.4, or =3.14 and issue a series of manual text FIND operations – saving or writing down interim results. ▪ This is:  Typing-intensive  Error-prone  With lots of time spent loading programs into the editor in split-screen, etc. ▪ Using IDz you: ▪ Find your starting Search variable ▪ Pin the Search View and double-click each found-reference ▪ This is: ▪ Not typing-intensive ▪ Less error-prone ▪ With IDz, all Search results are: ▪ Fixed ▪ Hyperlinked – available from a mouse click 36 IDz's Data Flow Analysis Techniques

Many categories of project requirements necessitate that you track the order in which data values propagate within a program and across an application. This is commonly referred to as "Data Flow Analysis" While there is no single declarative function in IDz to address Data Flow Analysis, there are techniques that exploit the advanced Eclipse functionality in the tooling. IDz also provides a "Data Elements" view – that presents the complete list of variables in a "Compilation Unit" – which can be used as an organizing interface for your data analysis tasks. Finally, it should be noted that RAA (Rational Asset Analyzer) does offer a single "Impact Analysis" function that provides Data Flow Analysis Occurrences in Ctrl+F ISPF Command RAA Compilation Search Line Find Hyperlinked references – Y Y N Y synchronized with editor Color-coded "Modified" vs. Y N N Y "Referenced" results Use of Regular Expressions Y Y N Y in Search Automated Impact Analysis N N N Y Multi-window views Y Y N N (Analysis "Dashboard") Search using Filtering N Y Y N Excludes with lines/columns 37 Data Flow Analysis Using IDz Technique steps: From the starting point (a variable): 1. Select the field and search (using Occurrences in Compilation Unit) for all instances of the field throughout the source code

2. "Pin" the search results

3. Double-click each result line – which co-locates the line in the editor

4. Analyze the statements operation

5. If another variable is indicated as being part of the Data Flow task scope, return to Step 1 and search for the next variable 38 Occurrences in Compilation Unit – Analysis Tools

If you are analyzing, researching a data problem – like verifying Data Flow or doing Impact Analysis, or if you just need to quickly lookup the occurrences of a variable within your program you can:

1. Select the variable 2. Right-click and select: Occurrences in Compilation Unit

This opens a Search view with all occurrences of that variable: 1. Hyperlinked back to the source line of the reference 2. Color-coded – showing the variable reference in statements that - Declare or Modify a variable in gold - And all other variable references in statements in gray

39 Occurrences in Compilation Unit – continued

You can use Occurrences in Compilation Unit effectively to investigate data movement, analyze the impact of a change, research the cause of a data-specific ABEND (like an 0C7 or 0C4), etc.

Here's an example showing Search on a variable, with the Search Results view moved, and "pinned" with additional searches for Occurrences in Compilation Unit exposed through IDz

40 Concept – Pin the Occurrences in Compilation Unit - Search Results

Open a program in the editor ▪ From the command line, type: F and press 1. In the Editor source, Double-click (to select) 2. From the Context Menu, select Occurrences in Compilation Unit

This will launch a search for the variable throughout your program, and saves the search results in a Search Results view

3. From the Search View, click: Pin the Search View – This persists your results view, even when you launch additional searches

41 Concept – Create a Data Analysis "Dashboard“ From Multiple Search Results

You can move (Drag & Drop) the Search results views to different Workbench areas

Or you can Detach the views for optimized use of "screen real estate" in your analysis

Here's an example of this with an Assembler program

42 Review - Data Flow Analysis – Using Ctrl+F Regular Expressions

You can do Data Flow Analysis using:

• Ctrl+F

• Regular Expressions – to OR multiple variable searches

• Peek (set at 1 or 2) to see rows surrounding the found lines

Find String with text separated by |

Clicking All excludes rows

43 Show Expanded Source

Expands all COBOL Copybooks and PL/I Include statements inline (within) the program source. And it opens the expanded source file in Browse mode. This can simplify full-program-text analysis.

▪ Note that EXEC SQL INCLUDE xxxx statements are not expanded (although Open Copy member works with these statements)

Expanded source

Program in edit 44 Data Flow Analysis – Review

▪ Data Flow analysis is an iterative complex process, that involves expanding the scope of your search as new variables in the data flow are discovered

▪ On the mainframe, you either:  Utilize listing files/SX-REF entries – or  Using ISPF you access option 3.4, or =3.14 and issue a series of manual text FIND operations – saving or writing down interim results. This is: ▪ Typing-intensive and error-prone ▪ With lots of time spent loading programs into the editor in split-screen, etc.

▪ Using IDz you: 1. Find your starting Search variable 2. Pin the Search View and double-click each reference

 There are static analysis tools from IBM that are dedicated to providing this information, through ultra-quick and simple techniques (ask your instructor about Rational Asset Analyzer)

45 Optional Topics and Workshops For This Section

▪ If you have time, and are comfortable with the material just covered, feel free to read through the Optional Topic slides – and/or try out the techniques shown using IDz and the sample programs.

▪ The development techniques covered in these slides can make your standard z/OS Maintenance, Production Support and Development tasks much easier, and make you more productive.

▪ So at some point – perhaps after class consider returning to these optional topics to build out your IDz skills.

▪ Also – if you have access to IDz installed on your mainframe and time permits, please try out the techniques shown using your own application source.

46 Optional Topic – Using Regular Expressions to Search for Hex Values

You can use regular expressions to search for EBCDIC Hexadecimal Values, embedded in a program or in copybook source: Regular Expressions are an ASCII search mechanism Use ASCII/EBCDIC comparison charts to map to the EBCDIC value you're looking for ▪ ASCII - 1a ▪ EBCDIC - 3f

Regular Expression: [\x1a]

See Slide Notes for URLs to useful Regular Expression tutorials online

Hex Edit of line ➔

ASCII ➔ EBCDIC ➔

A typical conversion table URL: http://www.flounder.com/ebcdictoascii1.htm 47 Optional Topic – Using Regular Expressions to change all within columns

You can use regular expressions to substitute for ISPF picture string editing. Example – change all characters in columns 73 → 80 to blanks (spaces)  Regular Expression Start column: 73 End column: 80  Find: Type a period .  Replace: Type a space

Note that you could also use the ISPF Picture string command line command to do this:

48 Optional Topic – Regular Expressions to search for "any hex chars in a file"

You can use Regular Expressions to find any EBCDIC (hex) data in source files:  Regular Expression Type this in the Find area: [\x00-\x1F]

Note – the COBOL Editor (see Appendix B) can be use to effectively search for specific Hex (binary) values in EBCDIC.

The LPEX editor's regular expression search – by default – uses ASCII. 49 Regular Expressions Can Be Used in All Search Contexts ▪ You can use Regular Expressions to search for text: In a program Throughout all programs in a project On the mainframe: ▪ Across all members n a PDS ▪ Across multiple PDSs of different types: .COBOL, .BMS, .JCL, etc.

50 Finding Related Text on Adjacent Lines ▪ Sometimes what you're looking for is broken across adjacent lines. Example: Find MOVE and a specific variable when the variable is not on the same line as the MOVE verb ▪ The pattern for search across lines is ABC[\s\S]*?DEF

▪ In order to search across lines you will need to use the Search menu (similar to the previous example)

▪ Try this: Open TRTMNT.cbl From the Search menu Select: Search… Enter: move[\s\S]*?actual-val Enter: TRTMNT.cbl in the File name patterns edit box Press Search

51 Regular Expressions – Used to Support ISPF Find "Picture Strings"

ISPF Editor LPEX Editor . Dot, any single Simple String Y character Previous String Find Previous / F5 Delimited String Y \ special Expression Text string Y ^ logical NOT Picture Strings – special characters Y – with regular expressions \x Hexadecimal P'=' – any character Ctlr+F,  Regular Expression, . P'-' – any non-blank character Ctlr+F,  Regular Expression, [^\x20] P'.' – any non-displayable character Ctlr+F,  Regular Expression, [^\x20-\x7E] P'#' – any numeric character Ctlr+F,  Regular Expression, [0-9] P'-' – any non-numeric character Ctlr+F,  Regular Expression, [^0-9\x20] P'@' – any alphabetic character Ctlr+F,  Regular Expression, [A-Za-z] P'<' – any lower-case character Ctlr+F,  Regular Expression, [a-z] P'>' any upper-case alphabetic character Ctlr+F,  Regular Expression, [A-Z] P'$' – any special character (not alphanumeric) Ctlr+F,  Regular Expression, [^A-Za-z0-9] Ctrl+F

52 (Optional Topic) Find/Replace Dialog – Regular Expressions The Regular Expression meta-language is based on a few simple constructs

53 Find/Replace With Regular Expressions

▪ Load test1.cbl into the editor  Expression ▪ Check Regular expression

Enter the following Regular expressions, and click All after each: Expression What it does [0-9] All numeric characters [a-z] All alphabetic characters [a-z] Check:  Case sensitive in the dialog, and reissue this regular expression. Then un-check Case sensitive before continuing DL.C Find all variables with "DL" – any character – then the letter C [^\s] Find all characters except for white space (blanks: \s ) [^a-z] Non-alphabetic characters [^A-Z\x20] Non-alphabetic characters and no white spaces [^A-Z0-9\x20] Non-alphanumeric characters and no white spaces [^A-Z0-9\x20-] Non-alphanumeric characters, no white spaces, no dashes [^A-Z0-9\x20\(\)..-] Non-alphanumeric characters, no parenthesis and no white spaces [^*A-Z0-9\x20\(\)..-] Non-alphanumeric characters, no parenthesis, no asterisks, no white spaces .*(data) Find all variables that end in "data" PIC .9|PIC 9\( Find all numeric variable declarations 54 See Notes Optional Topic – Another Useful Search Mechanism – Persist Find Results ▪ Using the Search menu, you can search on a variable (or any partial selected text) in a program with: Search Text > File ▪ The results persist and are hyperlinked – for easy navigation, and can be: Copied/pasted to a requirements document Changed Replace Selected… Replace All… Searched Again to provide the capability of AND-ing multiple search patterns

55 Optional Topic – Highlight Found Text

▪ Some ISPF developers prefer to highlight all found text occurrences. ▪ This can be accomplished from: Preferences > LPEX Editor > System z LPEX Editor > Find Text

▪ Use Ctrl+F (Find) to search and highlight text in your source

To remove highlighted entries, type: clearMatches on the editor command line

56 ISPF - Find All (Exclude) Search Within File

Common ISPF editing technique: - Exclude various source lines - find (within) excluded lines - Used extensively on giant production source files

Command ====> F (or C) 'xxx' X

To perform this using IDz use the same command line syntax format: 1. Exclude lines 2. Then type: F ALL X

This will limit the scope of the search to only the excluded source lines

Note that ALL operand is not required 57 ISPF - Find All (Not Exclude) Search

Another common ISPF technique - Exclude various source lines - Find within (not) excluded lines

Command ====> F (or C) 'xxx' NX

To perform this using IDz use the same command line syntax format: 1. Exclude lines 2. Then type: F ALL NX

This will limit the scope of the search to only the NOT excluded source lines

Note that the ALL operand is not required

58 Optional Topic – Supporting the ISPF "ONLY" Command ISPF provides a "one-command" exclude/find all – "ONLY"

ISPF "ONLY" does the following: Top ; x all ; F 'xxx' all

The IDz ONLY emulation is: 1. Select the variable (or text pattern) 2. Right-click > Selected > Filter selection

Note that you can create a custom "User Key Action" – for filterSelection – so that ONLY is more closely emulated. ▪ Preferences > LPEX Editor > User Key Actions ▪ Define a custom Key for filterSelection  In this example, Alt+F9 (a-f9) is set to: filterSelection

59 Another Example of Text Filtering – Selected > Filter selection ▪ Double-click to select a:  COBOL Keyword  Literal  Variable  Label (Paragraph or Section name)

▪ Right-Click Selected ▪ Filter selection

▪ Note the plus signs Expand/Collapse filtered code ▪ Press Ctrl/W to un-filter and return to normal program view

60 Show In > Data Elements

Along with Occurrences in Compilation Unit, you can get a global (Data Division) – wide list of your variables and paragraphs with:

Show In > Data Elements

This creates a sort-able list of all the data elements with several actions against them: • Hyper-link to any variable declaration • Re-sort the list by various columns • Filter the list: • By data element name • Remote paragraph/section labels • Remove columns • Open and mark occurrences throughout the source (prior topic)

61 Sorting the Data Elements view

Can sort/re-sort by any column in the view

Useful for: • Categorizing variables ➔ sort by Declared In • Organizing by COBOL Group ➔ sort by Top-Level Item • Sorting by numeric …vs… character data ➔ sort by Declaration • Business Rules candidates ➔ sort by References

62 Finding unused variables

To find unused variables in a program 1. Filter the View (small downward pointing triangle)  Hide program labels 2. Sort by References (lowest to highest) – zero references are your candidate unused list 3. Look at the Declared In column – candidates for removal are declared in your .cbl program 4. Look at the Item type – for Data items (not indexes) 5. Look at the Level – Level 1 are Group fields, that will need further examination 6. When in doubt, right-click the variable and select: Occurrences in Compilation Unit for a detailed view of field usage

63 Filtering the Data Elements view

Filter view results horizontally search by data element name or text pattern

Filter out or add back into the view results paragraphs and sections, and FILLER ("unnamed items") by clicking the small downward-pointing triangle on the far-right corner of the view

Filter out Columns

Acts as an on/off toggle to add/remove columns from view

64 Topic Summary

After having completed this topic, you should now be able to: Search through your source files on z/OS Use Regular Expressions for complex search requirements Filter search results – for AND'd search requirements Understand the difference between Index and regular (TSO) search Export Index search results to an external format

65