Trigger Message Passed to an Invoked Program

When a task is invoked by the MQ Trigger Monitor when a trigger event occurs for a queue, the trigger message data is made available to the program associated with the task. The MQTM structure describes the data in the trigger message. An IBM copybook may be used to define the structure and the fields may then be used in the program, see the following COBOL example. For a full source listing of the example, see the IDMSMQCB member in the CAGJSAMP library. For the IBM copybook CMQTMx, see Copy and include files section above and the appropriate IBM documentation.
idms19
When a task is invoked by the MQ Trigger Monitor when a trigger event occurs for a queue, the trigger message data is made available to the program associated with the task. The MQTM structure describes the data in the trigger message. An IBM copybook may be used to define the structure and the fields may then be used in the program, see the following COBOL example. For a full source listing of the example, see the IDMSMQCB member in the CAGJSAMP library. For the IBM copybook CMQTMx, see Copy and include files section above and the appropriate IBM documentation.
COBOL Example
The following COBOL example uses the LINKAGE SECTION to pass the MQTM (Trigger Message) structure for use in the program. Using the
'PROCEDURE DIVISION USING MQM-TRIGGER-MESSAGE'
statement, the COBOL program can use the fields defined in the CMQTML copybook. In the following example, the field MQTM-USERDATA is used in the COBOL program.
LINKAGE SECTION.         *    This IBM copybook contains the MQTM structure that is passed         *    to the application program via linkage from the IDMS MQ         *    Trigger Monitor.  It is optional to use the MQTM structure.          01  MQM-TRIGGER-MESSAGE.              COPY CMQTML.         *****************************************************************         *         *  PROCEDURE DIVISION         *         *****************************************************************         *    Procedure Division using MQTM structure          PROCEDURE DIVISION USING MQM-TRIGGER-MESSAGE.        *    Example of using MQTM-USERDATA field once received.             MOVE MQTM-USERDATA                TO MQ-WTL-TEXT.
ADS Example
In the following ADS example, the field MQTM-QNAME is used in the ADS dialog to open the queue. For a full source listing of the example, see the IDMSMQAB member in the CAGJSAMP library.                                                
The record that describes the MQTM structure must be included as a work record in the dialog definition. The CMQTMx copybook can be added as a work record to the ADS dialog. See ADD RECORD statement in the following ADS example.  
!********************************************************************** !* CALL MQOPEN TO OPEN THE TRIGGER MONITOR QUEUE. THIS IS SUPPLIED    *  !* VIA THE MQTM STRUCTURE PASSED BY THE IDMS TRIGGER MONITOR PROGRAM. *  !**********************************************************************   MOVE MQTM-QNAME  TO MQOD-OBJECTNAME.   MOVE W00-QMGR    TO MQOD-OBJECTQMGRNAME.   MOVE MQOT-Q      TO MQOD-OBJECTTYPE.   COMPUTE W03-OPENOPTIONS =   MQOO-INPUT-AS-Q-DEF +                               MQOO-FAIL-IF-QUIESCING.   CALL MQOPEN.   GENERATE FROM SOURCE ADD DIALOG IDMSMQAB     VERSION 0001        MAINLINE YES        AUTOSTATUS YES        STATUS DEFINITION RECORD ADSO-STAT-DEF-REC            VERSION 0001        ACTIVITY LOG YES        SYMBOL TABLE YES        DIAGNOSTIC TABLE YES        MESSAGE PREFIX DC        COBOL MOVE NO        ENTRY POINT PREMAP        RETRIEVAL LOCKING YES       ADD RECORD      CMQV                             VERSION 0001        ADD RECORD      CMQODV                           VERSION 0001        ADD RECORD      CMQMDV                           VERSION 0001        ADD RECORD      CMQPMOV                          VERSION 0001        ADD RECORD      CMQGMOV                          VERSION 0001        ADD RECORD      CMQSTSV                          VERSION 0001        ADD RECORD      CMQTML                           VERSION 0001          <- Add MQTM structure record