convertToString Record ID overwriting other records fields

I have a need to parse and split an X12 810 document. The GS envelope contains many ST envelopes. I have a need to split those ST documents into single EDI transactions within Trading Networks. The first thought that comes to mind is “hey…just use the WmEDI module for TN and set the configuration to split the document at the ST!”. I agree, that would be an easy approach. That’s worked for me at other places flawlessly. However, my employer uses GXS AI Server and Trade Guide for EDI translation. The webMethods platform is simply the communication method. They have no desire to switch their translation platform to webMethods, at this time. So…I’m stuck with just the FlatFile Adapter.

Now, having some history, and the knowledge the the EDI Module isn’t an option for me, let me pose to the group my problem. I’ve successfully created a Flat File Dict. and Schema that identify the segments and fields for a trading partners 810 implementation. It parses the 810 data perfectly fine. I can use convertToValues to create the IData object necessary to split the document. However, when I use the convertToString service to reassemble my single 810 document (I loop over the GS and then the ST nodes of the afore mentioned IData object) into a flat file, the Record IDs (GS, ST, etc…) all overwrite 2-3 characters of the first field for that record (GS01, ST01, etc…). I’ve configured the extractor to pull the record ID at field 0 and all the record’s constituent fields begin at field 1 and go outward from that point. I’ve even tried using composite field definitions, however, I may not have done those correctly. The flat file schema is a nested schema. That is to say that the following nesting is true:

ISA
-GS
----ST
------BIG
------REF
------N1
--------N3
--------N4
------IT1
------PID
------PO4
------TDS
------CTT
------SE
----GE
-IEA

Curiously, it appears as if the record ID is being overlaid the first 2-3 characters of the segment’s first field. It depends on how large the record ID is (2 or 3 characters). Any idea how or if it is even possible to keep the convertToString service from overwriting the first field? I do want the recordID to show. I just do not want it to overwrite the field contents.

I have resolved my problem. I needed to create a field within the record to contain the record ID value. In other words, I didn’t have my dictionary/schema configured correctly.
I misunderstood how the convertToString service output the flat file with regards to the record ID. The record ID will be input as the first “n” number of characters (“n” being dependent on the length of the record ID) beginning with the first byte of the record. I assumed the service would read my schema and see that the first field was actually listed in position “1” instead of “0” (I’m using “Nth field” positioning) . Therefore, it would automatically place the record ID in field position “0” and continue with my other fields as they were defined (i.e. position “1”, then “2”, etc…). That is not the case. You must provide the schema with a record ID “container” field. That field should always be created in the position that you wish the record ID to be contained (i.e. “0”, “3”, etc…). In hindsight, that makes perfect sense with the options presented to the user when defining where the record ID is located. See my example below.

If you have the following:

GSIN971507Fantasy Corp20091019213910301X004010

Then you must define your flat file schema so that the record “GS” is structured as such.
GS -
–GSID field = 0
–GS01 field = 1
–GS02 field = 2 ← record ID “container” field.
–GS03 field = 3
–GS04 field = 4
–GS05 field = 5
–GS06 field = 6
–GS07 field = 7
–GS08 field = 8