Template to map inbound EDI X12 transactions to application message format
home
This template helps in creating translation mapping to convert inbound EDI X12 messages received from B2B trading partners to application message formats such as JSON or XML.
Use Case
This Anypoint template serves as a foundation for creating maps for inbound B2B/EDI X12 messages to backend application formats, to be used in Anypoint Partner Manager or in a stand-alone Mule application.
Setup Mule project in Anypoint Studio
- Setup Mule project in Anypoint Studio
- Launch Anypoint Studio.
- From the File menu, select New > Project from Template.
- Log in to Anypoint Exchange with your Anypoint Platform credentials
- Search for X12.
- Click the template named
Template to map inbound EDI X12 transactions to application message format
.- Alternatively, download the template directly from Anypoint Exchange
- Click Open, to create a new project in your Studio workspace that is preloaded with the template.
Set the Source X12 Message Type
- The template is configured with X12 version 4010, Transaction set 850 purchase order
- Follow these steps to set the source X12 message type for the map:
- Click the Global Elements tab at the base of the Studio canvas in
global-configs.xml
. - From Global Configuration Elements, select X12 EDI Inbound and click Edit.
- In Schema definitions, select Edit inline.
- Select the value /x12/004010/850.esl and click the edit icon.
- Change the schema value to the version and transaction set you want to map from.
- For example, set Value to
/x12/004010/204.esl
, if you want to map from4010-204 Load tender
transaction.
- For example, set Value to
- Click the Global Elements tab at the base of the Studio canvas in
Set the Target JSON or XML Message Type
Set the target JSON or XML message type to transform inbound EDI X12 messages to your application message formats, such as XML or JSON:
- Copy the schema file of your target application message type into the
<Project-name>/src/main/resources
folder in the template project. - From the Mule Palette view, click the Transform Message component and drag it on to the Studio canvas.
- Select the Transform Message component and in the output section, next to Payload, click Define metadata.
- Click Add.
- In Type id, enter a new message type ID, for example
enterprise-inbound-purchase-order
. - Click Create type.
- From the Type drop-down menu in Select metadata type, select JSON or XML.
- Browse to the location of the JSON or XML schema file you imported in Step 1 and click Select
X12 to JSON/XML mapping
The new X12 transaction set structure displays in the input pane on the left, and your application message structure (JSON or XML) displays in the output pane on the right.
You can now begin mapping from the input to the output according to your mapping specifications.
Example map
Download a sample project from Exchange that has pre-built mapping to transform 4010 850 purchase order transactions into a JSON application message structure.
Testing the map locally
Follow these steps to test the translation map locally in Anypoint Studio:
- In Package Explorer, right-click on the template project, and select Run > Run as Mule application.
- Use a REST client to post an EDI message payload to the URL
http://localhost:8081/x12/in
.The application returns the translated JSON or XML. - If you are using the map in Anypoint Partner Manager:
- After you verify that the map works correctly, copy the DataWeave map from
src/main/resources/x12/IN-X12-version-transaction-to-applicationmessage.dwl
and rename it to something meaningful, such asIN-X12-4010-850-to-SAP-purchaseorder.dwl
. - Later, when you create and configure an inbound message flow in Partner Manager, you can import the
dwl
file to the Map section.
- After you verify that the map works correctly, copy the DataWeave map from