Space announcement This documentation space provides the same content as before, but the organization of the content has changed. The content is now organized based on logical branches instead of legacy book titles. We hope that the new structure will help you quickly find the content that you need.

FIND: COBOL



COBOL




Description

Important

This COBOL version of the FIND command is also known as enhanced FIND.

The FIND command searches for three data types: strings, data names, and COBOL-structures. Searching strings lets you search for character strings, searching data names and their relationships lets you trace data flow, and searching COBOL-structures lets you capture the underlying logical structure of your program. If the SET LOG FIND ON command is issued, the results of all data name and COBOL-structure finds will be written to the session log.

Because the FIND command is used to examine COBOL programs, a large number of COBOL-structure keywords can be used with the command to locate various source lines. See to COBOL-Structure Keywords for a list of the COBOL reserved words associated with each COBOL-structure keyword that can be used with the FIND command.

Important

Communication statements, debugging statements, and report-writer statements are not supported.

FIND is not valid in an unattended batch test.

Input

COBOL FIND Syntax (Format 1)

image2021-2-15_17-44-3.png

COBOL FIND Syntax (Format 2)

image2021-2-15_17-44-45.png

COBOL FIND Syntax (Format 3)

image2021-2-15_17-45-28.png

COBOL FIND Syntax (Format 4)

image2021-2-15_17-45-54.png

The following are the parameter descriptions for the FIND command:

string

Any character string. The string can be delimited by single quotes, double quotes, or double equal signs. A delimiter is required when a space is part of the string or if the string matches any reserved word. A reserved word consists of a keyword of the FIND command including COBOL-structure keywords.

data name

Any specified data item (that must never be enclosed in quotes) in a program.

CSR

Allows a FIND to be issued on a data name or string under the cursor position. If the data name contains a qualifications, the qualification is picked up automatically. Basically, this is a FIND CSR function similar to the Code Debug TSO PEEK CSR function. The FIND CSR command is usually assigned to PF14.

COBOL-structure-keyword

One of the following keywords: ALTER, BRANCH, CONDITION, CALL, CICS, DLI, INPUT, IO, OUTPUT, PARAGRAPH, or SQL. See COBOL-Structure-Keywords for the source lines to which each keyword refers.

IN COBOL-structure-keyword

Restricts the lines to be searched to source code statements that are defined as part of the COBOL-structure. The keywords are listed above in COBOL-structure-keyword and in COBOL-Structure-Keywords.

REFerence

Includes all source code statements referenced by the DEFINE, USE, and MODIFY keywords.

USE

The source code statements in the Procedure Division that reference the data name, but do not change its value.

MODify

The source code statements in the Procedure Division that could potentially change the value of the data name.

DEFine

The Data Division source code statements that reserve storage for the data name. If ALIAS is also in effect, all storage areas that redefine the data name are included.

ALIas

Includes in the search any other data name that refers to the same storage location, such as a redefined or group level data name.


Note

FILLER is not considered an alias.

NORedefine

Same search as ALIAS, but does not include redefined data names.

NOAlias

Confines the search to just the data name specified.

DIRect

Finds only those source code lines that directly reference the data name.

INDirect

Indicates, at each entry of the command, the data name, its aliases (if chosen), and all possible places a data value is passed to or from the data name and its aliases.

Also, directs Code Debug TSO to find the next level of indirection—repeat FIND INDIRECT.

ALL, FIRST, NEXT, LAST, PREV

These keywords specify the direction and starting location of the search and are valid on any FIND. They can appear in any position in the command, not just at the end.

SUBset

Limits a search to non-excluded lines only. This keyword is valid on any FIND.

EXclude

Excludes from view all lines not meeting the search criteria. This keyword is valid on any FIND.

NOLines

Used with the EXclude keyword, this keyword removes the xx LINES NOT DISPLAYED message line. It is valid on any FIND.

Usage Notes

