The Receive Message (RCVMSG) command, the Receive Nonprogram Message (QMHRCVM) API, and the Receive Program Message (QMHRCVPM) API have a CCSID-to-convert-to parameter. This parameter determines which CCSID the text or data is converted to before it is returned to the user.
The Receive Message command and APIs convert the text or data from the CCSID of the message queue or message file to the CCSID supplied on the CCSID-to-convert-to parameter. When replacement data is returned, only the *CCHAR data is converted from the CCSID of the message queue to the CCSID-to-convert-to value.
If the CCSID of the message file or message queue is 65534, the text or data is converted from the CCSID of the message description or message to the CCSID supplied on the CCSID-to-convert-to parameter.
The default for the CCSID-to-convert-to parameter is *JOB, which means that the CCSID of the job performing the receive operation is used.
Two CCSID return fields are supported by the Receive Message (RCVMSG) command:
The Receive Message (QMHRCVM) API and the Receive Program Message (QMHRCVPM) API support the return fields defined in TXTCCSID return field for receive message command and DTACCSID return field for receive message command. The Receive Message API and the Receive Program Message API also support two additional return fields.
Message description TST0005 has the following first-level text:
This is &CHAR &1; This is *CCHAR &2;
'&1' is defined as a *CHAR field of length 1. '&2' is defined as a *CCHAR field (*VARY 2) in length.
Message file MYMSGF has a CCSID of 65534. TST0005 is defined in message file MYMSGF. The message description CCSID is 65535. The CCSID of message queue MYMSGQ is 65534.
You enter the following Send Program Message command:
SNDPGMMSG MSGF(MYMSGF) MSGID(TST0005) CCSID(37) TOMSGQ(MYLIB/MYMSGQ) + MSGDTA(X'7B00017B')
The message is not converted when it is sent to message queue MYMSGQ because the message queue CCSID is 65534. The message is tagged with CCSID 00037.
You enter the following Receive Message command to receive the message just sent:
RCVMSG MSGQ(MYLIB/MYMSGQ) MSG(&MSG); DTACCSID(&DTACCSID); + CCSID(277) MSGDTA(&MSGDTA); TXTCCSID(&TXTCCSID);
Because the message description is tagged 65535, no conversion is performed when retrieving the message text of TST0005. The replacement data is tagged 00037. The *CCHAR part of the message data is converted from CCSID 00037 to CCSID 00277 before being inserted for &2; *CHAR data is never converted.
The following table shows the returned values after the Receive Message command runs:
Value | Description |
---|---|
&MSG = | This is &CHAR . This is *CCHAR #. The *CHAR data was not converted when substituted for &1; The *CHAR data remains X'7B'. X'7B' is the code point on code page 00277 for A ligature (). The *CCHAR data was converted to X'4A' before it was substituted for &2; X'4A' is the code point on code page 00277 for the number sign (#). |
&TXTCCSID = 65535 | The &TXTCCSID variable was set to 65535 because no conversion occurred. When no conversion occurs, the CCSID of the message description is returned if the CCSID of the message file is 65534. |
&DTACCSID = 00277 | The &DTACCSID variable was set to 00277 because a conversion occurred. |
Message file MYMSGF has a CCSID of 00037. Message queue MYMSGQ has a CCSID of 65534. The message being received has a message-level CCSID of 00277. CCSID 65534 uses the message-level CCSID when determining the CCSID the replacement data is to be converted from.
The message being received is a stored message. The stored message has *CCHAR replacement data. The CCSID of the job is 00278. You enter the following Receive Message command:
RCVMSG MSGQ(MYMSGQ) MSG(&MSG); MSGDTA(&MSGDTA);
The first-level text of the stored message that you receive is converted from CCSID 00037 to CCSID 00278. The replacement data of the message that you receive is converted from CCSID 00277 to CCSID 00278. Then the replacement data is substituted into the first-level text and returned in &MSG.
Both the first-level text and the replacement data of the message that you received are converted to the CCSID of the job because the CCSID of the job is the default for the CCSID-to-convert-to parameter.
Two different conversions must occur because only the replacement data is stored in the message queue for stored messages. The text of a stored message must be retrieved from the message file. If the message contained other replacement data type fields that were not defined as *CCHAR, the non-*CCHAR data is not converted before being returned.