Creating a Translation Map For Inbound X12 to JSON or XML

Create a template project in Anypoint Studio to import a template to map inbound EDI X12 transactions to an application message format, such as JSON or XML, then test the map locally.

Create a New Project From a Template

Create a template project in Studio and import a DataWeave map template that maps inbound X12 transactions to an application format:

  1. Launch Studio.

  2. From the File menu, select New > Project from Template.

  3. Log in to Anypoint Exchange with your Anypoint Platform credentials

  4. Search for X12.

  5. Click the template named Template to map inbound X12 transactions to application message format.

  6. Click Open, to create a new project in your Studio workspace that is preloaded with the template.

You can also download the template to map inbound X12 transactions to the application format from Exchange.

Set the Source X12 Message Type

The template to map X12 transactions to an application message format contains the following X12 transaction set:

  • Version

  • Transaction Set
    850 (Purchase order)

Follow these steps to set the source X12 message type for the map:

  1. Click the Global Elements tab at the base of the Studio canvas in global-configs.xml.

  2. From Global Configuration Elements, select X12 EDI Inbound and click Edit.

  3. In Name, change the name of the configuration to something meaningful.

  4. In Schema definitions, select Edit inline.

  5. Select the value /x12/004010/850.esl and click the edit icon.

  6. 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 to a 4010-204 Load tender transaction.

Set the Target JSON or XML Message Type

Set the target JSON or XML message type to transform inbound X12 messages to your application message formats, such as XML or JSON:

  1. Copy the schema file of your target application message type into the <Project-name>/src/main/resources folder in the template project.

  2. From the Mule Palette view, click the Transform Message component and drag it on to the Studio canvas.

  3. Select the Transform Message component and in the output section, next to Payload, click Define metadata.

    Define Metadata link
  4. Click Add.

  5. In Type id, enter a new message type ID, for example enterprise-inbound-purchase-order.

  6. Click Create type.

  7. From the Type drop-down menu in Select metadata type, select JSON or XML.

  8. Browse to the location of the JSON or XML schema file you imported in Step 1 and click Select.
    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.

Test the Map Locally

Follow these steps to test the translation map locally in Anypoint Studio:

  1. In Package Explorer, right-click on the template project, and select Run > Run as Mule application.

  2. Use a REST client to post an EDI message payload to the URL http://localhost:8081/x12/in.
    The application returns the transformed JSON or XML.

  3. 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 as IN-X12-4010-850-to-SAP-purchaseorder.dwl.

Later, when you create and configure inbound message flows, you can import the dwl file to the Map section of inbound message flow.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub