Kourier Integrator Online Help

KT.SAR

Syntax

KT.SAR {(T}

Description

This command can be used to search and replace any occurrence of a string in a file. All attributes in a file (including the item-id) are processed unless a single attribute is specified. If the "T" (table) option is specified the search and replacement strings are read from the file and item-id specified.

Prompts

Source File Name

The file containing the records to be searched.

Target File Name

The file where the records will be written.  If this field is not specified the Source File Name is used as the Target File Name.

AMC to Search

Limits the search and replacement to the attribute specified.  If this field is not specified all attributes will be processed.

 

If the T (table) option is specified the following prompts are displayed:

Table File Name

The name of the file where the table item can be read.

Table Record ID

The name of the item containing the table of search and replacement strings.

 

If the T (table) option is NOT specified the following prompts are displayed:

Search String

Enter the search string.  All entries are case sensitive and may include leading, embedded or trailing spaces.  Up to six search and replacement strings may be entered when the T option is not specified.

Replacement String

Enter the replacement string.  All entries are case sensitive and may include leading, embedded or trailing spaces.

All occurrences

Enter a Y to unconditionally change every occurrence of the search and replacements strings. If this field is left blank or an N is entered, the user is prompted to confirm each replacement.

Are parameters correct

Enter a Y to begin processing the search and replace string.  If this field is left blank or an N is enter the program is terminated.

Table File Format

The search and replace table consists of any number of lines that can be tab delimited or space delimited. When the table is space delimited strings with embedded spaces may be enclosed in double-quotes, single-quotes or backslashes.  Each line contains the following information:

oldpattern  newpattern  changeflag

where changeflag is either set to Y to unconditionally change every occurrence of the search and replacements strings or N to conditionally change each occurrence of a search and replacement strings (i.e. the user is prompted to confirm each replacement).
 

Example

>KT.SAR
Enter Source File Name........: ABC-FILE
Enter Target File Name........:
Enter AMC to Search (<CR>=All):

Enter Search String.......: MYSEARCH1
Replace with..............: MYREPLACE1
All occurrences (Y,N=<CR>): Y

Enter Search String.......: MYSEARCH2
Replace with..............: MYREPLACE3
All occurrences (Y,N=<CR>):

Enter Search String.......:

Search and Replace (SAR)

Source File: ABC-FILE                          Target File: ABC-FILE

Stat Search For............... Replace With............. Always Count
     MYSEARCH1                 MYREPLACE1                YES
     MYSEARCH2                 MYREPLACE3                NO

Are parameters correct (Y,N=<CR>)?

In this example, all attributes of the file ABC-FILE will be searched for each occurrence of the strings specified. MYSEARCH1 will be unconditionally replaced while MYSEARCH2 will be conditionally replaced.  When the program is running it will stop at the first occurrence of MYSEARCH2 and prompt the user for the required action.  In the case below, the second record read with the item-id of MYSEARCH2_AR_INVOICE_LI_INFO1 has the search string MYSEARCH2 in attribute 0 (the item-id).

 2 MYSEARCH2_AR-INVOICE_LI_INFO1

0000 MYSEARCH2_AR-INVOICE_LI_INFO1

Replace (Y,N)?

Upon completion of program the following information is displayed.  The count column indicated the number or replacements performed for each search string while the last two lines indicate the number of records read and written.,

Search and Replace (SAR)

Source File: ABC-FILE                          Target File: ABC-FILE

Stat Search For............... Replace With............. Always Count
     MYSEARCH1                 MYREPLACE1                YES       12
     MYSEARCH2                 MYREPLACE3                NO         5

  31 Records Read
  14 Records Written

Related Topics: 

Kourier TCL Commands Overview