The If Condition command allows you to enter simple “if...then” (“if” the condition specified is true, the “then” rule is preformed) and “If..then..else” (“if” the condition specified is true, the “then” rule is preformed. Otherwise, the “else” rule is performed.) logic into rules. This command also allows you to perform a specific rule if an error occurs which would be written to the log file or the trace file. After executing any “If Condition” command, the program always proceeds to the next command line in the rule.
Left – choose from:
Memory Variable – displays next to the Rule Command window. Drag a memory variable and drop it on the bottom text box below the Left text box.
Record/Field – displays next to the Rule Command window. Navigate down through a record to reveal the fields. Drag a field and drop it on the bottom text box below the Left text box.
System Variable – displays next to the Rule Command window. Drag a system variable and drop it on the bottom text box below the Left text box.
A system variable that returns a status can be used to test for special conditions. For example, the system variable SQL_RETURN can be evaluated after each SQL FETCH is performed to see if data is present.
Log Error Occurs – when you select Log Error Occurs, all the text boxes except If True are grayed out. An entry in the error log causes the rule specified in the If True text box to be performed. In the rule, you can specify additional actions to be taken when an error is encountered at runtime. For example, a report can be written to a user-defined file if an error occurs.
After an element is mapped or a rule is performed, the program checks to see if an error occurred. If a rule command caused multiple errors, Log Error Occurs reports only the last error condition that occurred. (The trace file and the log file have separate messages for each error.) Examples of multiple errors would be if the trading partner record is not found, if the control numbers on inbound don't match, if an incoming map segment does not match, or if the program terminates abnormally with an error message.
Logical – choose from:
EQ – equal to.
NE – not equal to.
GT – greater than.
GE – greater than or equal to.
LT – less than.
LE – less than or equal to.
Right – choose from:
Memory Variable – displays next to the Rule Command window. Drag a memory variable and drop it on the bottom text box below the Right text box.
Record/Field – displays next to the Rule Command window. Navigate down through a record to reveal the fields. Drag a field and drop it on the bottom text box below the Right text box.
System Variable – displays next to the Rule Command window. Drag a system variable and drop it on the bottom text box below the Right text box.
Constant – enter a value in the text box on the Constant Value window that displays and select OK. The value is automatically entered in the Right text box.
Error Condition – choose from the drop-down list of error conditions. (Error conditions are represented internally in the system by 2-digit codes. You can use an If Condition to compare one of these internal error codes to the value in a record field, memory variable, or system variable.) The 2-digit codes and explanations for each error condition are shown below:
Number |
Code |
Explanation |
---|---|---|
No Error |
Normal completion, with no errors detected. |
|
02 |
End of File |
The program reached the end of the file being processed. |
03 |
Duplicate Key |
You are attempting to add a record that already exists. |
04 |
Record Missing |
The requested record was not found. |
05 |
File Full |
The file space allocated has been exhausted. |
06 |
Device Error |
A physical device error has occurred. |
07 |
Open Error |
You are attempting to open a file that is already open, or an I/O command was issued before a file was opened. |
08 |
Out of Memory |
There is not enough memory available. |
09 |
File Conflict |
There is a conflict between file attributes. |
10 |
File Missing |
The operating system cannot find a file. |
Other |
An unspecified error condition has occurred. |
If True rule – performed when the If Condition is true or a Log Error Occurs. You can type the rule number in the If True text box, or you can select the up arrow to search for it. If you select the up arrow, the Rule Definitions window displays. On this window, you can select a rule or add a new one.
Else rule – performed when the If Condition is not true. You can type the rule number in the Else text box, or you can select the up arrow to search for it. If you select the up arrow, the Rule Definitions window displays. On this window, you can select a rule or add a new one.