COBOL

  1. FIND is valid without any keywords. The default action is to repeat the previously entered FIND function. The first string reached is highlighted and the display scrolls to that line. Subsequent strings are found with the FIND command or with PF5.
  2. Only a string FIND command can be used in nested programs.
  3. The syntax for the string follows the general conventions for literals discussed throughout this documentation, with one exception: character strings without imbedded blanks need not be enclosed in quotes. For example:

    FIND USG
    FIND 'US G'
    FIND "US' G"
    FIND X'C1C4E2'
    FIND ==USG==
  4. If the string is not found anywhere in the scanned data area, a message indicating this is displayed.
  5. When FIND SQL is issued, the EXEC SQL WHENEVER statements and EXEC SQL DECLARE statements not within the procedure division are currently not highlighted or counted.
  6. When FIND data name is used, the data name is highlighted in the line where it occurs. Periods or parentheses surrounding the data name without intervening spaces are also highlighted. The message on the message line says:
       n DATA REFS: n DEF, n USES, n MODS FOUND FOR data namewhere n DATA REFS is the total number of references, and n DEF etc. refers to the number of occurrences of each type of reference. If a particular type of reference is not found, it is not included in the message. FIND data name does not find data names that are part of comments. See Result of Finding the Data-Name SUBS for an example.
  7. When either a data name or a COBOL-structure keyword is entered, the default is ALL, meaning to find all occurrences. If FIND is entered with a string, the default is NEXT.
  8. The keywords REF, USE, MOD, DEF, ALI, NOA, DIR, and IND are valid only with a data name.
  9. A FILLER data name is not an ALIAS.
  10. The keywords REF, USE, MOD, and DEF are mutually exclusive. Only one of the four can be entered at a time. The keywords ALI, NOR, and NOA are mutually exclusive, as are DIR and IND. The default for each group, as indicated in the syntax diagram, is operative on every FIND entered, unless a keyword from each of the three groups is entered instead.
  11. When FIND is issued with the EXCLUDE keyword, the appropriate message is displayed and the cursor is positioned in the command area. When FIND is issued without the EXCLUDE keyword, the cursor is positioned on the first data name, string, or verb.
  12. Calls to specific modules can be defined as INPUT, OUTPUT, or IO. If the site installer or user lists the names of modules that are used for IO purposes in JCL015 in SLXTINST,then the only CALL statements found with a FIND IO command will be calls to the modules listed. FIND INPUT, FIND OUTPUT, and FIND IO only find the CALL modules listed in the INPUT/OUTPUT Module Definition screen completed at installation time.
  13. Use the SET DATAFIND command to indicate whether the next or all data names are to be found on the FIND data-name command.
  14. The FIND command is assigned to PF5. FIND CSR is assigned to PF14. FIND IND is assigned to PF17.
  15. When FIND is issued with the OUTPUT keyword, any verb found within an Evaluate statement will include the entire statement through the End Evaluate.

Examples

COBOL

  1. To locate the data name SUBS, enter the following on the command line:
      FIND SUBS
    The result of this FIND command is shown in the following figure.
    Result of Finding the Data-Name SUBS

               49 Data Refs: 1 DEF, 30 USES, 18 MODS found for SUBS
    ------   ---------------------------------------------- Before MYMAIN/AMODE 24 <>
    000084    * SUBSCRIPT FOR INDEXING ALONG INPUT MESSAGE LINE ITEMS
    000085    77  SUBS  PIC S9(3) COMP.                                        DEF
    000087    * SUBSCRIPT FOR INDEXING ALONG SPA LINE ITEMS
    000089    77  SPA-SUBS  PIC S9(3) COMP.
    000090    *
    000091    *            DL/I CALL FUNCTIONS
    000092    *
    000093    77  GU-FUNC     PIC X(4) VALUEGU  ’.

    The message area indicates the number of times SUBS is referenced in the program. The data name SUBS is highlighted and the message DEF appears on the right of the screen.
    To find the next occurrence of SUBS, press PF5 (repeat FIND), or type FIND on the command line, move the cursor down past the line in which SUBS is defined, and then press Enter.

  2. To locate all references and aliases of the data name N-CNTR, enter the following on the command line:
     FIND N-CNTR ALIAS
  3. To locate the string B010 in a paragraph name, enter the following on the command line:
       FIND B010 IN PARA
    See the following figure. The FIND string IN COBOL-structure-keyword command lets you focus on the statement that is of concern, rather than issue several repeat FIND commands.
    Result of Finding String B010 IN PARAGRAPH

                                1 CHARSB010found
    ------   ---------------------------------------------- Before MYMAIN/AMODE 24 <>
    000203    B005-PROCESS-DETAIL-RECS-EXIT.
    000204    B010-PROCESS-TEACHER-CHANGE.
    000205        DIVIDE TOTAL-TEACHER-IQ BY TEACHER-STUDENT-TOTAL
    000206            GIVING WA-TCHR-AVG-IQ ROUNDED.
    000207        MOVE WA-TCHR-AVG-IQ TO TATL-AVG-IQ.
    000208        MOVE DOUBLE-SPACING TO PROPER-SPACING.
    000209        WRITE IQ-TEST-REPORT-LINE FROM TEACHER-AVG-TOTAL-LINE
    000210             AFTER PROPER-SPACING.
    000211        MOVE ZERO TO TOTAL-TEACHER-IQ.



 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*