Field 48 in TLV format with Tags and Lengths in BCD

1,142 views
Skip to first unread message

Stefano Bonù

unread,
Aug 18, 2015, 5:26:03 AM8/18/15
to jPOS Users
Hi,

we need to manage field 48 as follow:


<LLL><TAG><LENGTH><VALUE><TAG><LENGTH><VALUE>
………
LLL: This describes the aggregate length of the data in data element 48.
Format: 2 bytes BCD (first nibble will be zero filled).

TAG: This sub-field contains a numeric value describing the data that is to
follow in the length and value fields. The tag values and the actual data they
represent are outlined in the table below.
Format: 2 bytes BCD (first nibble will be zero filled).

LENGTH: This sub-field contains a numeric value that may vary from 0 to 99
describing the length of the data that is to follow in the value sub-field.
Format: 1 byte BCD. (Tag 18 uses 2 bytes BCD).

VALUE: This sub-field contains the data associated with a particular tag. The
length of this data should be the same as that indicated in the length sub-field.
Format: see table below for individual tag formats.

this is a classical TLV format, but TAGs and LENGTHs are in BCD. We tried to manage with TLVList but we didn't have it as expected, neither using the GenericTagSequence and BinaryTagValue (in this case we have length in BCD, but tag doesn't).

Is there a way to do it ?

Thanks
Stefano Bonù

Barzilai Spinak

unread,
Aug 18, 2015, 11:32:11 AM8/18/15
to jpos-...@googlegroups.com
On 8/18/15 11:26, Stefano Bonù wrote:
> Hi,
>
> we need to manage field 48 as follow:
>
>
> <LLL><TAG><LENGTH><VALUE><TAG><LENGTH><VALUE>
> ………
> LLL: This describes the aggregate length of the data in data element 48.
> Format: 2 bytes BCD (first nibble will be zero filled).
[...]
> this is a classical TLV format, but TAGs and LENGTHs are in BCD. We tried to manage with TLVList but we didn't have it as expected, neither using
> the GenericTagSequence and BinaryTagValue (in this case we have length in BCD, but tag doesn't).
>
> Is there a way to do it ?

If none of those work, can you use a custom ISOFieldPackager based on the code in the org.jpos.tlv.* packages?
Or maybe use a channel filter that will transform field 48 into a more manageable format (such a jPOS-CMF) when coming in/going out the wire?

--
Barzilai Spinak
Transactility, Inc.
www.transactility.com
"Commercial licensing and support for the jPOS.org project"


Stefano Bonù

unread,
Aug 18, 2015, 11:46:09 AM8/18/15
to jPOS Users
Hi,

UPDATE: 

we implemented a new class in this way:

import org.jpos.iso.BcdPrefixer;
import org.jpos.iso.ISOTagBinaryFieldPackager;
import org.jpos.iso.LiteralBinaryInterpreter;
import org.jpos.iso.NullPadder;

public class IFB_TTLLBINARY2 extends ISOTagBinaryFieldPackager {

public IFB_TTLLBINARY2() {
        super(0,null, BcdPrefixer.LLL, NullPadder.INSTANCE,
                LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
    }

    public IFB_TTLLBINARY2 (int len, String description) {
         super(len, description, BcdPrefixer.LLL, NullPadder.INSTANCE,
                 LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
    }
}

and use it in the xml structure as follows:

<isofieldpackager id="48"
  name="additional data - private"
  length="999"
  class="org.jpos.iso.IFB_LLLBINARY"
  emitBitmap="false" 
  tagMapper="org.jpos.iso.packager.TTTDecimalTagMapper"
  packager="org.jpos.iso.packager.GenericTaggedFieldsPackager">
   <isofield id="0" length="0" name="" class="org.jpos.iso.IF_CHAR"/>

   <isofield id="1" 
   length="2" 
   name="Item Number" 
   class="IFB_TTLLBINARY2"/>
   
   <isofield id="2" 
   length="3" 
   name="Elavon STAN" 
   class="IFB_TTLLBINARY2"/>
   
   <isofield id="3" 
   length="6" 
   name="Elavon date and time" 
   class="IFB_TTLLBINARY2"/>
   
   <isofield id="4" 
   length="6" 
   name="Elavon Retrieval ref number" 
   class="IFB_TTLLBINARY2"/>
  </isofieldpackager>   

it seems that pack works correctly, TAGs and LENGTHs are in bcd when we load every 48 subfield defined in the package.
In a particular case we receive the 48 field without the first subfield filled and the unpack throws the following exception:

"Field length 3 too long. Max: 2"

Debugging the code we found that the exception is raised by the class ISOTagBinaryFieldPackager in the unpack method. The 48 field test value is 0024 0002 03 123456  0003 06 123456123456 0004 06 123456123456 (bcd tags and lengths).

            int tagLen = tagPrefixer.getPackedLength();
            c.setFieldNumber(tagPrefixer.decodeLength(b, offset));
            int len = prefixer.decodeLength(b, offset + tagLen);
            if (len == -1) {
                // The prefixer doesn't know how long the field is, so use
                // maxLength instead
                len = getLength();
            }
            else if (getLength() > 0 && len > getLength())
                throw new ISOException("Field length " + len + " too long. Max: " + getLength());

the getLength() is referred to the first packager field (length = 2), but the actual found is the second (length = 3), so that len > getLength(). 

Does it mean that it's not possible to skip some subfield in a GenericTaggedFieldsPackager ? Or are we in the wrong way ?

many thanks

Diego Marinelli

unread,
Jan 15, 2016, 10:05:37 AM1/15/16
to jPOS Users

Hi Stefano, did  you manage to get it working? did you had to create packager for field 60 too?
Thanks,
Reply all
Reply to author
Forward
0 new messages