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

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: |
Default Value | None |
Example |
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*