Issuing commands from application programs
Certain kinds of application programs can issue Db2 commands.
About this task
- APF-authorized programs
-
As with IMS, Db2 commands (including START DB2) can be passed from an APF-authorized program to multiple Db2 subsystems by the MGCRE (SVC 34) z/OS service. Thus, the value of the command prefix identifies the particular subsystem to which the command is directed. The subsystem command prefix is specified, as in IMS, when Db2 is installed (in the SYS1.PARMLIB member IEFSSNxx). Db2 supports the z/OS WTO command and response token (CART) to route individual Db2 command response messages to the invoking application program. Use of the CART is necessary if multiple Db2 commands are issued from a single application program.
For example, to issue DISPLAY THREAD to the default Db2 subsystem from an APF-authorized program that runs as a batch job, use the following code:
MODESUPV DS 0H MODESET MODE=SUP,KEY=ZERO SVC34 SR 0,0 MGCRE CMDPARM EJECT CMDPARM DS 0F CMDFLG1 DC X'00' CMDLENG DC AL1(CMDEND-CMDPARM) CMDFLG2 DC X'0000' CMDDATA DC C'-DISPLAY THREAD' CMDEND DS 0C
Db2 returns the following messages:
DSNV401I - DISPLAY THREAD REPORT FOLLOWS - DSNV402I - ACTIVE THREADS - ⋮ DSN9022I - DSNVDT '-DISPLAY THREAD' NORMAL COMPLETION
- IFI application programs
-
An application program can issue Db2 commands using the instrumentation facility interface (IFI). This method of issuing commands returns information about the success or failure of the command to your program. If the command issues a non-zero return code, the information returned to your program includes diagnostic information about the command processed. For commands that are executed asynchronously, the return code indicates whether the command started successfully.
The IFI application program protocols are available through the IMS, CICS®, TSO attachment facilities, the call attachment facility (CAF), and the Resource Recovery Services attachment facility (RRSAF).