Running z/OS UNIX applications under z/OS batch

Using the BPXBATCH utility

Use the IBM-supplied BPXBATCH program to run a XL C/C++ application under z/OS® batch from a z/OS UNIX file. You can invoke the BPXBATCH utility from TSO/E, or by using JCL. The BPXBATCH utility submits a batch job and performs an initial user login to run a specified program from the shell environment.

Before you invoke BPXBATCH, you must have the appropriate authority to read from and write to z/OS UNIX files. For writing program output such as error messages, you should allocate z/OS UNIX files to stdout and stderr. Allocate the standard files using the PATH options on the TSO/E ALLOCATE command or the JCL DD statement.

For more information on the BPXBATCH program, refer to BPXBATCH utility.

Invoking BPXBATCH from TSO/E

From TSO/E, you can invoke BPXBATCH several ways:
  • From the TSO/E READY prompt
  • From a CALL command
  • From a REXX EXEC

Figure 1 shows a REXX EXEC that does the following:

  1. Runs the application program /myap/base_comp from your user ID
  2. Directs output to the file /myap/std/my.out
  3. Writes error messages to the file /myap/std/my.err
  4. Copies the output and error data to data sets
Figure 1. REXX EXEC to Run a Program
/* base_comp REXX exec */
"Allocate File(STDOUT) Path('/u/myu/myap/std/my.out')
          Pathopts(OWRONLY,OCREAT,OTRUNC) Pathmode(SIRWXU) Pathdisp(DELETE,DELETE)"
"Allocate File(STDERR) Path('/u/myu/myap/std/my.err')
          Pathopts(OWRONLY,OCREAT,OTRUNC) Pathmode(SIRWXU) Pathdisp(DELETE,DELETE)"
 
"BPXBATCH PGM /u/myu/myap/base_comp"
 
"Allocate File(output1) Dataset
('MYAPPS.STD(BASEOUT)')"
"Ocopy Indd(STDOUT) Outdd(output1) Text Pathopts(OVERRIDE)"
 
"Allocate File(output2) Dataset('MYAPPS.STD(BASEERR)')"
"Ocopy Indd(STDERR) Outdd(output2) Text Pathopts(OVERRIDE)"

To invoke BPXBATCH, enter the name of the REXX EXEC from the TSO/E READY prompt. When the REXX EXEC completes, the files allocated to stdout and stderr are deleted.

Invoking BPXBATCH using JCL

To invoke BPXBATCH using JCL, submit a job that executes an application program and allocates the standard files using DD statements. For example, to run the application program /myap/base_comp from your user ID, direct its output to the file /myap/std/my.out, write error messages to the file /myap/std/my.err, and code the JCL statements as follows:
//jobname  JOB …
//stepname EXEC PGM=BPXBATCH,PARM='PGM /u/myu/myap/base_comp'
//STDOUT    DD PATH='/u/myu/myap/std/my.out',
//          PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU
//STDERR    DD PATH='/u/myu/myap/std/my.err',
//          PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU

Submitting a non-z/OS UNIX System Services executable to run under batch

If your program requires z/OS UNIX System Services, but has been link-edited into a load module (PDS member) or bound into a non-z/OS UNIX program object (PDSE member), it can be executed in the z/OS batch environment. Use the JCL EXEC statement to submit the executable to run under the batch environment. You must have the runtime option POSIX in effect, either as #pragma runopts(POSIX(ON)), or as PARM='POSIX(ON)/'.