Application programming on z/OS
Previous topic | Next topic | Contents | Glossary | Contact z/OS | PDF


How procedures are used

Application programming on z/OS

To save time and prevent errors, you can prepare sets of job control statements and place them in a partitioned data set (PDS) or partitioned data set extended (PDSE), known as a procedure library. This can be used, for example, to compile, assemble, link-edit, and execute a program.

A procedure library is a library that contains procedures. A set of job control statements in the system procedure library, SYS1.PROCLIB or an installation-defined procedure library, is called a cataloged procedure.

To test a procedure before storing it in a procedure library, add the procedure to the input stream and execute it; a procedure in the input stream is called an inline procedure. The maximum number of inline procedures you can code in any job is 15. In order to test a procedure in the input stream, it must end with a procedure end (PEND) statement. The PEND statement signals the end of the PROC. This is only required when the procedure is coded inline. In a procedure library, you do not require a PEND statement.

An inline procedure must appear in the same job before the EXEC statement that calls it.

Figure 1. Sample definition of a procedure
//DEF     PROC STATUS=OLD,LIBRARY=SYSLIB,NUMBER=777777
//NOTIFY  EXEC PGM=ACCUM
//DD1     DD   DSNAME=MGMT,DISP=(&STATUS,KEEP),UNIT=3400-6,
//             VOLUME=SER=888888
//DD2     DD   DSNAME=&LIBRARY,DISP=(OLD,KEEP),UNIT=3390,
//             VOLUME=SER=&NUMBER

Three symbolic parameters are defined in the cataloged procedure shown in Figure 1; they are &STATUS, &LIBRARY, and &NUMBER. Values are assigned to the symbolic parameters on the PROC statement. These values are used if the procedure is called but no values are assigned to the symbolic parameters on the calling EXEC statement.

In Figure 2 we are testing the procedure called DEF. Note that the procedure is delineated by the PROC and PEND statements. The EXEC statement that follows the procedure DEF references the procedure to be invoked. In this case, since the name DEF matches a procedure that was previously coded inline, the system will use the procedure inline and will not search any further.

Figure 2. Testing a procedure inline
 //TESTJOB  JOB ....
 //DEF      PROC STATUS=OLD,LIBRARY=SYSLIB,NUMBER=777777
 //NOTIFY   EXEC PGM=ACCUM
 //DD1      DD   DSNAME=MGMT,DISP=(&STATUS,KEEP),UNIT=3400-6,
 //              VOLUME=SER=888888
 //DD2      DD   DSNAME=&LIBRARY,DISP=(OLD,KEEP),UNIT=3390,
 //              VOLUME=SER=&NUMBER
 //         PEND
 //*
 //TESTPROC EXEC DEF
 //




Copyright IBM Corporation 1990, 2010