Module edifact.d03a.services
ballerinax/edifact.d03a.services Ballerina library
Overview
UN/EDIFACT is the United Nations standard for electronic data interchange, used to exchange business documents such as orders, invoices and despatch advices between trading partners.
This package provides Ballerina record types and parser functions for the 29 UN/EDIFACT D03A messages grouped under services: insurance premiums, claims assessment and inspections, job orders and applications, payroll deductions, medical prescriptions, reports and resource usage, life reinsurance, berth management and stowage instructions, sales reports and forecasts, and social administration and work grants.
Key Features
- Typed records for all 29 messages in the services group, each in its own submodule, so a program only pulls in the records for the messages it handles.
- Envelope-aware parsing and serialization: an interchange is read from
UNBthroughUNZ, including theUNH/UNTmessage header and trailer. - Round-trips in both directions — EDI text to records, and records back to
conformant EDI text with the
UNTsegment count recomputed. - Generated from the UN/EDIFACT D03A directory with the Ballerina EDI tool, so the records follow the published specification.
Quickstart
To use the edifact.d03a.services package in your Ballerina application, modify the .bal file as follows:
Step 1: Import the module
Import the package and the submodules for the messages you handle.
import ballerina/io; import ballerinax/edifact.d03a.services; import ballerinax/edifact.d03a.services.mBERMAN;
Step 2: Read an EDI message
Convert an EDIFACT interchange into a Ballerina record.
public function main() returns error? { string ediText = check io:fileReadString("berman.edi"); mBERMAN:EDI_BERMAN_BERMAN message = check services:fromEdiString(ediText, services:EDI_BERMAN).ensureType(); io:println(message); }
services:getEDINames() returns every message name this package
supports. interchangeFromEdiString gives access to the full UNB/UNZ
interchange, and headersFromEdiString reads just the headers.
Step 3: Write an EDI message
Convert a Ballerina record back into an EDIFACT interchange.
string ediText = check services:toEdiString(message, services:EDI_BERMAN);
Use interchangeToEdiString to write the full interchange rather than the
message body alone.
Step 4: Run the Ballerina application
bal run
Supported messages
| Message | Description | Module |
|---|---|---|
BERMAN | Berth management | edifact.d03a.services.mBERMAN |
BMISRM | Bulk marine inspection summary report | edifact.d03a.services.mBMISRM |
ICASRP | Insurance claim assessment and reporting | edifact.d03a.services.mICASRP |
INSDES | Instruction to despatch | edifact.d03a.services.mINSDES |
INSPRE | Insurance premium | edifact.d03a.services.mINSPRE |
INSREQ | Inspection request | edifact.d03a.services.mINSREQ |
INSRPT | Inspection report | edifact.d03a.services.mINSRPT |
JOBAPP | Job application proposal | edifact.d03a.services.mJOBAPP |
JOBCON | Job order confirmation | edifact.d03a.services.mJOBCON |
JOBMOD | Job order modification | edifact.d03a.services.mJOBMOD |
JOBOFF | Job order | edifact.d03a.services.mJOBOFF |
JUPREQ | Justified payment request | edifact.d03a.services.mJUPREQ |
LREACT | Life reinsurance activity | edifact.d03a.services.mLREACT |
LRECLM | Life reinsurance claims | edifact.d03a.services.mLRECLM |
MEDPID | Person identification | edifact.d03a.services.mMEDPID |
MEDPRE | Medical prescription | edifact.d03a.services.mMEDPRE |
MEDREQ | Medical service request | edifact.d03a.services.mMEDREQ |
MEDRPT | Medical service report | edifact.d03a.services.mMEDRPT |
MEDRUC | Medical resource usage and cost | edifact.d03a.services.mMEDRUC |
MEQPOS | Means of transport and equipment position | edifact.d03a.services.mMEQPOS |
MOVINS | Stowage instruction | edifact.d03a.services.mMOVINS |
PAYDUC | Payroll deductions advice | edifact.d03a.services.mPAYDUC |
RECLAM | Reinsurance claims | edifact.d03a.services.mRECLAM |
REGENT | Registration of enterprise | edifact.d03a.services.mREGENT |
SLSFCT | Sales forecast | edifact.d03a.services.mSLSFCT |
SLSRPT | Sales data report | edifact.d03a.services.mSLSRPT |
SOCADE | Social administration | edifact.d03a.services.mSOCADE |
WKGRDC | Work grant decision | edifact.d03a.services.mWKGRDC |
WKGRRE | Work grant request | edifact.d03a.services.mWKGRRE |