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

If your program does not contain a RUN command that includes substitution variables, use one of the following methods to start your program:
  • 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:
  • The CALL instruction
    This instruction starts a program. For the program named PANDA, the command is:
  • A function
    You also can call the program PANDA as a function:

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.

If your application contains QMF RUN commands with substitution variables, you have three choices for how to resolve those variables:
  • 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:
  • 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:
    In a procedure with logic, use two ampersands on the substitution variable to pass the variable to the query:

    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.