TFLD

Read syntax diagramSkip visual syntax diagram
Syntax

                                             .-'EQ')------.   
>>-TFLD--(--+-#nn(subscript)-------+----,----+-'operator'-+----->
            '-fieldname(subscript)-'                          

>----,----+-----------+----,----+-----+--)---------------------><
          | .-,-----. |         '-VER-'      
          | V       | |                      
          '---value-+-'                      

(Can be used in FASTREXX condition expressions.)

Performs a conditional test against any field defined in a template. For dimensioned fields, you can apply the condition to any or all of the elements of the array. You can only use this function if the associated function is running with a copybook or template.

Note: The Field name (fieldname), field reference (#nn), operator (operator), and non-numeric values should all be enclosed in quotation marks to avoid syntax errors.
#nn or fieldname
#nn
Use this form when providing free-format criteria during template edit. nn is the field reference number displayed during template edit. It is not valid to use fieldname for a field reference when providing criteria during template edit.
fieldname
Use this form of identifying fields when coding user procedures. For non-unique names, you can specify a name in the form groupname.dataname. Name matching is not case-sensitive. If the name is unqualified, then the first occurrence of the name is used. Do not code #nn values in user procedures, as the displayed field reference values do not identify the correct field when running from a user procedure.
subscript
This applies only to dimensioned fields. You can specify one of these forms:
(ANY)
This is the default if you do not specify a subscript for a dimensioned field and it indicates that at least one element of the associated array must satisfy the condition for a true result.
(ALL)
This indicates that all elements of the associated array must satisfy the condition for a true result.
(nn)
This refers to a single array element and you should provide a valid subscript for the dimensioned field.
operator
The default is EQ or =. This function supports all the operators described for dynamic template and criteria edit. For details about the operators supported and their description, see
value
The value or values entered must be valid in the context of the operator and the field which is being referenced. For example, only certain operators like CO (contains) allow multiple values. Numeric values should be entered when testing numeric fields, and so on.
Specifying hexadecimal strings
A hexadecimal string must be in the form 'hhhhhh'x. The value enclosed in quotation marks must be an even number of characters and contain valid hexadecimal characters (0–9, A–F).
Specifying binary strings
A binary string must be in the form 'nnnnnn'b. The value enclosed in quotation marks must be a combination of "0"s and "1"s.
Specifying character strings
For non-numeric types, the value should be enclosed in quotation marks.
VER
Verify the field is composed only of characters specified in the value column.

Example 1

Check every element of the dimensioned field CONTACTS and process only those records with contact values of 'Smith' or 'Jones'.
Note: In this case, we use operator CU so the contains processing is not case-sensitive.
if TFLD('CONTACTS(ANY)','CU','Smith','Jones') then
   return
 else
   return 'DROP'

Example 2

Check the monthly pay for a contract record types and process those with every month occurrance higher than 8000.
Note: MPAY is not unique, so we qualify which MPAY we want to check.
Copybook
 01 REC-CONTRACT.
    05 MPAY      PIC S9(8) Binary OCCURS 12 Times.
 01 REC-Employee.
    05 MPAY      PIC S9(8) Binary OCCURS 12 Times.

 if TFLD('REC-CONTRACT.MPAY(ALL)','>',8000) then
   return
 else
   return 'DROP'

Performance notes

TFLD is faster than FLD_CO, but requires a template to reference a field value.
TFLD('#3',,'CO','A')  & TFLD('#3',,'CO','B')
would be faster if coded as:
TFLD('#3',,'ACO','A','B')