Using Exec Files for Input to the Batch Facility

There are a variety of ways that exec procedures can help facilitate the submission of jobs to the CMS batch facility. The following examples are very simple. You probably would not go to the trouble of sending such a job to the batch virtual machine for processing. The examples do, however, illustrate the two basic ways that you can use exec procedures with the batch facility:
  • Initiating an exec procedure from a batch virtual machine
  • Using an exec procedure to create a job stream for the batch virtual machine.

Example 1: You can prepare an exec file that contains all of the CMS commands you want to execute, and then pass the name of the exec to the batch virtual machine.

Suppose you have the following file, COPY JCL:
/JOB CARBON 999999
CP LINK MCGUIRE 191 391 RR LINKPASS
ACCESS 391 B/A
EXEC COPYF
/*
and the file, COPYF EXEC:
/*    */
'COPYFILE FIRST FILE B SECOND = A'
'COPYFILE THIRD FILE B FOURTH = A'
If you enter the commands:
spool punch to cmsbatch
punch copy jcl * (noheader
the commands in COPYF EXEC are executed by the batch virtual machine.
Example 2: You could also use an exec to punch input to the batch virtual machine. Using the same commands as in the previous example. Suppose you have the following exec named BATCOPY that contains the same commands used in the previous example:
/* exec to submit a batch job */
'CP SPOOL PUNCH TO BATCH3 CONT'
punch = 'EXECIO 1 PUNCH (STRING'  /* initializing a variable */
punch '/JOB CARBON 999999'
punch 'CP LINK MCGUIRE 191 391 RR LINKPASS'
punch 'ACCESS 391 B/A'
punch 'COPYFILE FIRST FILE B SECOND = A'
punch 'COPYFILE THIRD FILE B FOURTH = A'
punch '/*'
'CP SPOOL PUNCH NOCONT CLOSE'
Then, when you enter the exec name:
batcopy
the input lines are punched to the batch virtual machine.

In either case, the execs you use may be simple or complicated. In the first instance, an exec might contain many steps, with control statements to conditionally control execution, error routines, and so on.

In the second instance, you might have an exec that is versatile so that it can be used with different arguments so as to satisfy more than one situation. For example, you can create a simple exec to send any job to the batch virtual machine to be assembled. This exec, called BATCHASM EXEC, might contain:
/* An exec for batch assemblies */
'CP SPOOL PUNCH TO BATCH3 CONT'
arg filename .
punch = 'EXECIO 1 PUNCH (STRING'  /* initializing a variable */
punch '/JOB MCGUIRE 888888'
punch 'CP LINK MCGUIRE 191 391 RR LINKPASS'
punch 'ACCESS 391 B/A'
punch 'ASSEMBLE' filename '(PRINT'
punch 'CP SPOOL PUNCH TO MCGUIRE'
punch 'PUNCH' filename 'TEXT A'
punch '/*'
'CP SPOOL PUNCH NOCONT CLOSE'
Now, whenever you want the CMS batch facility to assemble a source file for you, enter:
batchasm filename
The batch virtual machine will assemble the source file (filename), print the listing, and send you a copy of the resulting TEXT file.