REPLACE SEGMENT


Use to specify the segments you want replaced in the output file. (If you do not replace or select a segment, it is not included in the output file.)

  • You specify the information to replace a segment by using FIELD keywords in the WITH option based on criteria defined by the WHEN keyword.
  • If you are replacing more than one segment, you specify the REPLACE SEGMENT keyword for each segment you want to replace.
  • You can only specify REPLACE SEGMENT once for each segment name. For example, you cannot specify REPLACE SEGMENT twice for SEG01.

If you specify the name of the segment:

  • Without specifying a condition for WHEN, the EXTRACT command replaces the segment
  • And you specify a condition using WHEN (expression), the EXTRACT command replaces the segment when the condition in the expression is true

GUID-401A1911-57E0-4E85-A465-85A40773329F-low.png

Required or Optional

Optional

Synonym

None

Values

Specify the name of the segment that you want replaced in the output file. This segment becomes the current segment that the EXTRACT command uses in the FIELD and WHEN expressions.

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

For information about the:

WHEN-DELETE-REPLACE-and-SELECT-SEGMENT_2

WITH

Default Value

None

Example

  • Extracts from a database with the name &dbdname
  • Selects the segment with the name &segname
  • Replaces the segment with the segment &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