The XFD WHEN directive supports complex expressions such as those containing multiple AND and OR operations and parentheses to group sub-expressions for proper order of evaluation. For example:
$XFD WHEN (var1 = "abc" or var1 = "def") and \ $XFD (var2 > "000" or var3 > "000") and \ $XFD var4 != "xyzzy"
Here is a more complete example:
fd idx1-file. 01 idx1-record1. 03 filler pic x(46). 01 idx1-record2. 03 idx1-key. 05 idx1-num1 pic 9(3). 05 idx1-num2 pic 9(3). 05 idx1-num3 pic 9(3). 03 filler pic x(37). $xfd when ((idx1-num1 = "000" or idx1-num1 = "009") and \ $xfd (idx1-num2 = "000" or idx1-num2 = "009")) \ $xfd tablename=one 01 idx1-record3. 03 filler pic x(6). 03 rec3-name1 pic x(20). $xfd when idx1-num3 = "333" or idx1-num3 = "444", tablename=two 03 rec3-name2 pic x(20). $xfd when idx1-num1 = "001" AND idx1-num2 = "001" 01 idx1-record4. 03 filler pic x(6). 03 rec4-name1 pic x(30). 03 rec4-name2 pic x(10). $xfd when idx1-num1 > "001" OR idx1-num2 > "001" 01 idx1-record5. 03 filler pic x(6). 03 rec5-text pic x(40).
$XFD WHEN var1 = "abc" or var2 = "def" $XFD WHEN var3 = "xyz" 01 record-type-2.
If what you meant was:
$XFD WHEN (var1 = "abc" or var2 = "def") \ $XFD and var3 = "xyz" 01 record-type-2.
then you must code it that way (note the use of parentheses and the backslash XFD directive line continuation character).
"The optional condition tablename at the end of a WHEN directive applies to all simple conditions within the expression and to the overall combined expression. For example:
$XFD WHEN (var1 = "abc" or var1 = "def") and \ $XFD (var2 = "123" or var2 = "456") \ $XFD tablename = table-2 01 record-type-2.
The condition tablename table-2 is applied to all four simple conditions and propagated to the two OR conditions and to the final AND condition of the expression.