How to issue DB2 Commands using Batch Processor Online or in Batch.

Document ID : KB000048261
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

Batch processor is able to process the standard DB2 Commands such as -START or -STOP or -DISPLAY in batch or online. It might be handy to add such commandsinto a job stream to carry out useful functions.

Solution:

The DB2 commands to be executed by batch processor must be enclosed in a batch processor command list:

Here is an example:

.CALL DSN PARM(ssid)
.DATA
-STOP DATABASE (DBCORP1) SPACENAM(*)
-DISPLAY DATABASE (DBCORP1) LIMIT(300)
-START DATABASE (DBCORP1) SPACENAM(*)
-DISPLAY DATABASE (DBCORP1) LIMIT(300)
-DISPLAY UTILITY (*)
.ENDDATA

The .CALL DSN command calls the DB2 command processor passing the subsystem id.

The DB2 commands are enclosed by a .DATA and .ENDDATA so that the command processor knows where the last command is. The commands are executed one by one.

This command list can be executed online by batch processor using the Batch Processor Interface specifying EXECUTION MODE ===> O

The output is displayed on the screen. This output could be sent to a dataset using the QFILE command on the command line.

This command list can be executed in batch also using the standard JCL for batch processor…..nothing else needed.

//STEP1 EXEC PGM=PTLDRIVM,REGION=4M,PARM='EP=BPLBCTL'
//STEPLIB DD DISP=SHR,DSN=PTIPROD.RD17GA1.CDBALOAD
// DD DISP=SHR,DSN=ssid.PRIVATE.SDSNEXIT
// DD DISP=SHR,DSN=DB2.SDSNLOAD
//PTILIB DD DISP=SHR,DSN=PTIPROD.RD17GA1.CDBALOAD
// DD DISP=SHR,DSN=ssid.PRIVATE.SDSNEXIT
// DD DISP=SHR,DSN=DB2.SDSNLOAD
//PTIPARM DD DISP=SHR,DSN=PTIPROD.RD17GA1.CDBAPARM
//PTIXMSG DD DISP=SHR,DSN=PTIPROD.RD17GA1.CDBAXMSG
//SYSOUT DD SYSOUT=*
//PTIIMSG DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//ABNLIGNR DD DUMMY SUPPRESS ABENDAID DUMPS
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(30,30))
//SYSREC DD UNIT=SYSDA,SPACE=(TRK,(1,1))
//BPIIPT DD DISP=SHR,
// DSN=command.list.dataset(commands)
//BPIOPT DD *
.CONTROL BPID(command.list.dataset-commands) +
LOGID(ssid) UNIT(SYSDA)
.LIST SYSOUT(A,,X)
.OPTION NOERRORS NOSQLERRORS RETRY(01) NOBINDERRORS +
WRAPLINE
.RESTART OVERRIDE
.CONNECT ssid

You might specify a .RESTART OVERRIDE above in case one of the commands fails as it will leave the Batch Processor in a restart condition. In this way the job can simply be resubmitted from the start.

You could direct this output to an existing dataset also:

Instead of

.LIST SYSOUT(A,,X)

use

.LIST FILE(hlq.your.sysout)

This would help to preserve the output if needed for auditing.