CHANGE primary command (Edit only)

The CHANGE primary command finds and changes one or more occurrences of a character string (or field value) in the data being edited.

When one or more occurrences of a string are found, FM/IMS places the cursor immediately after the first occurrence. If necessary, it scrolls the data to bring the string into view.

For date and time fields that are displayed using the output format defined in the view, FM/IMS searches the displayed values for string1 and if found replaces string1 with string2 in the displayed value.

When you are using a view, the setting of the SHOW SUP command affects the segments that are searched. With SHOW SUP OFF, only those segments matching the current segment type and layout are searched. With SHOW SUP ON, the search is not limited to segments of the current segment type and layout.

The CHANGE primary command does not change an occurrence of a string when any part of the string is in the key field of the segment.

FM/IMS places the cursor immediately after the first occurrence of the string. If necessary, it scrolls the data to bring the string into view.

The CX command displays an Extended Command Entry panel, in which you can enter long arguments that may not fit on the Command line.

Syntax

Figure 1. CHANGE syntax in edit

1 Change
1 CX
1 CHG
2? SEGment(segment-name)
2? GET(n)
2? 
3.1! SCOPE
3.1 Db
3.1 Rec
3.1 DEPendent
3.1 *
3.1 string1
3.1 *
3.1 string2
3.1! NEXT
3.1 ALL
3.1 FIRST
3.1! CHARs
3.1 PREfix
3.1 SUFfix
3.1 WORD
1  %column range
1  %field list or range
column range (CHAR, HEX, and LHEX formats only)

1 col1 ?col2
field list or range (SNGL or TABL display format)

1 ! #ALL
2.1 (?+ , #field)
1 (?+ , #field_1 - #field_2)

You can specify parameters in any order.

segment-name
When the SEGMENT parameter is specified, the search is restricted to occurrences of the segment type, segment-name. The parameter is only permitted when SHOW SUP is on, or when you are not using a view.
GET(n)
Limits the number of segments searched to n.
SCOPE
Search range is the current scope.
DB
Search the entire database.
REC
Search is restricted to the current database record.
DEPENDENT
Search is restricted to the dependents of the current segment. The parameter is only permitted when SHOW SUP is on, or when you are not using a view.
* (asterisk)
When used in place of the search string, uses the search string specified on the previous CHANGE command as the search string.

When used in place of the replacement string, uses the replacement string specified on the previous CHANGE command as the replacement string.

The position of the * is important for CHANGE. If it is positioned before a string, it indicates the previous search argument; that is, it is treated as the first string. If a string is found prior to the *, then it is treated as the second string (the change argument), taking the change argument from the previous CHANGE command. To use both the previous search string and the previous change string, specify CHANGE * *.

string1
The string to be searched for, which can be up to 100 characters long.

The string can be:

  • A character string not starting or ending with a single quotation mark and not containing any embedded blanks or commas. The case of the string is ignored. Uppercase and lowercase representations of the same character match.

    For example:

    CHANGE before after

    changes the strings before, Before, and BEFORE.

  • A character string enclosed in single quotation marks. The string can contain blanks and commas. The case of the string is ignored. The string can be a null string (''). If string1 is a null string, then string2 is inserted at the current column position.
  • C followed by a character string enclosed in quotation marks (C'Frog'), or a character string enclosed in quotation marks followed by C ('Frog'C). The string can contain blanks and commas. The string must match exactly (including case).
  • P preceded or followed by a picture string enclosed in single or double quotation marks to describe a type of string to be found rather than the exact characters. It can contain blanks, alphabetic and numeric characters which represent themselves, or any of the special characters listed here, each of which represents a class of characters:
    =
    Any character.
    @
    Alphabetic characters.
    #
    Numeric characters.
    $
    Special characters.
    & notsym;
    Non-blank characters.
    .
    Invalid characters.
    -
    Non-numeric characters.
    <
    Lowercase alphabetics.
    >
    Uppercase alphabetics.

    When this notation is used, numeric, bit and unicode fields (for SNGL and TABL display formats) are excluded from the search process.

  • X followed by a hexadecimal string enclosed in single quotation marks (X'C1C2').
  • A numeric value (SNGL or TABL display format only). The algebraic value of string1 must match the algebraic value of the numeric field. The lengths (number of digits) of string1 and of the numeric field are not significant. Similarly, the data type of the numeric field is not significant. For example, a string of 123 matches a packed-decimal field containing 00123 or a floating-point field containing 1.230E+02. An unsigned value in string1 is considered to be positive.
  • A DBCS string or a mixed DBCS and non-DBCS string. If the Shift-out (x'0E') is the first character of the argument, it is stripped off prior to searching for the string. If shift-in (X'0F') is the last character of the argument, it is stripped off prior to searching for the string.
string2
The string used to replace string1, which can be up to 100 characters long.

The string can be:

  • A character string not starting or ending with a single quotation mark and not containing any embedded blanks or commas. If CAPS ON is in effect, then string2 is translated to uppercase.
  • A character string enclosed in single quotation marks. The string can contain blanks and commas. Case is respected and retained unless CAPS ON is in effect, in which case string2 is translated to uppercase. The string can be a null string ('').
  • C followed by a character string enclosed in quotation marks (C'Frog'), or a character string enclosed in quotation marks followed by C ('Frog'C). The string can contain blanks and commas. Case is respected and retained. The string can be a null string (C'').
  • A DBCS or a mixed DBCS and non-DBCS string. The shift-out (X'0E') and shift-in (X'0F') at the start and end of the string are adjusted in such a way that the integrity of the DBCS data is not compromised.
  • P preceded or followed by a picture string enclosed in single or double quotation marks to describe the change to be made. You can change characters from uppercase to lowercase or from lowercase to uppercase, or leave the field the same using these string special characters.
    =
    Any character.
    <
    Lowercase alphabetics.
    >
    Uppercase alphabetics.

    Examples of picture strings used with the CHANGE command:

    c p'.' x'00'
    Change next invalid character to hex x'00'.
    c p'###' 100
    Change next 3-digit number to 100.
    c all 73 80 p'=' " "
    Put blanks in columns 73 to 80.
    c all p'-' 1 10 "0"
    Change all non-numeric characters in columns 1 to 10 into the char "0".
    c p'<' p'>'
    Change any lowercase to uppercase.
    c p'a>' p'=<'
    Change character a, any uppercase to character a, lowercase.
    c p'>' '¬'
    Change any uppercase to "not sign" (note: "not sign" has no special meaning in a "to" string).
    c p'<#' p'>='
    Change any lowercase, any number to upper case, the number found.

    When this notation is used, numeric, bit and unicode fields (for SNGL and TABL display formats) are excluded from the search process.

    .
  • X followed by a hexadecimal string enclosed in single quotation marks (X'C1C2'). If CAPS ON is in effect, then all hexadecimal representations of lowercase characters are translated to their equivalent uppercase characters.
  • A numeric value (SNGL or TABL display format only).
  • A DBCS string or a mixed DBCS and non-DBCS string. The shift-out (X'0E') and shift-in (X'0F') at the start and end of the string are adjusted in such a way that the DBCS data integrity is not compromised.
NEXT
The CHANGE command searches for the next occurrence of the string, string1, in the search range, starting at the cursor location (if the cursor is within the data portion of the display), or at the top of the displayed page (if the cursor is outside the data portion of the display).

If string1 is found, FM/IMS changes it to string2 and places the cursor immediately after string2.

If string1 is not found by the end of the search range, or if the cursor location is after the last segment in the search range, FM/IMS displays a message indicating that the end of the search range has been reached and redisplays the page that was displayed prior to the search. To resume the search from the top of the search range, use the RFIND (F5) primary command or the RCHANGE (F6) primary command.

FIRST
The CHANGE command searches for the first occurrence of the string, string1, in the search range, starting at the beginning of the first segment in the search range.

If string1 is found, FM/IMS changes it to string2 and places the cursor immediately after string2.

If string1 is not found in the search range, FM/IMS displays a message indicating that the string was not found and redisplays the page that was displayed prior to the search.

ALL
The CHANGE command searches for all occurrences of the string, string1, in the search range, starting at the beginning of the first segment in the search range and continuing to the end of the search range.
If string1 is found one or more times, FM/IMS:
  • Changes all occurrences of string1 to string2.
  • Places the cursor immediately after the first changed occurrence.
  • Displays a message indicating how many times the string was changed.

If string1 is not found in the search range, FM/IMS displays a message indicating that the string was not found and redisplays the page that was displayed prior to the search.

CHARS
Matches the search string anywhere in the data.
PREFIX
Matches the search string wherever it appears as a prefix in the data. To be a prefix, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by an alphanumeric character.
SUFFIX
Matches the search string wherever it appears as a suffix in the data. To be a suffix, the matched text must be preceded by an alphanumeric character, and must be followed by a non-alphanumeric character or be the end of a line or field.
WORD
Matches the search string wherever it appears as a word in the data. To be a word, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by a non-alphanumeric character or be the end of a line or field.
col1
The starting column of the search. If col1 is specified without col2, string1 must start in col1 to be found. If both col1 and col2 are specified, string1 must be completely contained within the designated columns.
Note: When column ranges are specified and the data is displayed in SNGL or TABL formats, the search is performed in the order that the data occurs, which may not be the order in which the fields are displayed. Numeric field values are not considered in this type of search.

When column ranges are specified, then a string comparison is performed, even for numeric fields.

col2
The ending position of the search. If col2 is larger than the segment size, the segment size is used.
#ALL
Each field is searched according to its template attributes.
#field
The field reference number for a field in the layout for the current segment type. Used in SNGL or TABL format to limit the search to the specified field or fields within the currently displayed segment type.

To specify more than one field reference, they must be either enclosed in parentheses (optionally separated by commas), or separated by commas but without any intervening spaces. For example, (#17 #22), (#17, #22), and #17,#22 are valid field reference specifications.

For alphanumeric fields, the string is found if it is completely contained within one of the designated fields. For example: CHANGE DB ALL xxxx yyyy #5,#6 finds and changes all segments of the current type containing "xxxx" within either of the fields with field references #5 and #6.

For numeric fields, the string is found if the value of either of the numeric fields is equal to the value specified by the string.

The field reference number is relevant to the layout of the segment being searched during the change operation. Hence, when using a field reference number and SHOW SUP ON is in effect (segments are not grouped), this may result in changing data in fields you did not expect when the fields specified are not common between layouts.

For example, CHANGE DB ALL 123 256 #8,#9 finds and changes all segments of the current (numeric or character) type:
  • Containing the value 123 in either of the numeric fields with field references #8 and #9.
  • Containing the string 123 in either of the character fields with field references #8 and #9

If the argument is a DBCS string, only data between a shift-out and shift-in is searched for a match. For example, if your search string was X'0E40400F' (that is, shift-in blank blank shift-out), the CHANGE command would not find two consecutive blanks in non DBCS data.

#field_1
The first field reference of a range of fields. It cannot be subscripted. If the #field_1 field reference value is less than the lowest displayed field reference value, the lowest displayed field reference value is used.
#field_2
The last field reference of a range of fields. It cannot be subscripted. If the #field_2 field reference value is greater than the highest displayed field reference value, the highest displayed field reference value is used.

The #field_1 and #field_2 field reference values must be separated by a hyphen (-). Spaces are permitted between the hyphen and the field reference values.

If #field_1 is a higher value than #field_2, the search process reverses the operands.

Availability

Related tasks and examples

Extended Command Entry pop-up panel for the CHANGE command shows the Extended Command Entry pop-up panel for the CHANGE command. In this example, any occurrences of the string The Cappuccino Strip in FM/IMS are to be changed to the string LONG AND WINDING ROAD.
Figure 2. Extended Command Entry pop-up panel for the CHANGE command
Process   Options   Utilities   Help
  ──────────────────────────────────────────────────────────────────────────────
FM/IMS                        Edit : IMS Database DJ1E
            Autosave OFF SHOW SUP ON  Scope ALL    Col 1          Format CHAR
   ┌───────────────────── Extended Command Entry ──────────────────────┐ DATE
   │                                                                   │
   │ Complete typing the CHANGE command and press Enter.               │
   │                                                                   │
 0 │ CHANGE  ===> 'THE CAPPUCCINO STRIP '___________________________   │
 0 │         ===> 'LONG AND WINDING ROAD'___________________________   │
 0 │         ===>  _________________________________________________   │
 0 │         ===>  _________________________________________________   │
 0 │         ===>  _________________________________________________   │
 0 │                                                                   │
 0 │                                                                   │
 0 │  F1=Help    F2=Split   F3=Exit    F9=Swap   F12=Cancel            │
 0 └───────────────────────────────────────────────────────────────────┘ 9/1980
    ___  2    LINKSUB   O'CONNOR
    ___  2    LINKSUB   SAMSON
    ___  2    LINKSUB   SOUTH FREMANTLE
    ___  2    LINKSUB   WHITE GUM VALLEY
    ___ 1     SHIRE     KALGOORLIE          W60500012.`....................o.
    ___  2    SHIRENP   .......b...
    ___  2    LINKSUB   HANNANS
    ___  2    LINKSUB   KALGOORLIE
    ___ 1     SHIRE     MOUNT MAGNET        070400399.............. ..... ...
    ___  2    SHIRENP   ...........
    ___  2    LINKSUB   MOUNT MAGNET
    ___  2    LINKSUB   MOUNT MAGNET SHIRE
 Command ===> cx___________________________________________________ Scroll CSR
  F1=Help      F2=Format    F3=Exit      F4=CRetriev  F5=RFind     F6=RChange
  F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel