How difficult can it be to use BPXBATCH? It is harder and more interesting than you may think.

I just wanted to add a parameter to the started procedure for a web server. It took me over three days with lots of help to achieve it. I found that many things I thought I knew – turned out to be wrong!

BPXBatch is a program that allows you to run shell programs (and proper programs) that run in Unix Services on z/OS. As every one knows you can pass parameters using

  • exec pgm=bpxbatch,parm=’…’
  • exec pgm=bpxbatch,parmdd=pardmdd and having //pardmdd dd…
  • //stdparm dd …

The challenge I had was to use this in a started task. I had

//COLWEB PROC AA=’ABCD’,BB=’EFGH’
//IHS EXEC PGM=BPXBATCH,REGION=0M,
// PARM=’SH longname.sh -aa &ABCD -bb &BB’
//STDOUT DD SYSOUT=H
//STDERR DD SYSOUT=H
//STDENV DD …

and wanted to add some debug information to the command. This would make the parm=’…’ longer than 100 characters and so parm=’…’ cannot be used. I converting it to

//COLWEB PROC AA=’ABCD’,BB=’EFGH’
//IHS EXEC PGM=BPXBATCH,REGION=0M,PARMDD=PARMDD
//PARMDD DD * SYMBOLS=JCLONLY
SH longname.sh xx -aa &ABCD -bb &BB -debug longstring
/*
//STDOUT DD SYSOUT=H
//STDERR DD SYSOUT=H
//STDENV DD …

did not work – the parameters were not passed through.

If I used

//COLWEB PROC AA=’ABCD’,BB=’EFGH’
// EXPORT SYMLIST=*
// SET T1=’ABCD’
// SET T2=’EFGH’

//IHS EXEC PGM=BPXBATCH,REGION=0M,PARMDD=PARMDD
//PARMDD DD * SYMBOLS=JCLONLY
SH longname.sh xx -aa &T1 -bb &T2 -debug longstring
/*
/*

This worked ok. I believe the reason why &AA and &BB cannot be used is that symbols have to be exported before they are defined, for them to be used in DD * statements. As you cannot put an “EXPORT” before the procedure, they cannot be exported.

A solution is

//COLWEB PROC AA=’ABCD’,BB=’EFGH’
// EXPORT SYMLIST=*
// SET SAA=&AA
// SET SBB=&BB

//IHS EXEC PGM=BPXBATCH,REGION=0M,PARMDD=PARMDD
//PARMDD DD * SYMBOLS=JCLONLY
SH longname.sh xx -aa &SAA -bb &SBB -debug longstring
/*
/*

This works fine; the command was

SH longname.sh xx -aa ABCD -bb EFGH -debug longstring

It now starts to get interesting

Originally I used

// SET SAA=’&AA’

Having learned the hard way to put quotes around things.

The statement was then

SH longname.sh xx -aa &AA -bb &BB -debug longstring

When this executed the parameters were

xx -aa

This was shock – where was the rest of the data?

The SH… basically invokes a shell command, and although the documentation does not describe it, you can do things like

SH set -x;longname.sh xx -aa &AA -bb &BB -debug longstring

Which sets the shell trace flag. Executing this prints out a trace of all of the shell program statements executed.

As this is a shell command, the “&” signifies that the command is to run asynchronously (in the background. (This is well known in the Unix world, see the sh command syntax) The string passed to the command is up to the &.

If you want to pass a “&” you need \&, and so the string should really be specified as

SH set -x;longname.sh xx -aa \&AA -bb \&BB -debug longstring

Lessons learned

  • If you want to pass started task parameters through to a dataset, you need to use intermediate set symbols
  • Do not put quotes around the started task parameters.

Thanks

I’d like to thank Paul Gilmartin who gave me a lot of help in the shell side of thing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s