Customize EDI X12 schema for B2B Integrations
Customize EDI X12 schema for B2B Integrations
home
This example illustrates how to customize the standard X12 EDI schema to handle EDI data specifications of B2B trading partners for both inbound and outbound EDI message exchange.
Use cases
Your organization or your trading partner wants to follow custom EDI message specifications such as:
- Making one or more optional segments or data elements (as defined in the base X12 specs) to Mandatory, or vice versa
- Modifying the minimum and / or maximum allowed lengths for one or more data elements
Example
The example contains 3 flows:
- Base schema flow: b2b-x12-base-schema-Flow
- Uses X12 connector configuration X12_Config_850_Base,
- Leverages the base X12 specification for X12 version 4010, 850 (Purchase Order Transaction type) from the EDI schema language file: _/x12/004010/850.esl _as the Schema deffinition.
- Custom Schema flow 1: b2b-x12-custom-schema-1-Flow (Recommended approach for customizing EDI schemas)
- Uses X12 connector configuration X12_Config_850_V1
- Schema definition uses a customized ESL, named 850-custom-v1.esl
- This uses overlayed schema cutomization with the below overrides to the base X12 schema.
- This was created by cloning /x12/004010/850.esl, and making the below customizations:
- Maximum length of BEG-03 (element id: 324) is changed from 22 (base standard) to 30
- The usage of BEG-04 element (Release Number), element-328 is made Mandatory (it is optional with the base standard)
- Segment/element overrides to be applied in the schema is made directly in the transaction set specific ESL for 850 (850-custom-v1.esl, in this example). Only the overriddent segment/element definitions need to be included. With the import of basedefs.esl at the top, definitions for other unmodified segments and elements still point to the standard X12 specs.
- This custom ESL file can be used to define custom X12 message types in Anypoint Partner Manager.
- Custom Schema flow 2: b2b-x12-custom-schema-1-Flow
- Uses X12 connector configuration X12_Config_850_V2
- Schema definition uses a customized ESL, named 850-custom-v2.esl, which in turn import a cloned version of the base definitions basedefs-custom-v2.esl
- The customized base definition file has the below overrides, similar to the previous example:
- maxLength of BEG-03, Element ID 324 (Purchase Order Number is increased from 22 to 30.
- BEG-04 is changed from Optional to Mandatory.
- The customized base definition file has the below overrides, similar to the previous example:
Setup the Example
- Open the Example project in Anypoint Studio from Anypoint Exchange.
- Install the latest version of Anypoint X12 connector
- The application performs the below steps:
- Receives EDI X12 850 purchase order payload via a HTTP listener
- Parses the payload using the X12 connector's Read operation, leveraging either the base X12 schema ESL file for 4010/850, or one of the customized schema ESL files.
- If the application is able to successfully parse the payload, it gets converted into JSON format using an included Dataweave map.
- If the payload fails to parse, the application returns the Error Object from the X12 Read operation, indicating the reason for the failure.
Run the Example
- Run the application in Anypoint Studio
- Post the sample EDI payloads included in src/main/resources/test-data to the below URLs:
- http://localhost:8081/x12/base-schema
- EDI-850-sample-1-base.edi successfully parses
- EDI-850-sample-2-custom.edi fails because:
- Length of BEG-03 is 30, while maximum length must be only 22 according to the base X12 specs
- EDI-850-sample-3-custom.edi fails because:
- Length of BEG-03 is 30, while maximum length must be only 22 according to the base X12 specs
- http://localhost:8081/x12/custom-schema-v1
- EDI-850-sample-1-base.edi successfully parses
- EDI-850-sample-2-custom.edi successfully parses, even though BEG-03 is 30 characters - due to the customization to allow up to 30 characters for BEG-03.
- EDI-850-sample-3-custom.edi fails due to:
- BEG-04 (Release Number) is missing and is mandatory and is missing in the data.
- http://localhost:8081/x12/custom-schema-v2
- Produces the same results as custom-schema-v1
- http://localhost:8081/x12/base-schema