Any assistance is very much appreciated

Feb 27, 2013 at 8:12 AM
Hi there,

Good day! I am amazed with the x12Parser project you built and shared with the community. I am currently thinking of utilizing it in part of my work, rest assured credibility will be given.

A brief specification on the work I am working on that I hope to share here. I am going to implement x12Parser into a document management system that I am working on. The requirement will be:
  1. There will be inbound EDI file from client.
  2. This EDI inbound will be translated to understandable data which is to be processed by the system im working on.
  3. There will be EDI outbound file. This EDI outbound file will be generated based on the data by the system im working on.
Questions:

I am thinking to integrate x12Parser into the system where it will process the EDI file into XML and be consumed into my system. But on the outbound file for the EDI, anyway that I could use x12Parser to assign data to it, and generate the EDI file?

Hope you can provide some hint and assistance.

Thanks in advance.

P/s: my apology in advance to dstrubhar for contacting him prior asking. Only realised I should have posted on this discussion thread instead.
Feb 27, 2013 at 11:19 PM
You can generate an XML file that matches the specifications that are outlined in the XSD file and then run it through the TransformToX12.exe program and it will convert it to an EDI file.

A good way that you can test this process with a file is to take a well formed EDI file, run the parseX12.exe program against it and then take the output from that program and run it through the transformToX12.exe program and it will transform it back to the X12 file. At that point you should have the original X12 file, the XML file and the freshly output X12 file. You can compare the two X12 files and they should be the same. You can take the XML file and use that as a guideline for what you need to transform your data into to run through the TransformToX12.exe program.
Feb 28, 2013 at 12:38 AM
Here would be an example of what I mentioned above:

Here is the sample file, samplefile.edi:
ISA00 00 121111111111 01111111111 1302271235U004030000000680P>
GSPO11111111111111111120130227123568X004030VICS
ST
8500001
BEG00SA
XX-123419980301AE123
N1
STJohn Doe
N2Division 1
N3
1000 Park Avenue
N4New YorkNY10610
PO1
125EA
9.5CTMGXYZ-1234
PIDF
HAMMER-CLAW
PO1275EA6.95CTMGL505-123
PID
F
*PLIERS 8 NEEDLE NOSE
CTT2
AMT
TT758.75C
SE
13
0001
GE168
IEA
1
000000068

For the purposes of this example I have the EDI file in the same file as the executable files.

From a command window prompt, I run:

C:\X12\Release>X12Parser.exe samplefile.edi samplefile.xml

This creates a new file called samplefile.xml, the content of which is:
<?xml version="1.0"?>
<Interchange segment-terminator=" " element-separator="*" sub-element-separator=">">
<ISA>
<!--Author Information Qualifier-->
<ISA01>00<!--No Authorization Information Present--></ISA01>
<!--Author Information-->
<ISA02>          </ISA02>
<!--Security Information Qualifer-->
<ISA03>00<!--No Security Information Present--></ISA03>
<!--Security Information-->
<ISA04>          </ISA04>
<!--Interchange ID Qualifier-->
<ISA05>12<!--Matress Retailer--></ISA05>
<!--Interchange Sender ID-->
<ISA06>1111111111     </ISA06>
<!--Interchange ID Qualifier-->
<ISA07>01<!--Duns (Dun & Bradstreet)--></ISA07>
<!--Interchange Receiver ID-->
<ISA08>111111111      </ISA08>
<!--Interchange Date-->
<ISA09>130227</ISA09>
<!--Interchange Time-->
<ISA10>1235</ISA10>
<!--Inter Control Standards Identifier-->
<ISA11>U<!--U.S. EDI Community of ASC X12, TDCC, and UCS--></ISA11>
<!--Inter Control Version Number-->
<ISA12>00403</ISA12>
<!--Inter Control Number-->
<ISA13>000000068</ISA13>
<!--Acknowlegment Requested-->
<ISA14>0<!--No Acknowledgment Requested--></ISA14>
<!--Usage Indicator-->
<ISA15>P<!--Production Data--></ISA15>
<!--Component Element Separator-->
<ISA16>
  <ISA1601 />
  <ISA1602 />
