Send Nonprogram Message (QMHSNDM) API


  Required Parameter Group:


  Optional Parameter Group:


  Default Public Authority: *USE

  Threadsafe: Yes

The Send Nonprogram Message (QMHSNDM) API sends a message to a nonprogram message queue so your program can communicate with another job or user.

To send a message to a call message queue or the external message queue, see Send Program Message (QMHSNDPM) API.

Before coding your call to the QMHSNDM API, see Dependencies among Parameters.

If your application attempts to diagnose and recover from errors, it might need to take additional action before calling the QMHSNDM API. The QMHSNDM API sends a message to a list of message queues. When the API encounters an error in sending your message to a message queue in the list, it sends a diagnostic message to your call message queue. The API then proceeds to the next message queue in the list. After trying to send the message to all specified message queues and if the API detected any errors, it returns the general escape message CPF2469. This message is sent as an exception or in the error code.

To diagnose and recover from these errors, your program should call the Receive Program Message (QMHRCVPM) API to receive the diagnostic messages sent.


Authorities and Locks

Message File Authority
*USE
Message File Library Authority
*EXECUTE
Message Queue Authority
*OBJOPR and *ADD
Message Queue Library Authority
*EXECUTE
Reply Message Queue Authority
*OBJOPR and *ADD
Reply Message Queue Library Authority
*EXECUTE

Required Parameter Group

Message identifier
INPUT; CHAR(7)

The identifying code for the predefined message being sent, or blanks for an immediate message.

If you specify a message identifier, you must specify a qualified message file name. If you do not specify a message identifier, the qualified message file name parameter is ignored.

Qualified message file name
INPUT; CHAR(20)

For a predefined message, the name of the message file and the library in which it resides. The first 10 characters specify the file name, and the second 10 characters specify the library.

You can use these special values for the library name:

For an immediate message, use blanks for this parameter. If you specify a name, the API ignores it and does not return an error.

Replacement data or impromptu message text
INPUT; CHAR(*)

If a message identifier is specified, the data to insert in the predefined message's substitution variables. If no message identifier is specified, the complete text of an immediate message.

If this parameter contains pointer data, each pointer must start on a 16-byte boundary to keep the data accurate.

Length of replacement data or impromptu message text
INPUT; BINARY(4)

The length of the message data or immediate text, in bytes. Valid values for each are:


Message type
INPUT; CHAR(10)

The type of the message. You must specify one of these values:

For descriptions of the message types, see Message Types. For details about coding the other parameters when sending a particular type of message, see Dependencies among Parameters.

List of qualified message queue names
INPUT; ARRAY of CHAR(20)

A list of 1 through 50 message queues to which the message is being sent, and the libraries in which they reside. When sending an inquiry message, you can list one message queue, or you can list two message queues if one of the queues is *HSTLOG. The special value *HSTLOG indicates the message will be sent to QSYS/QHST. When using the special value *ALLACT, you can list only one queue. In all other cases, you can list up to 50 message queues.

You can specify user profile message queues or other nonprogram message queues, or you can use several special values.

To specify the default message queue associated with a user profile, use the first 10 characters for the user profile name. In the second 10 characters, use the special value *USER.

To specify other nonprogram message queues, use the first 10 characters for the message queue name and the second 10 characters for the library name. You can use these special values for the library name:

To specify other types of message queues, use one of the following special values for the first 10 characters, and leave the second 10 characters blank:


Number of message queues
INPUT; BINARY(4)

The number of message queues specified in the list of qualified message queue names parameter. Valid values are 1 through 50. When using the special value *ALLACT for the message queue, you must specify 1. When sending an inquiry message, you can specify 1 or you can specify 2 if one of the values is *HSTLOG.

Qualified name of the reply message queue
INPUT; CHAR(20)

For an inquiry message only, the name of the message queue to receive the reply message, and the library in which it resides.

The first 10 characters specify the message queue, and the second 10 characters specify the library.

You can use these special values for the message queue name:

You can use these special values for the library name:

For all message types except inquiry, use blanks for this parameter. If you specify a message queue, the API ignores it and does not return an error.

Message key
OUTPUT; CHAR(4)

For an inquiry message only, the key to the sender's copy of the message in the reply message queue. This API assigns the key when it sends the message.

For all other message types, no key is returned.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Optional Parameter Group

Coded character set identifier
INPUT; BINARY(4)

The coded character set identifier (CCSID) that the supplied replacement data or impromptu message text is in. If a message identifier is specified, the text supplied by the replacement data or impromptu message text parameter that corresponds to *CCHAR type fields is assumed to be in the CCSID supplied by this parameter. The data supplied that does not correspond to a *CCHAR field is 65535 and is not converted. For more information about *CCHAR type fields see the Add Message Description (ADDMSGD) command.

If no message identifier is specified, the impromptu message text supplied by the replacement data or impromptu message text parameter will all be assumed to be in the CCSID supplied by this parameter. For more information about message handler and its use of CCSIDs, see CCSID support for messages. The following values are allowed:


Dependencies among Parameters

You can use many different combinations of parameters when calling the QMHSNDM API. The values you specify for the message identifier and message type parameters determine which other input parameters you must specify and which you must code as blanks. They also determine whether the system returns the message key in the message key output parameter.

The following table summarizes the use of parameters for the QMHSNDM API.

The terms used in the table to describe the parameter values are defined in the following list.



Error Messages



API introduced: V3R6

[ Back to top | Message Handling APIs | APIs by category ]