1

How can I set subfields to an IsoMessage object using the J8583 library? I use the j8583 library for sending ISO8583 messages which require only whole number data element indexes such as fields 7,11 and 12

public void createIsoMessage(){
        MessageFactory<IsoMessage> messageFactory = new MessageFactory<>();
        IsoMessage isoMessage = messageFactory.newMessage(0x800);
        isoMessage.setValue(7, "0601163045", IsoType.DATE10, 10);
        isoMessage.setValue(11, "163045", IsoType.DATE10, 6);
        isoMessage.setValue(12, "163045", IsoType.DATE10, 6);
    }

But I need to send data elements that have subfields such as fields: 127.2 127.3 127.12 127.25.3 127.25.4, however I can only set integer data element indexes using the setValue() function

I need to be able to set data elements, particularly data element 127, that have subfields to be able to send ICCDATA which is required by the payment processor.

efe
  • 41
  • 1
  • 4

1 Answers1

2

This is from the j8583 doc

You can also create a CompositeField, store several subfields inside it, and store it in any field inside an IsoMessage, specifying the same instance as the CustomField:

CompositeField f = new CompositeField().addValue(new IsoValue<String>(IsoType.ALPHA, "one", 5))
    .addValue(new IsoValue<String>(IsoType.LLVAR, "two"))
    .addValue(new IsoValue<Long>(IsoType.NUMERIC, 123l, 6))
    .addValue(new IsoValue<String>(IsoType.ALPHA, "OK", 2));
message.setValue(125, f, f, IsoType.LLLVAR, 0);
Andrés Alcarraz
  • 1,570
  • 1
  • 12
  • 21
  • When setting a composite field, does the library automatically add the bitmap for the composite field? For example, field 127 has a subfield 127.1 which holds the bitmap, so I'm wondering if i need to set the bitmap field in the xml template and also in code – efe Jun 02 '23 at 10:23
  • It seems it doesn't support bitmapped inner fields out of the box, so you would have to calculate that by yourself. I'm also seeing that this wouldn't work as it is, because it only let you add inner fields sequentially. Perhaps you could consider [jpos](https://www.jpos.org). Otherwise, you could implement a `BitmappedCompositeField`, perhaps you could use IsoMessage itself to implement that. – Andrés Alcarraz Jun 02 '23 at 15:43