</ISA16>
</ISA>
<FunctionGroup>
<GS>
  <!--Functional Identifier Code-->
  <GS01>PO</GS01>
  <!--Application Sender's Code-->
  <GS02>111111111</GS02>
  <!--Application Receiver's Code-->
  <GS03>111111111</GS03>
  <!--Date-->
  <GS04>20130227</GS04>
  <!--Time-->
  <GS05>1235</GS05>
  <!--Group Control Number-->
  <GS06>68</GS06>
  <!--Responsible Agency Code-->
  <GS07>X<!--Accredited Standards Committee X12--></GS07>
  <!--Version/Release/Industry Identifier Code-->
  <GS08>004030VICS</GS08>
</GS>
<Transaction ControlNumber="0001">
  <ST>
    <!--Transaction Set Identifier Code-->
    <ST01>850</ST01>
    <!--Transaction Set Control Number-->
    <ST02>0001</ST02>
  </ST>
  <BEG>
    <BEG01>00</BEG01>
    <BEG02>SA</BEG02>
    <BEG03>XX-1234</BEG03>
    <BEG04 />
    <BEG05>19980301</BEG05>
    <BEG06>AE123</BEG06>
  </BEG>
  <Loop LoopId="N1" Name="">
    <N1>
      <!--Entity Identifier Code-->
      <N101>ST</N101>
      <!--Name-->
      <N102>John Doe</N102>
    </N1>
    <N2>
      <N201>Division 1</N201>
    </N2>
    <N3>
      <!--Address Information-->
      <N301>1000 Park Avenue</N301>
    </N3>
    <N4>
      <!--City Name-->
      <N401>New York</N401>
      <!--State or Provice Code-->
      <N402>NY</N402>
      <!--Postal Code-->
      <N403>10610</N403>
    </N4>
  </Loop>
  <Loop LoopId="PO1" Name="Baseline Item Data">
    <PO1>
      <PO101>1</PO101>
      <PO102>25</PO102>
      <PO103>EA</PO103>
      <PO104>9.5</PO104>
      <PO105>CT</PO105>
      <PO106>MG</PO106>
      <PO107>XYZ-1234</PO107>
    </PO1>
    <Loop LoopId="PID" Name="Product/Item Description">
      <PID>
        <PID01>F</PID01>
        <PID02 />
        <PID03 />
        <PID04 />
        <PID05>HAMMER-CLAW</PID05>
      </PID>
    </Loop>
  </Loop>
  <Loop LoopId="PO1" Name="Baseline Item Data">
    <PO1>
      <PO101>2</PO101>
      <PO102>75</PO102>
      <PO103>EA</PO103>
      <PO104>6.95</PO104>
      <PO105>CT</PO105>
      <PO106>MG</PO106>
      <PO107>L505-123</PO107>
    </PO1>
    <Loop LoopId="PID" Name="Product/Item Description">
      <PID>
        <PID01>F</PID01>
        <PID02 />
        <PID03 />
        <PID04 />
        <PID05>PLIERS 8 NEEDLE NOSE</PID05>
      </PID>
    </Loop>
  </Loop>
  <Loop LoopId="CTT" Name="">
    <CTT>
      <CTT01>2</CTT01>
    </CTT>
    <AMT>
      <!--Amount Qualifier Code-->
      <AMT01>TT</AMT01>
      <!--Monetary Amount-->
      <AMT02>758.75</AMT02>
      <!--Credit/Debit Flag Code-->
      <AMT03>C</AMT03>
    </AMT>
  </Loop>
  <SE>
    <!--Number of Included Segments-->
    <SE01>13</SE01>
    <!--Transaction Set Control Number-->
    <SE02>0001</SE02>
  </SE>
</Transaction>
<GE>
  <!--Number of Transaction Sets Included-->
  <GE01>1</GE01>
  <!--Group Control Number-->
  <GE02>68</GE02>
