Search code examples
parsingswift-mt

Handle 121 and 111 swift tag using Prowide Software API(WIFE)


We are using Prowide Software (WIFE) API for parsing swift message. While processing swift messages we are getting tag 111 and 121 in MT103 swift message.due to which parser code is failing. Could anyone please help me to know how to handle this using WIFE API?


Solution

  • I'm one the library authors. Field 111 and 121 are part of the optional user header (block 3) so in order to get those fields values you have to do something like:

    String msg ="{1:F01CCRTIT2TA15A0000000000}{2:I103CCRTIT2TXXXXN}{3:{103:TGT}{113:NNBI}{108:FOO123}{111:001}{121:8579f4a4-a547-463e-ae63-e7c6620d59b4}}{4:\n" +
       ":20:0013355630808057\n" +
       etc
       ":71A:SHA\n" +
       "-}";
    MT103 mt = MT103.parse(msg);
    String UETR = mt.getSwiftMessage().getBlock3().getTagValue("121");
    

    For future reference, as of SRU 2018 support for the SWIFT gpi (SWIFT Global Payment Innovation) fields has become mandatory. So the upcoming version of Prowide Core (since October 2018) includes many new API to deal with those fields.

    Setters and getters have been added to the SwiftMessage object, including an empty setter setUETR() that will automatically generate a valid unique identifier.

    SwiftMessage m = new SwiftMessage();
    String uetr = m.setUETR();
    // the uetr will contain the generated identifier such as //"eb6305c9-1f7f-49de-aed0-16487c27b42d"
    

    Moreover, if the message is created with the MT103, MT103_STP, MT103_REMIT, MT202, MT205, MT202COV or MT205COV classes, where the UETR is mandatory, the block3 will be already initialized with a proper field 121 (UETR).

    MT103 mt = new MT103(sender, receiver);
    mt.append(new Field20("MYREF"));
    String uetr = mt.getSwiftMessage().getUETR()
    

    Finally, when processing incoming payments, the gpi fields can be directly retrieved with the getters:

    MT103 mt = MT103.parse(fin);
    if (mt.getSwiftMessage().isGpi()) {
        System.out.println(mt.getSwiftMessage().getServiceIdentifier());
        System.out.println(mt.getSwiftMessage().getUETR());
    }