FLDI

Figure 1. Syntax

1  FLDI (
2.1! 1
2.1 start
1 ,
1 length
1 ,
1 type
1 ,
1! 'EQ'
1 operator
2?  + , value
2  , duplication
2?   VER
2  )

Can be used in FASTREXX condition expressions.

Performs a conditional test against input record field defined in by the start length and type parameters.

Note:
  1. The operator (operator), and non-numeric values should all be enclosed in quotation marks to avoid syntax errors.
  2. If you specify a value for length that would cause the record length to be exceeded, a false result is returned.
  3. If you specify a numeric type (types B, P, Z), and the specified field contains invalid data for that type, then the function returns a false result. Numeric data is always returned in integer form; that is, the function does not perform scaling of numeric data.
start
Position in bytes, in the input record at which to start reading the field value. Can be specified as:
Absolute position
Must be a positive integer. If start is greater than the current length of the input record, the function has no effect.
Relative to current INPOS
Can be specified as IPx or INx, 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 input record, the function produces a false result.
Relative to current OUTPOS
Must be specified as OPx or ONx. 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 produces a false result.
length
The length of the field in bytes.
  • For binary fields, you must specify the length. It can be 2, 4, or 8.
  • For character fields, if you omit the length, the length is defaulted:
    • For contains type operators, to the rest of the input record.
    • When all values are variable substitutions, to the rest of the input record.
    • Otherwise, the maximum literal value length is be used.
  • For packed decimal fields, if you specify the length, it must be in the range 1–16. If you omit the length, the function attempts to determine the packed field length from the record data and returns only that field.
  • 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, the function returns the remainder of the record. If this exceeds 32, then the function returns a false result.
type
The data type of the field. Valid values are:
B
Binary. The function interprets binary fields as being signed.
C
Character. This is the default.
P
Packed decimal.
U
Interprets the field as character, but converts it to uppercase before returning the string.
Z
Zoned decimal. Interprets all of the COBOL external decimal variants as numeric data.
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.
  • Specify a variable by specifying &variable_name. A variable is substituted for the value if a matching character, numeric, or tally variable can be located. If a matching variable cannot be found, the string is treated as a literal value. If a numeric comparison is being performed, a character variable is converted to a number - if the conversion fails, the function returns a false result. If a numeric or tally variable is referenced in a character comparison, then the value is the number converted to its display form with leading zeros removed.
duplication
Specify an integer n to duplicate the literal value n times.
Note: This can only be used for operators that support a single value (for example, Not contains) and where the value is a literal constant and not a substitute variable.
VER
Verify the field is composed only of characters specified in the value column.

Example 1

Check the input record and process only those records that contain values of 'Smith' or 'Jones'.

Note: In this case, use operator CU so the contains processing is not case-sensitive.
  if FLDI(1,,C,'CU','Smith','Jones') then
     return
   else
     return 'DROP'

Example 2

Process all records with a salary greater than 75000, where salary is a packed decimal value found at start position 28.

Note: In this case, allow File Manager to calculate the packed decimal field length
  if FLDI(28,,P,'>',75000) then
     return
   else
     return 'DROP'

Example 3

Process all input records with the value 'ABCABCABCABCABC' at start position 10.

Note: The length defaults to 15, the literal value length.
If FLDI(10,'=','ABC',5) then
     return
  else
     return 'DROP'

Example 4

The same as Example 2, but using a numeric variable.
SETN(salary_high,75000)
if FLDI(28,,P,'>','&salary_high') then
     return
   else