Put a message using MQPUT
This example demonstrates how to use the MQPUT call using context.
This extract is taken from the Credit Check sample application (program CSQ4CVB1) supplied with IBM MQ for z/OS . For the names and locations of the sample applications on other platforms, see Sample procedural programs (platforms except z/OS ).⋮ * -------------------------------------------------------* WORKING-STORAGE SECTION. * -------------------------------------------------------* * * W02 - Queues processed in this program * 01 W02-TEMPORARY-Q PIC X(48). * * W03 - MQM API fields * 01 W03-HCONN PIC S9(9) BINARY VALUE ZERO. 01 W03-HOBJ-INQUIRY PIC S9(9) BINARY. 01 W03-OPTIONS PIC S9(9) BINARY. 01 W03-BUFFLEN PIC S9(9) BINARY. 01 W03-COMPCODE PIC S9(9) BINARY. 01 W03-REASON PIC S9(9) BINARY. * 01 W03-PUT-BUFFER. * 05 W03-CSQ4BIIM. COPY CSQ4VB1. * * API control blocks * 01 MQM-MESSAGE-DESCRIPTOR. COPY CMQMDV. 01 MQM-PUT-MESSAGE-OPTIONS. COPY CMQPMOV. * * MQV contains constants (for filling in the * control blocks) and return codes (for testing * the result of a call). * 01 MQM-CONSTANTS. COPY CMQV SUPPRESS. * -------------------------------------------------------* PROCEDURE DIVISION. * -------------------------------------------------------* ⋮ * Open queue and build message. ⋮
* * Set the message descriptor and put-message options to * the values required to create the message. * Set the length of the message. * MOVE MQMT-REQUEST TO MQMD-MSGTYPE. MOVE MQCI-NONE TO MQMD-CORRELID. MOVE MQMI-NONE TO MQMD-MSGID. MOVE W02-TEMPORARY-Q TO MQMD-REPLYTOQ. MOVE SPACES TO MQMD-REPLYTOQMGR. MOVE 5 TO MQMD-PRIORITY. MOVE MQPER-NOT-PERSISTENT TO MQMD-PERSISTENCE. COMPUTE MQPMO-OPTIONS = MQPMO-NO-SYNCPOINT + MQPMO-DEFAULT-CONTEXT. MOVE LENGTH OF CSQ4BIIM-MSG TO W03-BUFFLEN. * CALL 'MQPUT' USING W03-HCONN W03-HOBJ-INQUIRY MQMD MQPMO W03-BUFFLEN W03-PUT-BUFFER W03-COMPCODE W03-REASON. IF W03-COMPCODE NOT = MQCC-OK ⋮ END-IF.Parent topic: COBOL examples