-
-
Save pc14-alexandrakis/4ec4ac8fbb8cffcbe9a7ea5605a4747d to your computer and use it in GitHub Desktop.
Create a Rejection MT199 from an MT103 according to the Universal Confirmations Rule Book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.paymentcomponents.swift.mt.paid; | |
import com.paymentcomponents.swift.mt.Utils; | |
import gr.datamation.swift.common.SwiftMessage; | |
import gr.datamation.swift.common.Tag; | |
import gr.datamation.swift.processor.SwiftMsgProcessor; | |
import gr.datamation.swift.validator.SwiftMsgValidator; | |
import gr.datamation.swift.validator.SwiftValidObj; | |
public class UniversalConfirmations { | |
private static final String mt103String = | |
"{1:F01ABCDGRA0AXXX0057000289}{2:I103DDDDGRA0AXXXN}{3:{121:01911b73-1f15-4932-934a-609149301922}}{4:\n" + | |
":20:5387354\n" + | |
":23B:CRED\n" + | |
":23E:PHOB/20.527.19.60\n"+ | |
":32A:000526USD1101,50\n" + | |
":33B:USD1121,50\n" + | |
":50K:FRANZ HOLZAPFEL GMBH\n" + | |
"VIENNA\n" + | |
":52A:BKAUATWW\n" + | |
":59:723491524\n" + | |
"C. KLEIN\n" + | |
"BLOEMENGRACHT 15\n" + | |
"AMSTERDAM\n" + | |
":71A:SHA\n" + | |
":71F:USD10,\n" + | |
":71F:USD10,\n" + | |
":72:/INS/CHASUS33\n" + | |
"-}{5:{MAC:75D138E4}{CHK:DE1B0D7}}TRAILER BLOCK"; | |
public static void main(String[] args) { | |
//You can instatiate the SwiftMsgProcessor with the EOL of your choice. | |
//\n for linux based systems or \r\b for Windows | |
//If the default constructor is used then the \n will be used by default | |
SwiftMsgProcessor parser = new SwiftMsgProcessor("\n"); | |
try { | |
System.out.println("Parsing a valid MT103 message"); | |
SwiftMessage smObj = parser.ParseMsgStringToObject(mt103String); | |
System.out.println("Sender " + smObj.getArgLTaddrBlk1()); | |
System.out.println("Receiver " + smObj.getArgLTaddrBlk2()); | |
Tag tag20 = smObj.getTag("20"); | |
Tag tag50a = smObj.getTag("50F"); | |
//Get specific tag from the SwiftMessage object | |
System.out.println("Tag " + tag20.getName() + " " + | |
" " + tag20.getValueAsString()); | |
//Validate the message | |
SwiftValidObj swiftValidObj = new SwiftMsgValidator().validateMsg(smObj); | |
//Check if it has any errors | |
if (!swiftValidObj.hasErrors()) { | |
System.out.println("Message is valid, generasting a Rejected MT199 for according to the Unuversla Coonfirmations Rule Book"); | |
SwiftMessage mt199 = smObj.autoReply("an-id", "RJCT", "MS03", null, null, null); | |
System.out.println(new SwiftMsgProcessor("").BuildMsgStringFromObject(mt199)); | |
} else { | |
Utils.printErrors(swiftValidObj); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
System.err.println("Message cannot be parsed"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment