I am evaluating j8583
as a library to parse ISO8583
messages. It works as expected for almost all fields but I am having trouble getting the correct value for Field 33.
I have created the following unit test:
@Test
public void testDecode() throws IOException, ParseException {
MessageFactory<IsoMessage> messageFactory = ConfigParser.createFromClasspathConfig("j8583.xml");
messageFactory.setUseBinaryMessages(true);
String testData = "0100000000018000000006560103095900000360";
IsoMessage isoMessage = messageFactory.parseMessage(HexCodec.hexDecode(testData), 0);
assertEquals("560103", isoMessage.getField(32).toString());
assertEquals("590000036", isoMessage.getField(33).toString());
}
And here is my config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE j8583-config PUBLIC "-//J8583//DTD CONFIG 1.0//EN" "http://j8583.sourceforge.net/j8583.dtd">
<j8583-config>
<parse type="0100">
<field num="32" type="LLBCDBIN" length="11"/>
<field num="33" type="LLBCDBIN" length="11"/>
</parse>
</j8583-config>
When running the unit test Field 32 is parsed correctly, but 33 fails. The value I get for Field 33 is 900000360
Since they are both configured the same and the data seems to be the same (06560103095900000360), I don't understand why this does not parse correctly
For odd lengths, the values are left-padded, not right-padded. So the first nibble is ignored, not the last one.
I'm sorry it's not clear in the documentation. I'll amend it to specify this.