How completion and reason codes are returned
A completion code and reason code are returned as output by each statement. The completion code is stored in the IMFCC and IMFMQCC variables. The variables usually contain a 0 or 2 in IMFMQCC and a 0 or 8 in IMFCC, showing success and failure, respectively. Some IMFEXEC MQI statements can return an intermediate state, a 1 in IMFMQCC and a 4 in IMFCC, indicating partial success.
The reason code is stored in the IMFRC and IMFMQRC variables. The contents of both variables are the same. The reason code shows the reason for the failure, or partial success. There are many reason codes covering circumstances such as a full queue or get operations not allowed for a queue. Applications can analyze the reason code and based on the returned value, take additional actions.
The variable IMFMQI_REASON contains the constant (character string) reason code that corresponds with the numeric reason code returned by IBM MQ when an error is encountered. For example: when IBM MQ returns the reason code 2195, the variable IMFMQI_REASON contains ‘MQRC_UNEXPECTED_ERROR’. The numeric reason code is displayed on the EM9201I message, which is sent to the BBI journal when there is an error returned by IBM MQ.
The completion codes for each statement with the description of the statement are listed in Table 1.
Table 1. MQI EXEC completion codes
IMFMQCC | IMFCC | Reason | System action | User action |
---|---|---|---|---|
0 | 0 | Successful completion | None | None |
2 | 8 | IBM MQ returned error | Command fails | You have 2 options:
|
12 | Buffer too small | Message is not PUT to the queue and command fails. | Specify a buffer large enough to hold the entire message and all included structures. Refer to Creating-a-message-from-variables for more information. | |
4 | 16 | Syntax error | Command fails | Refer to EM0022E message in BBI journal for error description. |
20 | Variable Processing routine not found | Command fails; for COPY MQI and DISPLAY MQI commands only | Look for errors during BBI PAS startup, related to program QAVARS, correct if possible and restart the BBI PAS. Otherwise contact BMC Software customer support. |
The reason code is returned in the IMFMQRC and IMFRC variables; contents of both variables are the same. For the reason code descriptions, refer to the 'Message Queuing Constants' chapter of the IBM manual IBM MQ Application Programming Reference or the IBM Knowledge Center.