If you have to create ISO8583 credit/debit card messages in IBM Integration Bus, but the messages use 'unpacked' bitmaps instead of the more usual 'packed' bitmaps, then read on ...
ISO8583 messages consist of a number of optional fixed-length or prefixed-length fields without initiators. The presence of a given data field in the message is indicated by the setting of a corresponding bit in a bitmap. The bitmaps occur near the start of the message, and can either be in 'packed' format where each bitmap is encoded as 8 bytes of binary data (8 bits per byte), or in 'unpacked' format where each bitmap is encoded as 16 text characters (4 bits per character).
The IBM Integration Bus v9 sample for ISO8583 contains message flows that parse and create ISO8583 messages with 'packed' bitmaps. The 'create' flow contains ESQL code that automatically creates the bitmap elements and sets them correctly according to the existence of the data elements in the IIB message tree. The code to do that is straightforward as each bit is its own element and just needs setting to 0 or 1 depending on the existence of its corresponding data element.
The IIB v9 sample for ISO8583 can be used as the basis for message flows that parse and create ISO8583 messages with 'unpacked' bitmaps. The DFDL schemas for 'unpacked' ISO8583 are available on the DFDLSchemas GitHub site. The 'parse' message flow just needs to be updated to use the 'unpacked' schemas instead of the 'packed' schemas. The 'create' flow needs the same update, but it also needs new ESQL code to create the bitmap elements - and that's the tricky bit.
In an 'unpacked' bitmap, each group of 4 bits is treated as a hex integer which is then converted to a character. Each bit in a group of 4 is assigned a numeric value, 8, 4, 2, 1 from left to right. For example, bit 001 has value 8, bit 002 has value 4, bit 003 has value 2 and bit 004 has value 1. If data elements 002 and 004 exist in the tree but data elements 001 and 003 do not, then the numeric value of the first group of 4 bits is 5 (0 + 4 + 0 + 1 = 5). The number is then converted to hex and then to a character, giving '5'. Similarly, if data elements 005 and 006 exist in the tree but data elements 007 and 008 do not, then the numeric value of the second group of 4 bits is 12 (8 + 4 + 0 + 0 = 12). The number is then converted to hex and then to a character, giving 'C'.
The ESQL in the Gist creates the 'unpacked' bitmap, and may be used to replace the ESQL in the IIB sample's 'create' flow. In a typical ISO8583 message only a small number of the 128 fields are used, so for efficiency the ESQL code walks the data elements in the tree, updating the bitmap as it goes, rather then walking the bitmap elements then looking for each data element. The file extension must be renamed to .esql after download.
Please observe the accompanying license file.