Skip to content

Using custom maps

olmelabs edited this page Dec 4, 2017 · 2 revisions

Sometimes to implement particular trading partner requirements you need to create custom map. Such maps are usually smaller as they contain only loops, segment and data elements used by your trading partner. In this case you can craft your own map. You can either define everything yourself or inherit from standard map, say using all data-elements and redefining only map loops and segments. Or you can define own segments as well.

In this example we have custom map and some custom segments. For simplicity segments are inherited from standard. SO the steps are.

  1. Create new Console Application
  2. Install Package from Nuget: Install-Package xEdi.EdiEngine
  3. Add Segments folder to project
  4. Add file "Segments.cs" custom segments (here we inherit from repository for simplicity)
namespaceConsoleApplication3.Segments{publicclassISA:EdiEngine.Standards.X12_004010.Segments.ISA{}publicclassIEA:EdiEngine.Standards.X12_004010.Segments.IEA{}publicclassGS:EdiEngine.Standards.X12_004010.Segments.GS{}publicclassGE:EdiEngine.Standards.X12_004010.Segments.GE{}publicclassST:EdiEngine.Standards.X12_004010.Segments.ST{}publicclassSE:EdiEngine.Standards.X12_004010.Segments.SE{}publicclassW05:EdiEngine.Standards.X12_004010.Segments.W05{}}
  1. Add Maps folder to projects
  2. Add custom map - file "M_940.cs"
usingConsoleApplication3.Segments;usingEdiEngine.Common.Definitions;usingEdiEngine.Common.Enums;namespaceConsoleApplication3.Maps{publicclassM_940:MapLoop{publicM_940():base(null){Content.AddRange(newMapBaseEntity[]{newW05(){ReqDes=RequirementDesignator.Mandatory,MaxOccurs=1},});}}}
  1. Add the following code to "Program.cs"
usingSystem;usingEdiEngine;usingEdiEngine.Runtime;namespaceConsoleApplication3{classProgram{staticvoidMain(string[]args){stringedi=@"ISA*00* *00* *ZZ*VENDOR *ZZ*WAREHOUSE *090902*0900*U*00401*000009221*0*P*>GS*OW*VENDOR*WAREHOUSE*20090902*1700*9221*X*004010ST*940*20066W05*N*35131*POMAILSE*3*20066GE*1*9221IEA*1*000009221";//Your custom map assembly name in ctorEdiDataReaderr=newEdiDataReader("ConsoleApplication3");EdiBatchb=r.FromString(edi);EdiTranst=b.Interchanges[0].Groups[0].Transactions[0];Console.WriteLine(newJsonDataWriter().WriteToString(b));Console.Read();}}}

This will output Json to console

Clone this wiki locally