Depending on your Sequel version the following methods can be used to search and/or replace values within Sequel Script objects.


Search and/or Replace with SCHSCRIPT Command

Starting with version R10M23, the new Search Script (SCHSCRIPT) command allows you to quickly and easily search for occurrences of any element defined in your Sequel Scripts. You can also do mass search and replace operations without creating source files and queries used in alternate methods. Built-in reports (SCRFNDRPL) will show you where specified items were found and, if replaced, where and how many times replacement occurred.

Simply issue the command SEQUEL/SCHSCRIPT and press F4 to prompt. Fill in the parameters and press Enter to run the command.

"

The parameters are as follows:

SCRIPT Parameter
Indicates the name and library of the script User Space to be searched.

Script Name
*ALL: All the scripts in the library will be searched.
generic*: Specify the generic name of the scripts to be searched. A generic name is a character string that contains one or more characters followed by an asterisk (*). If a generic name is specified, all scripts that have names with the same prefix as the generic name are searched.
name: Specify the name of the script to be searched.

Script Library
*CURLIB: Use the current library for the job.
name: Use the library name that contains the scripts.

FIND Parameter
Up to 50 characters of text to search for. The text must contain at least one non-blank character and must be enclosed in quotes. This parameter is required.

REPLACE Parameter
Up to 50 characters of text to replace the text found. Text is enclosed in quotes.
*NONE: No replacement will be made, making this a find only search.

TYPE Parameter
This defines which part of the script is to be searched.
*ALL: All aspects of the script will be searched.
*VAR: Only the prompted variable definitions will be searched in conjunction with the Variable Option Parameter.
*LINE: Only the script line statements will be searched.
*TITLE: Only the script title will be searched.

CASE Parameter
This specifies whether the search string should ignore the case of the data it is searching or if the case should match.
*IGNORE: The case of the search data is not a factor in the selection.
*MATCH: The case of the search data must exactly match the search FIND string.
If the REPLACE other than *NONE is used, the replaced value will be exactly as entered, regardless of this selection.

OUTPUT Parameter
Specifies whether to print a simple list of the selected scripts and the number of matches made based on the FIND string.
*YES: Print the list. The spooled file is named SCRFNDRPL.
*NO: Do not print the list.

VARELEM Parameter
Specifies which elements of runtime variables are searched. There are four elements of a variable that can have text that is searchable: Default Value, Prompt Text, Integrity Check, and Extended Help
*ALL All four elements of the variable are searched.
*DFT: Only searches the Default element of the variable.
*PMT: Only searches the Prompt Text element of the variable.
*INT: Only searches the Integrity Check element of the variable.
*HLP: Only searches the Extended Help element of the variable.


Replace Script Values with PDM

Using the Programming Development Manager (PDM) and some work files, you can find and replace values in multiple Sequel Scripts, and recreate the scripts with ease. Follow the steps below to use this method. This method works with Sequel version R10M23 and greater. This method allows you to see the script commands as they are changed.

  1. Use the following command to create a create a multi-member CL source file—each member contains the command description for one script from the library specified:
    DSPSCRIPTD SCRIPT(VIEW_LIB/*ALL) TYPE(*SRC) OUTPUT(*OUTFILE) OUTFILE(QTEMP/QCLSRC)
  2. Issue the following command to start PDM:
    WRKMBRPDM FILE(QTEMP/QCLSRC)
  3. On the ‘Work with Members Using PDM’ screen, enter option 25 (find string) next to the first member listed, and press F13 to repeat the option for all members. Press Enter.
    "
  4. On the ‘Find String’ display, enter the value you want to find in each member (which represents each script definition). Here, we want to find a library name so it can be replaced with a new library name. Press Enter.
    "
  5. The Edit screen will open with your cursor positioned at the first occurrence of the search string. Press F14 (to open the Find/Change Options screen).
    "
  6. On the ‘Find/Change Options’ screen, specify a Change Value and press Enter.
    "
  7. Back at the Edit display, press F17 (change) to change the first occurrence of the found value. Press F17 to search and change each additional occurrence until you are satisfied you have changed them all. Press F3 to exit.
    "
  8. On the Exit screen you can choose to change the member or not—the default is Yes. Press Enter.
    "
  9. You will be brought back to the Edit display for the next member. Repeat steps 7 and 8 to find, replace, and save your changes. When you save any changes to the last member in the list, you will return to the WRKMBRPDM display (step 3).
  10. Press F3 to exit the WRKMBRPDM screen, and issue the following command to recreate your scripts using the updated CL source file:
    CRTSCRIPT SCRIPT(VIEW_LIB/*ALL) SRCF(QTEMP/QCLSRC) SRCMBR(*ALL) 

Search Script Defintions for Any Value (no replace)

With this process, you can find any command, parameter, or value referenced in any of your Sequel script objects. Use this method if your version of Sequel is prior to R10M23

This method uses work files and Sequel functions (scripts and Sequel query statements).

  1. Issue the following command to create a work file containing a list of Sequel objects:
    DSPOBJD OBJ(LIB/*ALL) OBJTYPE(*USRSPC) OUTPUT(*OUTFILE) OUTFILE(MYLIB/OBJECTS)
  2. Create ScriptB (this script is used by ScriptA below and must be created first) with the following commands:
    10 MONMSG
    20 DSPSCRIPTD SCRIPT(yourlib/&SCPTNM) TYPE(*SRC) OUTPUT(*OUTFILE) 
       OUTFILE(QTEMP/SCPTNM)
    30 EXECUTE SQL(‘select “&&scptnm” len(10) name(scptnm), *.1 
       from qtemp/scptnm’) OUTFILE(mylib/Scripts2) MBROPT(*ADD)
    40 DLTF FILE(QTEMP/SCPTNM)
  3. Create ScriptA with the following commands:
    10 MONMSG
    20 RUNCMD CMD(‘runscript script(yourlib/ScriptB) 
     setvar((_&&scptnm ‘’_&&odobnm’’))’) SQL(‘select odobnm 
     from mylib/objects where odobat contains “SQLSCRIPT”’)
  4. Run ScriptA. The following process will occur:
    ScriptA, using the RUNCMD, will repetitively run ScriptB as many times as there are records in the OBJECTS file (created in Step 1) with an attribute of SQLSCRIPT.
    Every time ScriptB runs, it places the command listing and the corresponding name for each script in a work file—SCRIPTS2.
  5. When ScriptA is finished, query the SCRIPTS2 file to find any value you like in the script’s commands using a request similar to the following:
    DISPLAY (‘SELECT DISTINCT SCPTNM, SRCDTA FROM MYLIB/SCRIPTS2 WHERE UPPER(SRCDTA) CONTAINS “EXECUTE”’)
    

This request displays each script name that contains an EXECUTE command.

 


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: April 21, 2017