Calling programs from a procedure with logic
You might have procedures that call applications.
When you call your callable interface application from a procedure with logic,
be careful about the number of ampersands you specify for the substitution
variables in your application. This is important if the program being
called contains a RUN command with substitution variables,
as in RUN QUERY WEEKLY_Q (&&DEPT=58
.
Calling programs without substitution variables
- The ADDRESS instruction This instruction establishes a command environment. For example, if you want to call a program that is named PANDA from within the TSO environment, enter this command:
ADDRESS TSO "PANDA"
- The CALL instruction This instruction starts a program. For the program named PANDA, the command is:
CALL PANDA
- A function You also can call the program PANDA as a function:
ANSWER = PANDA()
You might consider removing the substitution variables from the RUN command if you want to call your programs by using one of the REXX invocation calls. In that case, QMF prompts the user for the variables.
Calling programs that contain substitution variables
Whether you are running a procedure with logic or a callable interface program that is invoked by a procedure with logic, commands come into QMF the same way. In this context, the callable interface program becomes a logical extension of the procedure itself.
- Use the TSO command
to call the application as follows:
TSO <program name>
When you call the application using this command, QMF does not process any substitution variables it encounters. For example, the substitution variable in the following RUN QUERY command embedded in the program is passed to the query rather than being interpreted as a variable of the program:RUN QUERY WEEKLY_Q (&DEPT=58
- Treat all substitution variables in
your application as though you were using them in a procedure with logic.
Add an extra ampersand to every substitution variable so the procedure with logic does not resolve it. For example, consider the following command:
RUN QUERY WEEKLY_Q (&DEPT=58
In a procedure with logic, use two ampersands on the substitution variable to pass the variable to the query:"RUN QUERY WEEKLY_Q (&&DEPT=58"
If a substitution variable has only one ampersand, QMF resolves the variable for the procedure itself, and cannot pass the variable to the query.
- Use global variables.
You can define global variables at the start of your application and use them throughout your QMF session.