FIELD (REPLACE SEGMENT)


Use with REPLACE SEGMENT to specify the expression that determines the contents of the field to be included in the segment you are replacing.

You can also change the format of the data when it is added to the output file using TRANSFORM. The changes to the format include the:

  • length
  • type of data

Follow these guidelines when you specify the FIELD keyword.

  • Repeat the FIELD keyword until you have defined the segment.
  • Specify the fields in the order that you want them to appear in the output file.

Expressions used with REPLACE SEGMENT can only refer to the current segment (the one named in the REPLACE SEGMENT keyword) or segments higher in the hierarchical path.

GUID-A2D96F5C-F2C4-46FF-AA0D-0CE6442658B7-low.png

Required or Optional

Required if you specify the WITH keyword

Synonym

None

Values

This keyword is followed by an option list that contains several keywords as shown in the syntax diagram above

Specify the expression that determines the contents of the field that is replaced.

Default Value

None

Example

  • Extracts from a database with the name &dbdname
  • Selects the segment with the name &segname
  • Replaces the segment with a segment that has a name of &segname
  • If the field specified using &field1 contains the format specified using &format, then the field is transformed to the format specified using s:lt
  • If the field specified using &field1 does not contain the format specified using &format, the field is transformed to the format specified using s:lt and the value specified using &n is placed in the field
  • Includes the field specified using &field2
  • Formats the output file with no header, trailer, or prefix (If you want to use a predefined format, you must the FORMAT keyword.)
  • Places the output in a file with a name in the format &outdd
 EXTRACT( DBDNAME( &dbdname )
    OUTPUTFILE ( DDNAME( &outdd )
    SELECT SEGMENT ( &segname )
    REPLACE SEGMENT ( &segname
        WITH (
            FIELD (
           ( IF ( &field1 IS &format ) THEN ( &field1 ) ELSE ( &n ) )
           TRANSFORM ( s:lt )
           )
           FIELD ( ( &field2 ) )
           )
           )
           )
           )

 

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

iExtract for IMS 8.2