I have a several fields that change their definitions based on what usage of that field is being used.
For example, F48 is defined as:
Variable Length, 1-byte binary + 255 bytes, variable by usage, max 256 bytes
It's simple enough handling one usage at a time, for example usage A is defined in spec and my packager:
Variable length, 1-byte binary + 255 bytes, EBCDIC, max 256 bytes
<isofield
id="48"
length="255"
name="ADITIONAL DATA - PRIVATE"
class="org.jpos.iso.IFB_LLHECHAR"/>
But another usage may be defined as
variable length, 1-byte binary + 4 N, 4-bit BCD
Or
variable length, 1-byte binary + 143 AN, EBCDIC
And so on. I'm not quite sure how to handle multiple usages of the same field in my generic packager.
I've thought about using isofieldpackager to treat it like subfields, and then depending on the usage I need I just use that subfield.
For example, with usage A, I tried
<isofieldpackager
id="48"
length="255"
name="F48 ADDITIONAL DATA - PRIVATE"
emitBitmap="false"
firstField="0"
class="org.jpos.iso.IFB_LLHBINARY"
packager="org.jpos.iso.packager.GenericSubFieldPackager">
<isofield
id="0"
length="255"
name="ADITIONAL DATA - PRIVATE"
class="org.jpos.iso.IFB_LLHECHAR"/>
</isofieldpackager>
and then setting the field as isoMSG.set("48.0", "This is my data"), which seems to work for the most part, but there is some unreadable data being prefixed to that field when it reaches my acquiring process.
Thanks for any help, if you need more info let me know
At the channel level, if you have a way to figure out the usage, you can use the
dynamic packager
support. So basically, you create different packages, and the channel decides which one to use at runtime.But the easiest way is to handle it as an opaque binary field, and then handle the differences on your higher level code.