Menu

Parsing MT98 with extra custom field. It works with 7.7, but with 7.8.5 doesn't work.

Help
2016-11-24
2016-11-26
  • Kantoro Erkulov

    Kantoro Erkulov - 2016-11-24

    Hello, guys.

    Can you help me on this.
    After updating to 7.8.5 version from 7.7 I'm having some problems with parsing MT198 file.

    I have method

    public FieldCUSTOM_TAG getFieldCUSTOM_TAG(SwiftMessage swiftMessage) {
        if (swiftMessage == null) {
            throw new IllegalStateException("SwiftMessage was not initialized");
        }
        if (swiftMessage.getBlock4() == null) {
            System.out.println("block4 is null");
            return null;
        } else {
            final Tag t = swiftMessage.getBlock4().getTagByName("CUSTOM_TAG");
            if (t == null) {
                System.out.println(("field CUSTOM_TAG not found"));
                return null;
            } else {
                return new FieldCUSTOM_TAG(t.getValue());
            }
        }
    }
    

    And a class FieldCUSTOM_TAG which extends Field class.

    This is the sample text, which I'm trying to parse with 7.8.5 version.

    {1:F01BIC0BANKAXXX0006222623}{2:I198BIC0BANKXXXXS}{4:
    :20:my_ref
    :12:1
    :77E:
    :21:my_ref
    :13D:1611240000+0100
    :32B:USD10,
    :CUSTOM_TAG:my_value
    -}

    Here goes the code and outputs in different versions.

    SwiftParser swiftParser = new SwiftParser(in);
    SwiftMessage swiftMessage = swiftParser.message();
    System.out.println(swiftMessage.getBlock4());

    7.8.5 version Output:

    com.prowidesoftware.swift.model.SwiftBlock4[[Tag[20:my_ref], Tag[12:1], Tag[77E:], Tag[21:my_ref], Tag[13D:161124], Tag[32B:USD10,
    :CUSTOM_TAG:my_value]
    ]]

    7.7 version Output:

    com.prowidesoftware.swift.model.SwiftBlock4[[Tag[20:my_ref], Tag[12:1], Tag[77E:], Tag[21:my_ref], Tag[13D:161124], Tag[32B:USD10,], Tag[CUSTOM_TAG:my_value]]]

    The problem is that in 7.7 version my custom method getFieldCUSTOM_TAG(SwiftMessage swiftMessage) returns FieldCUSTOM_TAG.

    But in 7.8.5 the field CUSTOM_TAG not found. When I try to get it with getFieldCUSTOM_TAG(SwiftMessage swiftMessage).

    What I'm doing wrong? Is there any new approach of parsing in 7.8.5?

    Thanks in advance.

     
  • Kantoro Erkulov

    Kantoro Erkulov - 2016-11-24

    Sorry, The topic was about Parsing MT198 not MT98.
    Don't know how to edit topic.

     
  • Sebastian Zubrinic

    Hi,

    This is due to a patch refered in the release CHANGELOG as:
    Fixed MT parser to allow additional lines in a field start with colon ':'

    It was necessary because it is not sufficient to check for a starting colon as new field indicator; for example for fields like 77E it is allowed the field content to have a ':<CR><LF>' as the second line.

    You should use proper field names in order to be detected as new fields by the parser. Not necessary a valid field for the MT, but at least something like 0-9[0-9][A-Z]

    Also notice that you could use a custom user block to append stuff to the message in a more standard way. Check the javadoc for SwiftBlockUser at: http://api.prowidesoftware.com/core/com/prowidesoftware/swift/model/SwiftBlockUser.html

    Finally, for more prompt and private assitance please check our support offering at:
    http://www.prowidesoftware.com/services.jsp

     

Log in to post a comment.