In this tutorial we’ll discuss how to combine separate EDI files using the EDIFileJoiner component and C#.Net.  We can combine files at the Functional Group (GS) or the Transaction Header level (ST).  The basic flow is demonstrated in the diagram below.

EDIFileJoiner

In this example we’re going to combine two files at the Transaction Header level.  This means that after combining the files there will only be one Interchange (ISA-IEA) containing one Functional Group (GS-GE) which will contain all the Transactions (ST-SE) from each file.

We will be combining two 4010 834 EDI files.  Each of these files contain only one transaction (ST-SE).

File 1 (834_1.edi)

ISA*00* *01*SUBPASSWOR*ZZ*APPSENDERID *ZZ*APPRECID *061218*1234*U*00401*000000000*0*T*:~
GS*BE*123*456*20061218*1234*1*X*004010X095A1~
ST*834*12345~
BGN*01*12456*19980520*1200****2~
N1*P5**FI*999888777~
N1*IN**FI*654456654~
INS*Y*18*021*20*A***FT~
REF*0F*123456789~
REF*1L*123456001~
DTP*356*D8*19960523~
NM1*IL*1*DOE*JOHN*P***34*123456789~
PER*IP**HP*7172343334*WP*7172341240~
N3*100 MARKET ST*APT 3G~
N4*CAMP HILL*PA*17011**CY*CUMBERLAND~
DMG*D8*19400816*M~
HD*021**HLT~
DTP*348*D8*19960601~
COB*P*890111*5~
N1*IN*ABC INSURANCE CO~
HD*021**DEN~
DTP*348*D8*19960601~
HD*021**VIS~
DTP*348*D8*19960601~
SE*22*12345~
GE*1*1~
IEA*2*000000000~

File 2 (834_2.edi)

ISA*00* *01*SUBPASSWOR*ZZ*APPSENDERID *ZZ*APPRECID *061218*1234*U*00401*000000001*0*T*:~
GS*BE*123*456*20061218*1234*1*X*004010X095A2~
ST*834*12346~
BGN*02*12456*19980520*1200****2~
N1*P5**FI*999888777~
N1*IN**FI*654456654~
INS*Y*18*021*20*A***FT~
REF*0F*202443307~
REF*1L*123456001~
DTP*356*D8*19960112~
NM1*IL*1*SMITH*WILLIAM****34*202443307~
PER*IP**HP*7172343334*WP*7172341240~
N3*1715 SOUTHWIND AVENUE~
N4*ANYTOWN*PA*171110000~
DMG*D8*19700614~
HD*021**HMO~
DTP*348*D8*19960601~
LX*01~
NM1*P3*1*BROWN*BERNARD**DR****25~
SE*18*12346~
GE*1*2~
IEA*1*000000001~

The Code

// Create a new instance of the EDI File Joiner
EDIFileJoiner joiner = new EDIFileJoiner();
 
// Join the files at the ST header level
joiner.FileJoinLevel = FileJoinLevel.HEADER;
 
// Specify the list of files to join
List files = new List();
files.Add(“834_1.edi”);
files.Add(“834_2.edi”);

// Join the EDI files
joiner.Join(files, “CombinedAll.edi”);

After calling the Join method the two files are combined at the Transaction Header (ST) level and the resulting EDI file will be saved in the current directory.

CombinedAll.edi

ISA*00* *01*SUBPASSWOR*ZZ*APPSENDERID *ZZ*APPRECID *061218*1234*U*00401*000000000*0*T*:~
GS*BE*123*456*20061218*1234*1*X*004010X095A1~
ST*834*12345~
BGN*01*12456*19980520*1200****2~
N1*P5**FI*999888777~
N1*IN**FI*654456654~
INS*Y*18*021*20*A***FT~
REF*0F*123456789~
REF*1L*123456001~
DTP*356*D8*19960523~
NM1*IL*1*DOE*JOHN*P***34*123456789~
PER*IP**HP*7172343334*WP*7172341240~
N3*100 MARKET ST*APT 3G~
N4*CAMP HILL*PA*17011**CY*CUMBERLAND~
DMG*D8*19400816*M~
HD*021**HLT~
DTP*348*D8*19960601~
COB*P*890111*5~
N1*IN*ABC INSURANCE CO~
HD*021**DEN~
DTP*348*D8*19960601~
HD*021**VIS~
DTP*348*D8*19960601~
SE*22*12345~
ST*834*12346~

BGN*02*12456*19980520*1200****2~
N1*P5**FI*999888777~
N1*IN**FI*654456654~
INS*Y*18*021*20*A***FT~
REF*0F*202443307~
REF*1L*123456001~
DTP*356*D8*19960112~
NM1*IL*1*SMITH*WILLIAM****34*202443307~
PER*IP**HP*7172343334*WP*7172341240~
N3*1715 SOUTHWIND AVENUE~
N4*ANYTOWN*PA*171110000~
DMG*D8*19700614~
HD*021**HMO~
DTP*348*D8*19960601~
LX*01~
NM1*P3*1*BROWN*BERNARD**DR****25~
SE*18*12346~
GE*2*1~
IEA*1*000000000~

Notice in the combined file that the GE segment first element (GE01) correctly says that there are 2 transactions.  Files can also be combined asynchronously.

Now that was easy!

 

Take Charge Of EDI

RDPCrystal EDI Library

trial2