Ballerina is the only language with native support for B2B integrations. It enables a seamless exchange of business data with partner networks using standard formats like X12, EDIFACT, or even custom EDI formats.

Ballerina's powerful EDI data mapping and processing capabilities facilitate interoperability among data formats and simplify the use of EDI data within business apps.

Download Ballerina

Position Ballerina

EDI? Ballerina is EDI

EDI data can be loaded into Ballerina records using the built-in EDI handling capabilities. This allows developers to manipulate EDI data using the usual Ballerina syntax. Ballerina also supports the conversion of records back into EDI formats, making it possible to exchange processed data seamlessly with partner networks. With Ballerina, working with EDI data becomes as straightforward as working with any other Ballerina data type.

import simple_edi_schema.hmart;
import ballerina/io;

public function main() returns error? {
   string ediText = check io:fileReadString("resources/in-message.edi");
   hmart:HMartOrder hmartOrder = check hmart:fromEdiString(ediText);
   foreach hmart:Items_Type item in hmartOrder.items {
       io:println(string `Item: ${item.name}, Quantity: ${item.quantity}`);
   }
   hmartOrder.items[0].quantity = 5;
   string outputEdi = check hmart:toEdiString(hmartOrder);
   io:println(outputEdi);
}

Unlock EDI data for business apps

Developers can create Ballerina apps that perform actions on EDI data, such as calling external services with relevant EDI fields, making intelligent decisions, storing extracted data in databases, and performing data manipulations like filtering, replacing, and enrichment. These capabilities empower organizations to effectively utilize EDI data, enabling the implementation of data-driven processes and enhancing overall operational efficiency.

import edi_in_business_apps.hmart;
import ballerina/http;
import ballerina/io;

http:Client salesEp = check new (url = "http://kwLogistics");

public function main() returns error? {
   string ediText = check io:fileReadString("inFolder/message.edi");
   hmart:HMartOrder hmartOrder = check hmart:fromEdiString(ediText);
   int totalQuantity = 0;
   foreach hmart:Items_Type item in hmartOrder.items {
       totalQuantity += item.quantity;
   }
   if totalQuantity > 100 {
       json response = check salesEp->/largeOrders.post(
           {salesOrder: hmartOrder, totalQuantity});
       io:println(response);
   } else {
       json response = check salesEp->/orders.post(
           {salesOrder: hmartOrder});
       io:println(response);
   }  
}

Transform EDI data to any format

With its powerful and graphical data mapping capabilities, Ballerina enables the seamless transformation of EDI data into formats such as JSON, XML, CSV, and more. This allows organizations to effortlessly navigate complex EDI structures and accurately perform transformations, ensuring smooth integration with both internal and external applications.

Transform EDI data to any format

X12? Ballerina is X12

Ballerina's built-in support for X12 messages empowers organizations to seamlessly work with their partner networks using the widely adopted X12 standard. Developers can easily process, parse, and generate X12 messages, ensuring efficient data exchange between partner systems.

import ballerina/io;
import ballerinax/x12.supplychain.v004010.m850;

public function main() returns error? {
    string ediText = check io:fileReadString("resources/messages/850_sample1.edi");
    m850:EDI_850_Purchase_Order purchaseOrder = check m850:fromEdiString(ediText);
    m850:PO1_Loop_GType[] items = purchaseOrder.PO1_Loop;
    float orderValue = 0;
    foreach m850:PO1_Loop_GType item in items {
        float? itemValue = item.Baseline_Item_Data?.Unit_Price * 
                item.Baseline_Item_Data?.Quantity_Ordered;
        if itemValue is float {
            orderValue += itemValue;
        }
    }
    io:println(io:println("Total order value: " + orderValue.toString()));
}

EDIFACT? Ballerina is EDIFACT

With Ballerina's built-in support for EDIFACT, organizations can easily handle EDIFACT messages, process complex data structures, and exchange information with partner networks. By leveraging Ballerina's intuitive features, developers can streamline EDIFACT integration, ensuring smooth communication with trading partners.

import ballerina/io;
import ballerinax/edifact.finance.d96a.mINVOIC;

public function main() returns error? {
    string ediText = check io:fileReadString("resources/invoice_message_in.edi");
    mINVOIC:EDI_INVOIC_Invoice_message invoice = check mINVOIC:fromEdiString(ediText);
    string? paymentMethod = 
            invoice?.PAYMENT_INSTRUCTIONS?.PAYMENT_INSTRUCTION_DETAILS?.Payment_means;
    if paymentMethod != "42" {
        return;
    }
    foreach mINVOIC:Segment_group_15_GType allowance in invoice.Segment_group_15 {
        if allowance.ALLOWANCE_OR_CHARGE.Allowance_or_charge_qualifier != "A" ||
            allowance.ALLOWANCE_OR_CHARGE.Settlement != "6" {
                continue;
        }
        mINVOIC:Segment_group_19_GType[] amounts = allowance.Segment_group_19;
        foreach mINVOIC:Segment_group_19_GType amount in amounts {
            string? sAmount = amount.MONETARY_AMOUNT_2.MONETARY_AMOUNT_1.Monetary_amount;
            if sAmount is string {
                decimal dAmount = check decimal:fromString(sAmount);
                dAmount += dAmount * <decimal>.1;
                amount.MONETARY_AMOUNT_2.MONETARY_AMOUNT_1.Monetary_amount = dAmount.toString();
            }
        }
    }
    io:println(invoice.toJson());
}

Partners don't follow standards? No problem!

Ballerina accommodates partner-specific EDI variations. Developers can convert them to organizations' standard formats using Ballerina's robust tools, ensuring effective collaboration with partners, regardless of their specific variations.

Partners don't follow standards? No problem!

Go beyond standards and work with custom EDI formats

Ballerina empowers organizations to create tailored EDI schemas with custom message structures and constraints. Its robust tools generate code to seamlessly handle these custom EDI schemas, facilitating the representation and communication of data beyond standard EDIs formats.

Go beyond standards and work with custom EDI formats

Extra! Start integrating with the partner network instantly with Ballerina + Choreo

Unlock instant partner integration with Ballerina's EDI support and Choreo. Choreo provides a comprehensive app development environment with production-ready deployment, CI/CD pipelines, multi-environment support, and robust monitoring for Ballerina apps. Start your EDI-based partner integration journey and accelerate collaboration with the powerful capabilities of Ballerina and Choreo.

Extra! Start integrating with the partner network instantly with Ballerina + Choreo