Default language.

EDIT (E)


The EDIT parameter replaces character, packed, or hexadecimal data in a record with character, packed, or hexadecimal data of a different length. When EDIT is executed, File-AID shifts the remaining data to adjust for the change. The EDIT parameter only changes the first occurrence of matched compare-data in a record. To change more than one occurrence of compare-data, use multiple EDIT parameters. To change all occurrences, use the EDITALL parameter.

The syntax of the EDIT parameter is:

EDIT=(location,{length },[dupl]compare-data,new-data)
                  {operator}

location

Location where the search for the data begins. Any valid actual or relative location can be used.

length

Length of the search field. The value must be at least one byte longer than the compare-data length. Any valid number can be entered as long as it does not exceed the record length. Use 0 to search the area between the current actual or relative location and the end of the record.

operator

Any valid operator element listed in Operator Element is allowed.

dupl

Optional duplication factor that defines the number of times File-AID looks for the compare-data to be contiguously repeated, starting at the specified location. A dupl element is valid only when an operator element other than NE is specified. The dupl value is ignored when a length is specified.
 

Important

The duplication factor is not used to determine the length of the compare-data to replace. Dupl is only used to determine if a condition is present. New-data always replaces compare-data. Dupl is ignored during replacement.

compare-data

Data to search for in the specified location. Most valid data types described in Data Element are allowed, except that data types I and ILn are not accepted in EDIT. Multiple compare-data values, separated by commas, are allowed.
 

Important

When specifying multiple compare-data values, duplication factors are not allowed. Also, the order of the compare-data element values determines the sequence of new-data replacements. Furthermore, when multiple compare-data values are specified with the EQ operator, the lengths of each compare-data value should be the same. If lengths are not the same, File-AID uses the length of the first compare-data value specified, when determining the length of the data to replace. If a length is specified instead of an operator, each of the multiple compare-data value lengths are used to change to the new-data.

new-data

Data that replaces the compare-data when a match is found. If the new-data length is larger than the compare-data length, the remaining contiguous data is shifted to the right. If the new-data is shorter, the contiguous data to the right is shifted left and kept contiguous to the new-data.

When a packed data element is used as new-data, the number of decimal digits (including leading zeros), entered in the control card, determines the length of the new packed field (see Example 5:).

When EDIT inserts data by replacing a field with another of greater length, File-AID shifts the data to the right to make room (see Example 1:). This shift is done field by field. Fields that are separated by more than one blank may be compressed to a single space to make room for inserted fields (see Example 2:).

Important

When using the UPDATE function, or when using the COPY or USER function to write to a fixed length output record, truncation occurs when shifting to the right extends data beyond the record boundary.

When EDIT replaces a data field with new-data of shorter length, File-AID shifts contiguous data to the left until a blank is found (see Example 3:). File-AID inserts blanks to compensate for the eliminated data. If no blanks are found, blanks are inserted at the end of the record (see Example 4:).

When the EDIT parameter is used with the COPY function to process variable-length files, File-AID lengthens or shortens the output record when necessary.

In an UPDATE function, record lengths must stay the same. When EDIT is used with the UPDATE function, lengthened records are truncated as discussed in Example 1:. Records from which data is eliminated during an UPDATE function remain the same length because File-AID adds trailing blanks to fill any remaining space in the record (see Example 3:).

Important

If the MOVE parameter is used with the EDIT or REPL parameters in one set of actions, specify the EDIT and/or REPL parameters before the MOVE parameter. The EDIT and REPL parameters act on the input record, and if the input data is moved to the output area, the EDIT or REPL changes following a MOVE do not appear in the output dataset.

Example 1:

EDIT=(1,5,C’1234’,C’ABCDE’)

Example 1 uses the UPDATE function and replaces the compare-data string 1234 in a field with the longer new-data string ABCDE. When this statement is executed, the results on two records are:

Before:

----+----1----+----2----+----3
1234 ABCD9999999999999STUVWXYZ
12346ABCD9999999999999STUVWXYZ

After:

----+----1----+----2----+----3
ABCDE ABCD9999999999999STUVWXY
ABCDE6ABCD9999999999999STUVWXY

The last character of each record is truncated because the length of both records is 30 bytes and the UPDATE function was used.

Example 2:

EDIT=(1,6,C’AAAA’,C’BBBBBBBB’)

Example 2 replaces string AAAA with string BBBBBBBB. When the longer new-data string is inserted, the fields are shifted, and when required, compressed. When this statement is executed, the results on two records are:

Before:

----+----1----+----2----+----3
AAAAA    12  34  56  789000
AAAAA   123 456  78  900000

After:

----+----1----+----2----+----3
BBBBBBBBA 12 34 56 789000
BBBBBBBBA 123 456 78 900000

Example 3:

EDIT=(1,5,C’1234’,C’1’)

Example 3 replaces the string 1234 with the shorter string1. When this statement is executed, the results on two records are:

Before:

----+----1----+----2----+----3
1234 ABCD9999999999999ZZZZ
12346ABCD9999999999999ZZZZ

After:

----+----1----+----2----+----3
1    ABCD9999999999999ZZZZ
16ABCD9999999999999ZZZZ

Note that because Record 1 contained a blank after the compare-data string 1234, File-AID inserts blanks immediately after the new-data string 1. However, Record 2 contained no embedded blanks, so the remaining data is shifted to the left.

Example 4:

EDIT=(1,6,C’AAAA’,C’’)

Example 4 totally eliminates data by coding a null entry to replace the string AAAA. When this statement is executed, the results on two records are:

Before:

----+----1----+----2----+----3
AAAAA    12  34  56  789000
AAAAAAAA123 456  78  900000

After:

----+----1----+----2----+----3
A        12  34  56  789000
AAAA123     456  78  900000

Example 5:

EDIT=(1,6,C’123’,P’+00123’)

Example 5 converts a zoned numeric value of 123 to a 3-byte packed value of +123 (X’00123C’). Leading zeros in the packed new-data value are used to calculate the new-data length. The plus sign (+) in the new-data value forces a C sign (positive) for the new packed field. A minus sign (-), if specified, forces a D sign (negative) for the new packed field. If no sign is specified, an sign is placed in the new packed field. In this example, data does not shift because the compare-data and the new-data are the same length (three bytes). When the statement shown in example 5 is executed, the results on two records are:

Before:

CHAR 123ABC 123
ZONE FFFCCC4FFF
NUMR 1231230123
     1...5...10

CHAR AB123C 123
ZONE CCFFFC4FFF
NUMR 1212330123
     1...5...10

After:

CHAR    ABC 123
ZONE 013CCC4FFF
NUMR 02C1230123
    1...5...10

CHAR AB C 123
ZONE CC013C4FFF
NUMR 1202C30123
     1...5...10

 

 

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