Dynamically calling the WebSphere MQ stub

Instead of link-editing the WebSphere MQ stub program with your object code, you can dynamically call the stub from within your program. You can do this in the batch, IMS, and CICS environments. This facility is not supported by programs using PL/I in the CICS environment and it is not supported in the RRS environment.

However, this method:

If you call the stub dynamically, the appropriate stub program and its aliases must be available at execution time. To ensure this, include the WebSphere MQ for z/OS data set SCSQLOAD:

For batch and IMS In the STEPLIB concatenation of the JCL
For CICS In the CICS DFHRPL concatenation

For IMS, you must ensure that the library containing the dynamic stub (built as described in the information about installing the IMS adapter in the WebSphere MQ for z/OS System Setup Guide) is ahead of the data set SCSQLOAD in the STEPLIB concatenation of the region JCL.

Use the names shown in Table 30 when you call the stub dynamically. In PL/I, only declare the call names used in your program.

Table 30. Call names for dynamic linking

MQI call Dynamic call name

Batch (non-RRS) CICS IMS
MQBACK CSQBBACK not supported not supported
MQCMIT CSQBCOMM not supported not supported
MQCLOSE CSQBCLOS CSQCCLOS MQCLOSE
MQCONN CSQBCONN CSQCCONN MQCONN
MQCONNX CSQBCONX CSQCCONX MQCONNX
MQDISC CSQBDISC CSQCDISC MQDISC
MQGET CSQBGET CSQCGET MQGET
MQINQ CSQBINQ CSQCINQ MQINQ
MQOPEN CSQBOPEN CSQCOPEN MQOPEN
MQPUT CSQBPUT CSQCPUT MQPUT
MQPUT1 CSQBPUT1 CSQCPUT1 MQPUT1
MQSET CSQBSET CSQCSET MQSET

For examples of how to use this technique, see the following figures:

Batch and COBOL Figure 23
CICS and COBOL Figure 24
IMS and COBOL Figure 25
Batch and assembler Figure 26
CICS and assembler Figure 27
IMS and assembler Figure 28
Batch and C Figure 29
CICS and C Figure 30
IMS and C Figure 31
Batch and PL/I Figure 32
IMS and PL/I Figure 33

Figure 23. Dynamic linking using COBOL in the batch environment



  ·
  ·
  ·
WORKING-STORAGE SECTION.
  ·
  ·
  ·
05 WS-MQOPEN PIC X(8) VALUE 'CSQBOPEN'.
  ·
  ·
  ·
PROCEDURE DIVISION.
  ·
  ·
  ·
CALL WS-MQOPEN WS-HCONN MQOD WS-OPTIONS WS-HOBJ WS-COMPCODE WS-REASON.
  ·
  ·
  ·

Figure 24. Dynamic linking using COBOL in the CICS environment



  ·
  ·
  ·
WORKING-STORAGE SECTION.
  ·
  ·
  ·
05 WS-MQOPEN PIC X(8) VALUE 'CSQCOPEN'.
  ·
  ·
  ·
PROCEDURE DIVISION.
  ·
  ·
  ·
CALL WS-MQOPEN WS-HCONN MQOD WS-OPTIONS WS-HOBJ WS-COMPCODE WS-REASON.
  ·
  ·
  ·

Figure 25. Dynamic linking using COBOL in the IMS environment



  ·
  ·
  ·
WORKING-STORAGE SECTION.
  ·
  ·
  ·
05 WS-MQOPEN PIC X(8) VALUE 'MQOPEN'.
  ·
  ·
  ·
PROCEDURE DIVISION.
  ·
  ·
  ·
CALL WS-MQOPEN WS-HCONN MQOD WS-OPTIONS WS-HOBJ WS-COMPCODE WS-REASON.
  ·
  ·
  ·
* ----------------------------------------------------------- * * * If the compile option 'DYNAM' is specified * then you may code the MQ calls as follows * * ----------------------------------------------------------- *
  ·
  ·
  ·
CALL 'MQOPEN' WS-HCONN MQOD WS-OPTIONS WS-HOBJ WS-COMPCODE WS-REASON.
  ·
  ·
  ·

Figure 26. Dynamic linking using assembler language in the batch environment



  ·
  ·
  ·
LOAD EP=CSQBOPEN
  ·
  ·
  ·
CALL (15),(HCONN,MQOD,OPTIONS,HOBJ,COMPCODE,REASON),VL
  ·
  ·
  ·
DELETE EP=CSQBOPEN
  ·
  ·
  ·

Figure 27. Dynamic linking using assembler language in the CICS environment



  ·
  ·
  ·
EXEC CICS LOAD PROGRAM('CSQCOPEN') ENTRY(R15)
  ·
  ·
  ·
CALL (15),(HCONN,MQOD,OPTIONS,HOBJ,COMPCODE,REASON),VL
  ·
  ·
  ·
EXEC CICS RELEASE PROGRAM('CSQCOPEN')
  ·
  ·
  ·

Figure 28. Dynamic linking using assembler language in the IMS environment



  ·
  ·
  ·
LOAD EP=MQOPEN
  ·
  ·
  ·
CALL (15),(HCONN,MQOD,OPTIONS,HOBJ,COMPCODE,REASON),VL
  ·
  ·
  ·
DELETE EP=MQOPEN
  ·
  ·
  ·

Figure 29. Dynamic linking using C language in the batch environment



  ·
  ·
  ·
typedef void CALL_ME(); #pragma linkage(CALL_ME, OS)
  ·
  ·
  ·
main() { CALL_ME * csqbopen;
  ·
  ·
  ·
csqbopen = (CALL_ME *) fetch("CSQBOPEN"); (*csqbopen)(Hconn,&ObjDesc,Options,&Hobj,&CompCode,&Reason);
  ·
  ·
  ·

Figure 30. Dynamic linking using C language in the CICS environment



  ·
  ·
  ·
typedef void CALL_ME(); #pragma linkage(CALL_ME, OS)
  ·
  ·
  ·
main() { CALL_ME * csqcopen;
  ·
  ·
  ·
EXEC CICS LOAD PROGRAM("CSQCOPEN") ENTRY(csqcopen); (*csqcopen)(Hconn,&ObjDesc,Options,&Hobj,&CompCode,&Reason);
  ·
  ·
  ·

Figure 31. Dynamic linking using C language in the IMS environment



  ·
  ·
  ·
typedef void CALL_ME(); #pragma linkage(CALL_ME, OS)
  ·
  ·
  ·
main() { CALL_ME * mqopen;
  ·
  ·
  ·
mqopen = (CALL_ME *) fetch("MQOPEN"); (*mqopen)(Hconn,&ObjDesc,Options,&Hobj,&CompCode,&Reason);
  ·
  ·
  ·

Figure 32. Dynamic linking using PL/I in the batch environment



  ·
  ·
  ·
DCL CSQBOPEN ENTRY EXT OPTIONS(ASSEMBLER INTER);
  ·
  ·
  ·
FETCH CSQBOPEN; CALL CSQBOPEN(HQM, MQOD, OPTIONS, HOBJ, COMPCODE, REASON); RELEASE CSQBOPEN;

Figure 33. Dynamic linking using PL/I in the IMS environment



  ·
  ·
  ·
DCL MQOPEN ENTRY EXT OPTIONS(ASSEMBLER INTER);
  ·
  ·
  ·
FETCH MQOPEN; CALL MQOPEN(HQM, MQOD, OPTIONS, HOBJ, COMPCODE, REASON); RELEASE MQOPEN;


© IBM Corporation 1993, 2002. All Rights Reserved