Search code examples
javakotliniso8583j8583

J8583 - Set Header in BCD


How to make header in BCD rather than HEX?

val isoRequest: IsoMessage = msgFactory.newMessage(0x800)
isoRequest.isoHeader = "6003000000"

log(isoRequest.writeData().bytesToHex())

Currently the above code will generate

363030333030303030300800

What we need is something like this

60030000000800

Solution

  • You probably need isoRequest.setBinaryIsoHeader

    e.g. (code in java):

    isoRequest.setBinaryIsoHeader(new byte[] {0x60, 0x03, 0x00, 0x00, 0x00});
    

    The string version sets the ASCII representation of the string characters.

    You can also get the byte array from a hex string in kotlin using this answer: https://stackoverflow.com/a/76830156/3444205