Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Scan & Replace Data in Source (SCANRPL) command scans one or all source file members in a source file and replaces a search pattern with the specified replacement text. Any source file member may be scanned and replaced using this command.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
PATTERN | Search pattern (regex allowed) | Character value | Required, Positional 1 |
REGEX | RegEx search pattern | *YES, *NO | Optional, Positional 2 |
NEWVALUE | Replacement string | Character value | Optional, Positional 3 |
SRCFILE | Source file | Qualified object name | Optional, Positional 4 |
Qualifier 1: Source file | Name, QRPGLESRC | ||
Qualifier 2: Library | Name, *CURLIB, *LIBL | ||
SRCMBR | Source Member to scan | Name, *ALL, *FIRST | Optional, Positional 5 |
MATCHCASE | Match upper/lower case | *MATCH, *IGNORE, *YES, *NO | Optional, Positional 6 |
START | Starting line position | Integer, 1 | Optional, Positional 7 |
OCCURS | Line occurrence to process | Integer, *ALL | Optional, Positional 8 |
IGNSPACE | Ignore Spaces in REGEX PATTERN | *IGNORE, *YES, *NO | Optional, Positional 9 |
Top |
Specifies the search pattern used to scan the input source file record. Any plain text or a regular expression may be specified. To use a regular expression, specify the REGEX(*YES) parameter option.
This is a required parameter.
Top |
Specifies the search pattern uses the regular express (REGEX) engine to search instead of the standard linear scan/search routine. Regular expressions may be specified in the PATTERN parameter when this parameter is REGEX(*YES), however remember to escape any control characters with a preceeding backslash. For example, if you are searching for a values such as "QGPL.CUSTMAST" the period must be escaped otherwise the regular expression engine will match any character with the period. So "QGPL/CUSTMAST" and "QGPL.QCUSTMAST" would both match the regex search pattern. Note that the SCANRPL program auto-escapes on the forward slash character since it is widely used in IBM i application systems.
This is a required parameter.
Top |
Specifies the text that is inserted into the source record in place of the text specified on the search pattern parameter.
This is a required parameter.
Top |
Specifies a source file that contains the source member to be scanned.
Qualifier 1: Source file
Qualifier 2: Library
Top |
Specifies the source member that is searched.
Top |
Top |
Specifies the position on each line where the scan operation begins.
Top |
Specifies the individual occurrence of the scan pattern on the line to process. If anything other than *ALL (or 0) is specified, only that individual occurrence is replaced--other occurrences of PATTERN are not changed. NOTE: It is uncommon to use anything other than the default value of *ALL for this parameter.
Top |
Causes the regular expression search to ignore spaces embedded within the PATTERN parameter. Spaces on the searched text (source member line) are not impacted by this parameter.
Top |
Example 1: Simple Command Example
SCANRPL PATTERN('xtools/qcpysrc,') NEWVALUE('cozTools/qcpysrc,') SRCFILE(QRPGLESRC) SRCMBR(*ALL) CASE(*IGNORE)
This command scans all source members in QRPGLESRC for the pattern 'xtools/qcpysrc' while ignoring upper/lower case variations. It then replaces each occurrance of that search pattern with 'cozTools/qcpysrc,'. The 'cozTools/qcpysrc,' replacement text is embedded with the same upper/lower case pattern as the users has specified on the command.
Top |
Top |