Last active
August 29, 2015 13:57
-
-
Save esaounkine/9461471 to your computer and use it in GitHub Desktop.
build MT103 using additional methods (more examples at http://wiki.datamation.gr/x/OIBH)
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
public SwiftMessage buildMT103() { | |
SwiftMessage message = new SwiftMessage(); | |
// Set Tags for block1 | |
message.setArgApplid("F"); | |
message.setArgServid("01"); | |
message.setArgLTaddrBlk1("COPZBEB0AXXX"); | |
// Set Tags for block2 | |
message.setArgInoutind("O"); | |
message.setArgMsgtype("103"); | |
message.setArgLTaddrBlk2("LRLRXXXX4A11"); | |
message.setArgMsgprior("N"); | |
message.getBlock3().addAll(createTagList("108:MT103 005 OF 020")); | |
message.getBlock4().addAll(createTagList(":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")); | |
message.getBlock5().addAll(createTagList("MAC:00000000", "CHK:4BCF59104AF9")); | |
return message; | |
} | |
public static RepSeq createRepSeq(String repSeqString) { | |
return new RepSeq(createTagList(repSeqString.split("\n:"))); | |
} | |
public static Vector<Tag> createTagList(String block4Text) { | |
return createTagList(block4Text.split("\n:")); | |
} | |
public static Vector<Tag> createTagList(String... tagValues) { | |
Vector<Tag> tagList = new Vector<Tag>(); | |
for(String tag : tagValues) { | |
tagList.add(createTag(tag)); | |
} | |
return tagList; | |
} | |
public static Tag createTag(String tag) { | |
String tagKey = tag.replaceAll("(?s):?(.*):.*", "$1"); | |
String tagValueString = tag.replaceAll("(?s):?.*:(.*)", "$1"); | |
String[] lines = tagValueString.split("\n"); | |
Vector tagValue = new Vector(); | |
Collections.addAll(tagValue, lines); | |
return new Tag(tagKey, tagValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment