0

!enter image description here

Hello all.I am new to EDI X12. I have got a task to read GS Segment 6th field(GS06) underlined in red in above image.Please help me with how to code in c# to get that value of GS06

user1410658
  • 551
  • 3
  • 10
  • 20
  • Why do you need to find the group control number? You can also get this same value from the GE segment. In your example, the ISA control number is the same (padded with zeros though). The problem there is that might not always be true, but I'd need to know your use case here. – Andrew Oct 20 '14 at 03:55

3 Answers3

2

First, you want the full document in memory. Then, by reading character 106, you will have the segment delimiter. Also grab character 4 for the field delimiter. Call Splitstring based on the segment delimiter, and you'll have an array of segments.

Typically, GS should be the second segment, so array[1] (or, as Andrew points out, you can check specifically for a segment that starts with "GS" & fieldDelim & "OG"). Splitstring again based on your field delimiter, and secondArray[5] is your GS06.

FinrodFelagund
  • 207
  • 4
  • 13
0

To start you need to find the element delimiter. In your example, it is the asterisk. Your segment terminator is the tilde.

The ISA segment is fixed length. The other segments are variable length. For your parser, to find a particular element, you should read in the text file, and parse the segments based on the segment terminator. After that, you can find the segment you're looking for, figure out the number of element delimiters and you have your found value.

In your example, the GSOG string will be constant. So you can read in the text file and when you encounter ~GSOG you know you're in the right location. Use your knowledge of delimiters to get you to where you need to be in the string.

Or use a commercial translator that will give you more mapping options.

Andrew
  • 2,801
  • 1
  • 26
  • 27
0

First put each lines into array(you can split the '~' sign),so that the second line will be the GS segment.Then again split the GS segment into array(ypu can split using '*').The sixth of the GS segment array will be GS06.Try this.Similarly you can get any value.

Sumi
  • 3
  • 2