</GE>
</FunctionGroup>
<IEA>
<!--Number of Included Functional Groups-->
<IEA01>1</IEA01>
<!--Interchange Control Number-->
<IEA02>000000068</IEA02>
</IEA>
</Interchange>

If I want to test doing an XML to EDI transformation I can then take do the following:

C:\X12\Release>TransformToX12.exe samplefile.xml samplefileOut.edi

That transforms the XML file back into the following:
ISA00 00 121111111111 01111111111 1302271235U004030000000680P>
GSPO11111111111111111120130227123568X004030VICS
ST
8500001
BEG00SA
XX-123419980301AE123
N1
STJohn Doe
N2Division 1
N3
1000 Park Avenue
N4New YorkNY10610
PO1
125EA
9.5CTMGXYZ-1234
PIDF
HAMMER-CLAW
PO1275EA6.95CTMGL505-123
PID
F
*PLIERS 8 NEEDLE NOSE
CTT2
AMT
TT758.75C
SE
13
0001
GE168
IEA
1
000000068

Comparing the original input file to the new output file we can see that the data files match up.

Now that we have seen that process work full flow, you should be able to clear the output data from the XML file and you can map your own data into it. (Assuming that you are looking to map into a purchase order file. If there is some other X12 file that you are trying to process you could repeat the same process that I illustrated above.
Coordinator
Feb 28, 2013 at 3:06 PM
To create X12 from scratch, you can look at an example unit test here http://x12parser.codeplex.com/SourceControl/changeset/view/20228#151876.
Eventually there will be a documentation page explaining this.

The advantages of using the parser for this is that it will automatically count your segments to place in the trailing segements SE, GE and IEA.
It will also check your segments against the spec to make sure they are allowed and it will cleanup any empty elements at the end of your segments.

For some of the segments, there are strongly typed classes that have the names of each elements in the segment.
Feb 28, 2013 at 3:23 PM
stevenacollins and dstrubhar:
Thank you! It's delighting to see active communities replying here! Most importantly, this project x12parser provides great coverage be it in documentation or the codes. Very well documented! Thanks from me and kudos to all the contributors/developers! Would certainly be happy to play a part by contributing if I could in near future.

dstrubhar:
I did found out the sample unit test provided with the package after I posted this message. The closest example that could well resembles to what I need (I'll be generating EDI for invoice-810) is PurchaseOrderCreationTester.cs. However, the sample were not quite complete as in the element "N1" is not available. Is there any reason? I guess adding a new segment will do the trick? Sorry if I am demanding too much but I'll test and play around trying it out (hopefully I could extend my duetime). But really, thanks alot! It has solved a major of my headache.
Coordinator
Feb 28, 2013 at 4:16 PM
I can add N1Segment for the next release, let me know which other ones you need that are missing.
Mar 4, 2013 at 8:03 AM
Wow, that's awesome dstubhar! I tried to search for the elements and found out below that are missing:

Header
BIG - Beginning record
N1 - Name
N2 - Additional name
FOB - F.O.B Related instructions
ITD - Terms of sale
DTM - Date/Time Reference

Detail
IT1 - Line Item Information
CTP - Pricing Information
PID - Item Description

Summary
TDS - Total Monetary Amount
TXI - Tax information
CAD - Carrier Details
SAC - Service, Promotion, Allowance or Charge Information
CTT - Transaction Totals
ISS - Invoice Shipment Summary
SE - Transaction Set Trailer

Please let me know if there is anyway I could help.

Thanks.

Warm Regards,
EK
Coordinator
Mar 7, 2013 at 2:27 PM
I have checked in an implementation of these segments.
The sample unit test for creation is here: http://x12parser.codeplex.com/SourceControl/changeset/view/23465#367671.

I may also add a few more segments that you have not listed before a do a release.

PID and IT1 can be treated as either a loop or a segment, but it has to follow the way it was defined in the specification, so make sure you use TypedLoopIT1 or TypedLoopPID when the spec defines it as a loop.