OFLD_CO

Read syntax diagramSkip visual syntax diagram
Syntax

               .-1-----.     .-length(outrec)-start+1-.      
>>-OFLD_CO--(--+-------+--,--+------------------------+--,------>
               '-start-'     '-length-----------------'      

                .-,------.      
                V        |      
>--+------+--,----needle-+--)----------------------------------><
   '-type-'                     

(Can be used in FASTREXX condition expressions.)

Searches the field within the output record specified by start and length, for one or more occurrences of needle. On successful execution when searching for a string, also updates the value of OUTPOS to the first byte of the located field in the output record.

Returns
If at least one occurrence of needle is found, returns 1. If no occurrences are found, returns 0.
start
Position, in bytes, in the output record at which to start searching for occurrences of needle. Can be specified as:
Absolute position
Must be a positive integer. Default value is 1. If start is greater than the current length of the output record, the function has no effect.
Relative to current INPOS
Must be specified as IPx or INx. If this resolves to a value of less than or equal to zero, the function results in an error. If this resolves to a value that is greater than the current length of the input record, the function has no effect.
Relative to current OUTPOS
Can be specified as OPx or ONx, or as Px or Nx. If this resolves to a value of less than or equal to zero, the function results in an error. If this resolves to a value that is greater than the current length of the output record, the function has no effect.
length
Length, in bytes, of the field to be searched.
  • For character fields, the length defaults to the remaining record length from the start position to the end of the record (inclusive). A value of 0 also indicates that the field extends to the end of the record.
  • For binary fields, you must specify the length. It can be 2, 4, or 8.
  • For packed decimal fields, if you specify the length, it must be in the range 1-16. If you omit the length, FLD_CO attempts to determine the packed field length from the record data.
  • For zoned decimal fields, if you specify the length, it must be in the range 1-31 or, if the field contains a separate sign character, in the range 1-32. If you omit the length, it defaults to the remainder of the record.
type
The data type of the field. Valid values are:
B
Binary. FLD_CO interprets binary fields as being signed.
C
Character. This is the default. The comparison is case sensitive.
P
Packed decimal.
U
Interprets the field as Character, but converts it to uppercase before comparing it with needle.
Z
Zoned decimal. Interprets all of the COBOL external decimal variants as numeric data.
needle
String(s) or numeric(s) to search for. For the character types, FLD_CO searches the haystack for each of the needles. In this context, it behaves like a combination of the FLD and CONTAINS functions. For the numeric data types, the haystack is treated as a single numeric field, and an appropriate numeric comparison is performed against each of the needles. In this context it behaves like a combination of the FLD and NCONTAIN functions. You can search for up to 20 strings or numerics at a time.

To perform case-insensitive searches, specify type as 'U' and needle in uppercase.

Example 1

If the current output record contains “MIKE”, “Mike” or “mike” in the first ten columns, then write the record.
If FLD_CO(1,10,'U','MIKE') Then WRITE('MDD')

Example 2

If the current output record contains “USA”, “Australia” or “England”, then drop the record from processing.
If FLD_CO(,,,'USA','Australia','England') Then Return 'DROP'

Example 3

If the current output record contains “MIKE”, “Mike” or “mike” in the ten columns immediately after the current INPOS, then write the record.

If FLD_CO(P0,10,'U','MIKE') Then WRITE('MDD')