Suppose you want data from certain fields to be included in your output under certain conditions, but omitted in others. For example, if a field is filled in, you want its value to be included in the record, but if the field is empty, you want the value omitted, avoiding spaces or zeros in the record. (This is analogous to a conditional programming statement such as an if/then statement.)
You can do this by inserting #If and #EndIf transaction fields into your transaction description. (Instructions.)
|
Variable |
Format |
Explanation/comment |
|
#If, #EndIf |
N(1)* |
If the expression you insert ¹0, then all transaction fields between #If and #EndIf, except for those following #ElseIf and #Else, are inserted. |
|
#ElseIf |
N(1)* |
If the #If expression =0, the #ElseIf expression is tried. If the #ElseIf expression ¹0, then all transaction fields between #ElseIf and the next #ElseIf, #Else or #EndIf are inserted. |
|
#Else |
N(1)* |
If the #If and #ElseIf expressions =0, the transaction fields between #Else and #EndIf are inserted. |
* The above transaction fields have the Format N or N(1), but their Length is 0 because these particular transaction fields never themselves result in any data being written to the transfer file.
The structure is as follows:
#If
…
#ElseIf (optional)
…
#ElseIf (optional)
…
#Else (optional, need not follow #ElseIf)
…
#EndIf
Note: When you choose a separator character in your transaction description, usually the last field in each record is not followed by that character. However, the exception is when the transaction description contains #If statements. In this case the last field in the record can be followed by a separator character because, for example, the last transaction field is #EndIf.