Module edifact.d03a.retail
ballerinax/edifact.d03a.retail Ballerina library
Overview
UN/EDIFACT D03A Retail group EDI parser: reads and writes the 23 messages covering product data, exchange reconciliation and inquiries, requests for quote and for document, pricing history, returns announcements and instructions, reservations, generic and statistical messages, and insurance policy administration and reinsurance messages.
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.
Key Features
- Typed records for all 23 messages in the retail 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.retail 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.retail; import ballerinax/edifact.d03a.retail.mGENRAL;
Step 2: Read an EDI message
Convert an EDIFACT interchange into a Ballerina record.
public function main() returns error? { string ediText = check io:fileReadString("genral.edi"); mGENRAL:EDI_GENRAL_GENRAL message = check retail:fromEdiString(ediText, retail:EDI_GENRAL).ensureType(); io:println(message); }
retail: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 retail:toEdiString(message, retail:EDI_GENRAL);
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 |
|---|---|---|
GENRAL | General purpose | edifact.d03a.retail.mGENRAL |
GESMES | Generic statistical | edifact.d03a.retail.mGESMES |
INFCON | Infrastructure condition | edifact.d03a.retail.mINFCON |
IPPOAD | Insurance policy administration | edifact.d03a.retail.mIPPOAD |
IPPOMO | Motor insurance policy | edifact.d03a.retail.mIPPOMO |
JAPRES | Job application result | edifact.d03a.retail.mJAPRES |
JINFDE | Job information demand | edifact.d03a.retail.mJINFDE |
PRIHIS | Pricing history | edifact.d03a.retail.mPRIHIS |
PROCST | Project cost reporting | edifact.d03a.retail.mPROCST |
PRODAT | Product data | edifact.d03a.retail.mPRODAT |
PRODEX | Product exchange reconciliation | edifact.d03a.retail.mPRODEX |
PROINQ | Product inquiry | edifact.d03a.retail.mPROINQ |
RDRMES | Raw data reporting | edifact.d03a.retail.mRDRMES |
REBORD | Reinsurance bordereau | edifact.d03a.retail.mREBORD |
RECORD | Reinsurance core data | edifact.d03a.retail.mRECORD |
REPREM | Reinsurance premium | edifact.d03a.retail.mREPREM |
REQDOC | Request for document | edifact.d03a.retail.mREQDOC |
REQOTE | Request for quote | edifact.d03a.retail.mREQOTE |
RESETT | Reinsurance settlement | edifact.d03a.retail.mRESETT |
RESMSG | Reservation | edifact.d03a.retail.mRESMSG |
RETACC | Reinsurance technical account | edifact.d03a.retail.mRETACC |
RETANN | Announcement for returns | edifact.d03a.retail.mRETANN |
RETINS | Instruction for returns | edifact.d03a.retail.mRETINS |