EDI (X12) in Mule 4

Pankaj Badi
6 min readOct 18, 2023

--

How we can write EDI message using “X12 Write” connector in mule 4.

  1. EDI: EDI (Electronic Data Interchange) segments are the individual units of data in an EDI message. They are used to represent specific pieces of information within an electronic document. EDI messages are composed of segments, and each segment has a unique identifier called a segment tag or code. Segments are further divided into elements, which contain the actual data values.
  2. Here is the basic structure of an EDI segment:

SegmentTag<Element1>Data1<Element2>Data2<…><ElementN>DataN

3. Segment Tag: It identifies the type of information the segment contains. For example, “N1” is often used for the name and address information of a party involved in the transaction.

4. Element: Each segment is divided into elements. Elements are the individual pieces of data within a segment. For example, within an “N1” segment, the first element might represent the party’s name, and the second element might represent the party’s identification number.

5. Data: This is the actual value of the element.

6. Segments are delimited by specific characters, such as the asterisk (*) or the tilde (~) depending on the EDI standard being used (like ANSI X12, EDIFACT, etc.). The structure of segments and the specific segment codes used can vary based on the industry and the type of transaction being conducted.

7. X12 EDI Connector in MuleSoft

The Connector is utilized to change over X12 messages to and from Data Weave-perfect portrayals utilizing records and maps. These are the accessible X12 variants 003010, 003020, 003030, 003040, 003050, 003060, 003070, 004010, 004020, 004030, 004040, 004050, 004060, 005010, 005020, 005030, 005040, 005050, and 006020 are bolstered with provided pattern definitions for all standard exchange sets.

8. Parts of an X12 :

ISA (Interchange Control Header): The ISA segment marks the beginning of the interchange of EDI data between parties. It contains information about the sender and receiver of the EDI data, as well as date, time, and control information.

GS (Functional Group Header): The GS segment is used to indicate the start of a functional group of related transactions. A functional group typically contains a collection of individual transactions that are related, such as a group of purchase orders or invoices.

ST (Transaction Set Header): The ST segment marks the beginning of a specific transaction set within a functional group. It identifies the type of document being transmitted, such as a purchase order or an invoice.

SE (Transaction Set Trailer): The SE segment marks the end of a specific transaction set. It contains a control number that indicates the number of segments in the transaction set.

GE (Functional Group Trailer): The GE segment marks the end of a functional group. It contains a control number indicating the number of transaction sets in the functional group.

IEA (Interchange Control Trailer): The IEA segment marks the end of the interchange of EDI data. It contains a control number indicating the number of functional groups in the interchange.

9. Transaction sets that are defined by the ANSI X12 EDI standard. Each transaction set has a unique purpose and format, allowing for the electronic exchange of specific types of business documents between trading partners. Here’s what each of these transaction sets represents:

835 Health Care Claim payment or advice.

837 : Health Care Claim.

834 : Benefits Enrollment and Maintenance.

820: Payroll Deducted Premium Payment for Insurances.

270: Health Care or Benefits Inquiry.

271: Health Care Eligibility or Benefits Response.

276: Health Care Claim Status Inquiry

277: Health Care Claim Status Response.

278: Health Care Service Review Information.

Use Case:

To implement EDI-834 : Benefits Enrollment and Maintenance using EDI(X12) Write Connector.

Solution:

10. How EDI(X12) Connectors works in MuleSoft: Let’s verify step by step.

a. Create new project in Anypoint Studio in Mule 4.

b. Configure the listener and set the path for your project as show in screenshot.

c. In the palette and search X12 EDI, Try looking for it in Exchange in the studio (give the Anypoint Platform credentials for login) and type X12 and search it.

d. In Package Explorer, All the dependencies and jars of X12 are added. I am using version “004050” and “834.esl” as per the use case.

e. In this we have two files one is basedefs.esl file and other is 834.esl file.

f. In the 834.esl file: We have heading, details and in some files we have summary also which is in “849.esl”. If not just ignore it I just has given this point to understand. In this Usage are “M” is Mandatory, “O” is Optional and count “>1” then take array and if count:2 then also take array. Check the position of that segment that is very important for example.

heading:

  • { idRef: ‘BGN’, position: ‘0200’, usage: M }, In the Transform Message we have to create like this “0200_BGN”.

g. In the basedefs file check the ‘BGN’ as we are refers to “834.esl” file.

In the above screenshot or basedefs.esl file.

{ idRef: ‘353’, usage: M }, { idRef: ‘127’, usage: M }, { idRef: ‘373’, usage: M }.

In this all three segments are Mandatory. Create the the structure in Transform Message as below.

“0200_BGN”: {

BGN01: “00” ,

BGN02: “9”,

BGN03: payload.Reciever_date as Date

},

h. In this Transform Message, Either you can used Delimiters: “*>U~” or in Write configuration we have following things.

In write connectors in that Batch tab by default it have.

In write connector, There is Identify tab.

i. Run your project.

j. Pass the body in the postman and hit the request.

{

“Billing_Country”: “USA”,

“Billing_Ci”: “TX”,

“Billing_State”: “UM”,

“AccountNumber”: “4”,

“Reciever_date”: “2023–10–18T18:25:43–05:00”,

“Billing_Count”: “fg”,

“Billing_City”: “ug”,

“Billing_Sta”: “mau”,

“Account_Number”: “21”,

“Name_person”: “sd”

}

k. Please find the code in the Git Repo.

l. EDI Errors and Solution: I have face below types of error and find the solution for it.

1. ”Errors in write operation: missing required value ‘1000_Loop’ at index 4"

Solution: The tag was under heading in the “834.esl” file. So, I have change it.

2. ”Errors in write operation: effective length 7 is greater than 3 for value N101 for segment N1 at segment position 4"

Solution: I have to change the length of the payload as its saying the size 3. Initially.
I taken value of Billing_Country is 7. After that payload.Billing_Country I have change to value which I have to set 3
.

3. “Errors in write operation: missing required value ‘0700_N1’ at index 4”

take the position of “834.esl” file.

Solution: Always check the position in “.esl” file it is very important.

Conclusion:

By following above steps you can create messages in EDI.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Pankaj Badi
Pankaj Badi

Written by Pankaj Badi

Hello Techies, I always want to learn new things and acquire skills as there is no end for learning and growing

No responses yet

Write a response