Search code examples
javaibm-mqibm-midrangemqtibco

Issue with MQ EBCDIC data conversion (25) interpreted as line feed and converted to 15


We have an interesting issue that came up.

We have an integration between AS400 system that sends MQ messages in EBCDIC format, picked up by TIBCO BW MQ plugin and processed. These are financial transactions.

The issue we have is that when the data element (packed decimal) contains odd digits like 251-259 or 25001-25999 etc. the data element is being interpreted by TIBCO BW MQ plugin as 151-159 etc.

So we had an amount of 25125 interpreted as 15125 causing a transaction tally missing of $100 (amounts in cents). TIBCO BW MQ plugin uses Java underneath, so this is probably a Java issue. AS400 is able to send and receive as 25125. But when we browse the message from MQ explorer, we see the data element value rendered as 15125 too.

AS400 team specifies that since they are able to send and receive as 25125 the issue is not on their side. Did anyone encounter a similar issue before? If so, how did you solve it? Is this an issue with MQ client or an issue with AS400 MQ delivering the message?


Solution

  • Thanks all for different pointers.

    This turned out to be an issue with the java jars provided along with MQ client. It turns out that this particular byte '0x25' has the curious property that when processed by the JVM in this way and treated as a character encoded in the CCSID 37 scheme, the output byte is '0x15'.

    For example, using a code snippet of the following form:

    byte[] bytesRepresentation = {(byte)0x25};
    String dataAsString = new String(bytesRepresentation, "IBM-037");
    byte[] newBytesRepresentation =
    dataAsString.getBytes(Charset.forName("IBM-037"));
    System.out.println(byteArrayToHexString(bytesRepresentation));
    System.out.println(byteArrayToHexString(newBytesRepresentation));
    

    the output is:

    25 15

    ie. the byte sequence has been changed by the byte[]->String->byte[] processing.

    MQ Support had recommended that the sending side change the message property that identifies message format as MQSTR to be changed to default (blank). After doing this, MQ client does not attempt a conversion and TIBCO received this properly from MQ client.