Contact Free trial Login

Create a Map For XML or JSON to Outbound EDI X12

Create a template project in Anypoint Studio to import a template that creates a DataWeave map to transform application formats such as XML and JSON to outbound EDI X12 transactions, then test the map locally.

Create a New Project From a Template

Create a template project in Anypoint Studio and import a DataWeave map template that maps application messages to outbound EDI X12 transactions:

  1. Launch Anypoint Studio.

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

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

  4. Search for X12.

  5. Click Template to map application messages to outbound EDI X12 transactions.

  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 EDI X12 transactions to the application format from Exchange.

Set the Source Message Type

To set the source JSON or XML message type for the map:

  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 Transform Message and drag it on to the Studio canvas.

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

    Transform Message component add payload metadata
  4. Click Add.

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

  6. Click Create type.

  7. In the Select metadata type dialog window, from the Type drop-down menu, select JSON or XML.

  8. Browse to the location of the JSON or XML schema file you imported in Step 1 and click Select.

Set the Target X12 Message Type

The template has the X12 configuration for the below X12 transaction set:

  • Version
    4010

  • Transaction Set
    850 (Purchase order)

Follow these steps to set the target X12 message type:

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

  2. From Global Configuration Elements, select X12 EDO Config and click Edit.

  3. In Name, change the name of the configuration.

  4. In the Schema definitions, select Edit inline.

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

    X12 EDI Config dialog
  6. Change the schema value to the version and transaction set you want to map from, for example, set the value to /x12/004010/204.esl, if you want to map to a 4010-204 Load tender transaction.
    You now see your application message structure (JSON or XML) on the input pane in the left, and the X12 transaction set structure on the output pane in the right.

  7. Click Finish, then click OK.
    You can now begin mapping from the input to the output.

Test the Map Locally

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

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

  2. Use a REST client to post a JSON or an XML payload to the URL http://localhost:8081/x12/out.
    The application returns the translated EDI X12 transaction.

  3. Copy the DataWeave map from src/main/resources/x12/OUT-application-message-to-X12-version-transaction-partner.dwl and rename it to something meaningful, for example, OUT-SAP-purchaseorder-XML-to-X12-4010-850-MythicalSupplier.dwl.

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

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub