Modal logic allows the user to perform conditional execution of processes. In the IBM® Connect:Direct® versions up to and including 6.2, lmodal logic enabled the comparison of 8-character strings using the IF-ELSE-EIF construct. However, starting from IBM Connect:Direct release 6.3, modal logic now supports the comparison of operands with strings up to 64 characters long.
The MODALIF construct in IBM Connect:Direct allows users to execute code conditionally based on comparing two operands. The format for using MODALIF involves specifying the two operands being compared, along with the comparison operator being used. If the comparison between the operands is true, the code following the "THEN" keyword will be executed. If the comparison evaluates to false, the code following the "ELSE" keyword will be executed
IF (OPER1 COND OPER2) THEN // execute code if the condition is true ELSE // execute code if the condition is false EIF
- = (equal to)
- < (less than)
- > (greater than)
- <> (not equal to)
- ^= (not equal to)
- ^< (not less than)
- ^> (not greater than)
- <= (less than or equal to)
- >= (greater than or equal to)
- EQ (equal to)
- NE (not equal to)
- LT (less than)
- GT (greater than)
- LE (less than or equal to)
- GE (greater than or equal to)
By using the MODALIF construct, Connect DirectIBM Connect:Direct users can execute their processes conditionally and tailor them to specific requirements.
|[optional]||IF||(label condition nn)|
|[no label]||ELSE||(alternative process steps)|
IBM Connect:Direct users can also use variables or strings as operands to compare using the MODALIF logic. This feature enables more flexibility and customization of processes.
However, it is important to note that when using MODALIF, the second operand (OPER2) should not contain data in multiple lines. This is because MODALIF compares the entire string in one line, and any additional lines in OPER2 will result in an error.
To avoid this issue, users can use multiple variables to construct the MODALIF statement. This involves breaking up the data in OPER2 into separate variables, each containing a single line of data. These variables can then be concatenated using string manipulation functions, and used as the second operand in the MODALIF statement.
By following these guidelines, IBM Connect:Direct users can effectively utilize the MODALIF logic and perform conditional execution of processes with ease.
MODALIF PROCESS SNODE=CD.ZOS.NODE1 HOLD=NO - &USERID=%USER - &VAR1=N12345678901234567890123456789012345678901234567890 || - 1234567890123 - &VAR2=N1234567890123456789012345678901234567890123 - &VAR3=N1234567890123456789012345678901234567890123 - &VAR4=N1234567890 || - 1234567890 || - 1234567890 || - 1234567890 || - 1234567890 || - 1234567890 || - 122 IF (&VAR1 EQ C'N123456789012345678901234567890123456789012345678901234567890122') THEN C01 COPY FROM (DSN=DATESET1 DISP=(SHR) PNODE) – TO (DSN=REC.DATASET1 DISP=(RPL) SNODE) ELSE C02 COPY FROM (DSN=DATASET1 DISP=(SHR) PNODE) – TO (DSN=REC.DATASET2 DISP=(RPL) SNODE) EIF IF (&VAR1 EQ C"&VAR2") THEN C03 COPY FROM (DSN=REC.DATASET1 DISP=(SHR) PNODE) – TO (DSN=REC.DATASET2 DISP=(RPL) SNODE) ELSE C04 COPY FROM (DSN=REC.DATASET1 DISP=(SHR) PNODE) – TO (DSN=REC.DATASET3 DISP=(RPL) SNODE) EIF IF (&VAR4 EQ C"VAR2.VAR3") THEN C05 COPY FROM (DSN=USER1.DATASET1 DISP=(SHR) PNODE) – TO (DSN=USER2.DATASET1 DISP=(RPL) SNODE) ELSE C06 COPY FROM (DSN=USER1.DATASET1 DISP=(SHR) PNODE) – TO (DSN=USER3.DATASET1 DISP=(RPL) SNODE) EIF
In this example, the MODALIF construct is used to conditionally execute the COPY command based on the comparison of different operands. The operands used in the comparison can be fixed strings or variables.
For instance, the first IF statement compares the value of the &VAR1 variable with a fixed string “N123456789012345678901234567890123456789012345678901234567890122". If the comparison is true, the code following the "THEN" keyword will be executed, which is the COPY command from DSN=DATESET1 to DSN=REC.DATASET1. If the comparison is false, the code following the "ELSE" keyword will be executed, which is the COPY command from DSN=DATASET1 to DSN=REC.DATASET2. Similarly, the second and third IF statements compare the values of multiple variables with each other or with fixed strings and execute the corresponding COPY commands based on the results of the comparisons.
MODALIF logic follows standard EBCDIC comparison. The standard EBCDIC comparison method is designed in such a way that when comparing characters, numbers are greater than letters. Moreover, uppercase letters are ranked higher than lowercase letters, and most special characters are ranked lower than both numbers and letters.
MODALIF supports alphanumeric characters as well as three special symbols: @, #, and $. The first (left) operand is treated as the step name and is always folded in uppercase.