z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Calling a subprocedure

z/OS TSO/E CLISTs
SA32-0978-00

You call a subprocedure using the SYSCALL statement. On the SYSCALL statement, name the subprocedure and any parameters you want to pass to the subprocedure. The parameters can be data strings, variable values, or variable names.

For example, the following CLIST uses the SYSCALL statement to pass a data string (Jones), a variable value (&A), and a variable name (B) to a subprocedure (XYZ):
   SET &A = AL
   SET &B = Jr.
   SYSCALL XYZ Jones &A B        /* pass parameters to XYZ             */

XYZ: PROC 3 PARM1 PARM2 PARM3    /* receive parameters on PROC stmt    */
       SYSREF PARM3              /* indicate parm3 holds a var. name   */
       WRITE &PARM1, &PARM2 &PARM3  /* result: JONES, AL Jr.           */
     END
Subprocedures always begin with a labeled PROC statement. The label can consist of 1-31 characters (A-Z, 0-9, #, $, @) beginning with an alphabetic character (A-Z). In the example above, the label is XYZ; the number 3 on the PROC statement indicates that the subprocedure receives 3 positional parameters; those parameters are assigned to the variables PARM1, PARM2, and PARM3. For more information about the PROC statement, see PROC statement.

The SYSREF statement tells the CLIST that PARM3 contains the name of a variable (B). The SYSREF statement allows other statements in subprocedure to reference and modify the variable's value (Jr.). For more information, see Using the SYSREF statement.

To pass a parameter containing blanks to a subprocedure, set a variable equal to the parameter value, then refer to that variable (without the ampersand) using &STR on the SYSCALL statement. In the subprocedure, use the SYSREF statement to refer to the PROC statement parameter that corresponds to the variable name passed on the SYSCALL statement. For example,
SET &A = JOHN AL
SYSCALL XYZ &STR(A)  /* Pass variable to XYZ, omitting & from
                            /* the variable name
⋮
XYZ: PROC 1 PARM     /* Subprocedure XYZ
SYSREF &PARM         /* indicate PARM holds a variable name
WRITE &PARM          /* result: JOHN AL

Subprocedures must always end with the END statement. When subprocedures end, they pass control back to the statement following the SYSCALL statement.

Subprocedures can use the SYSCALL statement to:
  • Call other subprocedures and pass parameters to them
  • Call themselves
  • Call the CLIST's main procedure, if it has a label

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014