Altova MapForce 2023 Enterprise Edition

Example: Convert SWIFT MT to SWIFT MX

Home Prev Top Next

This example illustrates how to map a file which contains a SWIFT MT message to an XML target file in SWIFT MX format. It is accompanied by a mapping available at the following path: <Documents>\Altova\MapForce2023\MapForceExamples\SWIFT_MT950_camt053.mfd. Because this mapping has a large size, only a fragment of it is illustrated below.



A mapping such as the one illustrated above can be created by following the steps below.


Step 1: Add the source SWIFT MT file to the mapping

1.On the Insert menu, click EDI.

2.Select the collection "SWIFT", and the message type "MT950 - Statement Message".

3.When prompted to supply an instance file, open the source file available at the following path: <Documents>\Altova\MapForce2023\MapForceExamples\MT950.txt. The Component Settings dialog box appears. For the scope of this example, you can leave the settings unchanged, and click OK. You can change these settings at any time later, see EDI Component Settings.


The SWIFT MT component is now added to the mapping.


At this stage, if you haven't done that already, you might want to save the mapping to the disk. A good practice is to save the mapping design file in the same directory as its source and target files—this way, you can easily manage all the relative paths to the source or target files. In this example, you could save the mapping to <Documents>\Altova\MapForce2023\MapForceExamples\, since this is the directory where both the source file and the target schema are located.


Step 2: Add the target schema to the mapping

1.On the Insert menu, click the XML Schema/File, and open the camt.053.001.08.xsd file from the <Documents>\Altova\MapForce2023\MapForceExamples\ directory.

2.When prompted to supply a sample XML file, click Skip.


The target XML component is now added to the mapping as well:



Step 3: Add the intermediary components

The remaining mapping consists of drawing connections between the source and the target components. For example, item MT950 in the source maps to item Stmt in the target, while the item 20 (Transaction Reference Number) maps to MsgId, as illustrated below. If you are new to MapForce, you may need to refer to the Working with Connections and the Tutorials sections for more details about drawing connections.


When at least one connection exists from source to target, you can already preview the mapping output by clicking the Output tab. Bear in mind, however, that the resulting XML output will not be valid according to the schema until all mandatory connectors have inputs. The mandatory connectors are highlighted in orange (for example CreDtTm in the image above).


Besides straightforward connections from source to target, the complete example mapping (SWIFT_MT950_camt053.mfd) contains a few intermediary components, namely:


1.Value-map components (look-up tables). These are useful whenever you need to convert values between two sets (for example, "C" to "CRDT", "D" to "DBIT", and so on). For more information, see Using Value-Maps.

2.The functions now and contains. The now function returns the current date and time, while the contains function returns a Boolean true if the first string argument contains the second string argument. For more information, see Add a Function to the Mapping.

3.Various string constants (for example, "PRCD", "CLBD"), see also Add a Constant to the Mapping.


To give you just a few examples, the following table describes how some of the connectors from the target component receive input.


Target connector



Although this target item does not receive an input explicitly, its child element MsgId does (see below); therefore, the parent GrpHdr will be created as well when you run the mapping.


Receives a straightforward connection from the Transaction Reference Number in the source (item 20 under MT950).


Receives the direct output of the function now, which is a MapForce built-in function that returns the current date and time.


Receives a direct connection from MT950 source item.


Receives input from a text constant, "PRCD".


Running the mapping

To preview the generated file in MapForce, click the Output tab. The image below illustrates only a fragment of the resulting XML file.


Mapping output

To save the mapping output to a file, do one of the following:


On the Output menu, click Save Output File.

Click the Save generated output ic-save-sel-string toolbar button.


Automation with MapForce Server

If you have licensed MapForce Server, you can also run the mapping at the command line, on a Linux, macOS, or Windows machine. Note that running mappings on a server typically requires a few extra steps as outlined in Preparing Mappings for Server Execution. Here are the steps required to run this particular mapping on a server:


1.Right-click an empty area on the mapping and select Mapping Settings from the context menu.

2.Clear the Make paths absolute in generated code check box and save the mapping in the same directory.

3.On the File menu, click Compile to MapForce Server Execution File and save the .mfx file in the <Documents>\Altova\MapForce2023\MapForceExamples\ directory.

4.Copy the generated .mfx file to a directory on the server machine (let's call it the "working directory").

5.Copy the file <Documents>\Altova\MapForce2023\MapForceExamples\MT950.txt to the working directory on the server machine.

6.Open a terminal and change the current directory to the working directory.

7.Run MapForce Server with the command below. Adjust mapforceserver_exec to be the path to the MapForce Server executable as applicable for your operating system.


mapforceserver_exec run SWIFT_MT950_camt053.mfx


In server execution, you can also run mappings as an API call, or as FlowForce Server jobs, either on demand or on recurring basis. For more information, see Compiling Mappings to MapForce Server Execution Files.

© 2016-2022 Altova GmbH