The Put samples

The Put sample programs put messages on a queue using the MQPUT call.

The source programs are supplied in C and COBOL in the batch and CICS environments (see Table 45 and Table 50).

Design of the Put sample

The flow through the program logic is:

  1. Connect to the queue manager using the MQCONN call. If this call fails, print the completion and reason codes and stop processing.
    Note:
    If you are running the sample in a CICS environment, you do not need to issue an MQCONN call; if you do, it returns DEF_HCONN. You can use the connection handle MQHC_DEF_HCONN for the MQI calls that follow.
  2. Open the queue using the MQOPEN call with the MQOO_OUTPUT option. On input to this call, the program uses the connection handle that is returned in step 1. For the object descriptor structure (MQOD), it uses the default values for all fields except the queue name field which is passed as a parameter to the program. If the MQOPEN call fails, print the completion and reason codes and stop processing.
  3. Create a loop within the program issuing MQPUT calls until the required number of messages are put on the queue. If an MQPUT call fails, the loop is abandoned early, no further MQPUT calls are attempted, and the completion and reason codes are returned.
  4. Close the queue using the MQCLOSE call with the object handle returned in step 2. If this call fails, print the completion and reason codes.
  5. Disconnect from the queue manager using the MQDISC call with the connection handle returned in step 1. If this call fails, print the completion and reason codes.
    Note:
    If you are running the sample in a CICS environment, you do not need to issue an MQDISC call.

The Put samples for the batch environment

To run the samples, you must edit and run the sample JCL, as described in Preparing and running sample applications for the batch environment.

The programs take the following parameters in an EXEC PARM, separated by spaces in C and commas in COBOL:

  1. The name of the queue manager (4 characters)
  2. The name of the target queue (48 characters)
  3. The number of messages (up to 4 digits)
  4. The padding character to be written in the message (1 character)
  5. The number of characters to write in the message (up to 4 digits)
  6. The persistence of the message (1 character: 'P' for persistent or 'N' for nonpersistent)

If you enter any of the above parameters wrongly, you will receive appropriate error messages.

Any messages from the samples are written to the SYSPRINT data set.

Usage notes

The Put samples for the CICS environment

The transactions take the following parameters separated by commas:

  1. The number of messages (up to 4 digits)
  2. The padding character to be written in the message (1 character)
  3. The number of characters to write in the message (up to 4 digits)
  4. The persistence of the message (1 character: 'P' for persistent or 'N' for nonpersistent)
  5. The name of the target queue (48 characters)

If you enter any of the above parameters wrongly, you will receive appropriate error messages.

For the COBOL sample, invoke the Put sample in the CICS environment by entering:

  MVPT,9999,*,9999,P,QUEUE.NAME

For the C sample, invoke the Put sample in the CICS environment by entering:

  MCPT,9999,*,9999,P,QUEUE.NAME

Any messages from the samples are displayed on the screen.

Usage notes



© IBM Corporation 1993, 2002. All Rights Reserved