javaiso8583jpos

jpos ISO8583 message parsing


I am trying to parse an ISO message using jpos library,

My message will be like this ( not copied full message) "012B11007E2466490C61A430163533313139383030343030303031363400100000000000010000000000010000000000010020221....."

The following is my code.

GenericPackager packager = new GenericPackager("src/main/resources/iso87ascii.xml");
        ISOMsg mes = new ISOMsg();
        mes.setPackager(packager);
        mes.unpack(inputMessage.getBytes(StandardCharsets.UTF_8));
        mes.dump(System.out, "");
    

The below is the part of my config file.

<isofield
        id="0"
        length="4"
        name="MESSAGE TYPE INDICATOR"
        class="org.jpos.iso.IFA_NUMERIC"/>
<isofield
        id="1"
        length="16"
        name="BIT MAP"
        class="org.jpos.iso.IFA_BITMAP"/>
<isofield
        id="2"
        length="19"
        name="PAN - PRIMARY ACCOUNT NUMBER"
        class="org.jpos.iso.IFA_LLNUM"/>
        

The expected parsing is something like below.

LNG - 012B

IDTM - 1100

BITMP - 7E2466490C61A430

F-2 16 35333131393830303430303030313634 (Length + data)

F-3 001000

But, the issue is , when I try to parse the message the Field-0 becomes "012B" and Field-2 is not parsed.

If I remove the "012B" from my input string, then

Field-0 becomes "1100" ( which is correct) Field-2 becomes "3533313139383030", but the expected value is "35333131393830303430303030313634"

My question is, on the parser, how can I configure the message length (012B)? why is Field 2 truncated to 16 characters?


Solution

  • The packager does not take care of the length, so you have to cut those bytes before passing the data to the packager.

    So the answer to the first question is you can't, you could but is not the responsibility of the packager to handle message length but of the channel.

    For the second question you already said that the length of field 2 is 16.