You can print the same commissions report as in the previous example, but add REXX logic to check whether the day is Monday. If it is Monday, the procedure can automatically print the report.
The rules and the structure of procedures with logic follow those of any REXX program. For more information about the REXX procedural language, see either of the following:
To create a procedure with logic:
RESET PROC
The PROC panel displays.
Because QMF does not convert any text in a procedure, type all QMF commands in uppercase, or they do not run.
Enclose all QMF commands in quotes, otherwise any QMF command identical to a REXX command (such as EXIT) is processed as a REXX command.
If you want to display and interact with panels just as you would if you entered a command on the QMF command, type INTERACT before the command name.
For more information on the INTERACT command, see the QMF Reference, SC26-4716-05.
You can also include internal functions for arithmetic operations, character manipulation, data conversion, and information gathering, and you can write your own external functions.
The procedure in Figure 148 has two exit statements. One has an exit code of 0, meaning that the procedure ran successfully. The other has a return code of 8, meaning that an error occurred while the procedure was running.
Or you can type INSERT on the QMF command line, move the cursor to the line you want to precede the new line, and press Enter.
Or you can type DELETE on the QMF command line, move the cursor to the line you want to delete, and press Enter.
SAVE AS procname
Figure 148. This procedure produces a commission report on Mondays.
+--------------------------------------------------------------------------------+ | PROC MODIFIED LINE 1 | | | | /* This procedure checks to see what day it is. If it's | | Monday, it runs a query and prints a report. If it | | isn't, a message is displayed informing the user. */ | | signal on error | | if date('w') = 'Monday' then | | do | | "RUN QUERY MYQUERY (FORM = MYFORM" | | "PRINT REPORT" | | "MESSAGE (TEXT='OK, MONDAY report has been created and sent to printer.'" | | end | | else | | do | | "MESSAGE (TEXT='Sorry, it is not Monday. Report cannot be created.'" | | end | | exit 0 /*Exit without errors */ | | error: | | "MESSAGE (TEXT = '"dsq_message_text"'" | | exit 8 /*Exit with error condition*/ | | *** END *** | +--------------------------------------------------------------------------------+
In the procedure that is shown in Figure 148, the REXX DATE function provides the day of the week. The rest of the procedure includes QMF commands that are run depending on the day of the week.