Example of running a batch Db2 application in TSO
Most application programs that are written for the batch environment run under the TSO Terminal Monitor Program (TMP) in background mode.
The following figure shows the JCL statements that you need in order to start such a job. The list that follows explains each statement.
//jobname JOB USER=MY DB2ID
//GO EXEC PGM=IKJEFT01,DYNAMNBR=20
//STEPLIB DD DSN=prefix.SDSNEXIT,DISP=SHR
// DD DSN=prefix.SDSNLOAD,DISP=SHR
⋮
//SYSTSPRT DD SYSOUT=A
//SYSTSIN DD *
DSN SYSTEM (ssid)
RUN PROG (SAMPPGM) -
PLAN (SAMPLAN) -
LIB (SAMPPROJ.SAMPLIB) -
PARMS ('/D01 D02 D03')
END
/*- The JOB option identifies this as a job card. The USER option specifies the Db2 authorization ID of the user.
- The EXEC statement calls the TSO Terminal Monitor Program (TMP).
- The STEPLIB statement specifies the library in which the DSN Command Processor load modules and DSNHDECP or a user-specified application defaults module reside. It can also reference the libraries in which user applications, exit routines, and the customized DSNHDECP module reside. The customized DSNHDECP module is created during installation.
- Subsequent DD statements define additional files that are needed by your program.
- The DSN command connects the application to a particular Db2 subsystem.
- The RUN subcommand specifies the name of the application program to run.
- The PLAN keyword specifies plan name.
- The LIB keyword specifies the library that the application should access.
- The PARMS keyword passes parameters to the run time processor and the application program.
- END ends the DSN command processor.
Usage notes
- Keep DSN job steps short.
- Recommendation: Do not use DSN to call the EXEC command processor to run CLISTs that contain ISPEXEC statements; results are unpredictable.
- If your program abends or gives you a non-zero return code, DSN terminates.
- You can use a group attachment or subgroup attachment name instead of a specific ssid to connect to a member of a data sharing group.