Because there are so many entrieson the web about how todevelop a schemanot included in the standard install of the BaseEDI accelerator, I would like to share how to create schemas that can be successfully imported and used.

Use http://www.disa.org/x12workbook/ts/ as implementation guide

Referring to http://msdn2.microsoft.com/en-us/library/aa559550.aspxand http://support.microsoft.com/?id=840113

1.Ensuretheheaderof the schemalooks like the following. I’ve highlighted the important values that need to be verified for each transaction. The encoding should beutf – 8.

Manually add the following data types to the schema

2. Use correct Rules subjects. The4 subject rules are the following:

Covast =EDI Implementation

All = Either

Any = One Present, Other Required

Grouped = Either Present, Other Required

One = Only one may be present

Example:

This creates the rules in the database and eif that checks for the Syntax Rules, example

Syntax Rules

At least one of DTM02, DTM03 or DTM05 is required.

If DTM04 is present, then DTM03 is required.

If either DTM05 or DTM06 is present, then the other is required.

This creates the internal rules that generate errors like in the following example:

Error encountered: ERROR (81), interchangenr 10209 :

The check condition has not been met. Contact the sender.source format: [5 00401 ,X12-4010]

source document: [812 004010DEFAULT X,CreditDebitAdjustment]

source segment: [data#4,def#4,tag=PER ,name=812_004010_DEFAULT_X_<PER]

source element: [def#3,elm#3,comp#0,name=812_004010_DEFAULT_X_<PER03>],

value: [CR]

undefined!

((812_004010_DEFAULT_X_<PER03> <> [] OR

812_004010_DEFAULT_X_<PER04> <> [] ) AND

(812_004010_DEFAULT_X_<PER05> <> [] OR

812_004010_DEFAULT_X_<PER06> <> [] ) AND

(812_004010_DEFAULT_X_<PER07> <> [] OR

812_00, (msgnr:1 segnr:4)(line:17 pos:6 filepos:761)

3. Ensure that all Subject names have “@” before the attribute name

4. Do not include an ISA, GS, or ST segments in your schema

5. All EDI elements must be XSD attributes not elements

6. Verify Schema Node Properties are correct. Highlighted properties are unique for XSD.

7. Verify Root Properties are correct. Highlighted properties are unique for each XSD.

8. Use Requirement, EDI datatype, and Maximum/Minimum Length must be explicitly declared in XSD. If you leave the Use Required as (Default) there is no attribute written to the XSD, and validation of documentswill fail, you will need to explicidly declare all elementsto be either Optional or Required. Verify by looking at actual XSD to make sure they are declared. Do not include Notes on any Attribute, Segment, or Loop.

If there are notes in the schema, what happens is that during the XSD2EDI.exe load it loads theNotes into the dbo.segcon table ‘Transaction<Notes>’instead of the ‘Transaction<segmentname>{occurrence}’, and then tries to load the non-uniquecolumn into the dbo.elmnts table, violating a primary key contraint:

xsd2edi : xsd2edi started
xsd2edi : Start parsing schema.
xsd2edi : End of parsing schema.
xsd2edi : Compare hashtotals 1QkjjiQpdJOb6SceeNzjNrQ==
xsd2edi : Start dumping definition to TEMP directory.
xsd2edi : End dumping definition to TEMP directory.
xsd2edi : Start deleting old document definition from repository.
xsd2edi : End deleting old document definition from repository.
xsd2edi : Start inserting new document definition to repository.
xsd2edi : Error in inserting document definition: Error = [Microsoft][SQL Native Client][SQL Server]Violation of PRIMARY KEY constraint ‘PK__elmnts__1A14E395’. Cannot insert duplicate key in object ‘dbo.elmnts’.
xsd2edi : End inserting new document definition to repository.
xsd2edi : (-2160) <Description for error (-2160) cannot be found. Please refer to the Trouble Shooting Guide for this description>
xsd2edi : xsd2edi finished

(who uses Notes anyway?!)

9. Date and Time attribute Properties. Advanced Base Data Type should be set to “xs:string” and General Data Type should be set to either“X12_DT (Simple Type)”or “X12_TM (Simple Type)” .

10. Covast Codelists are saved in the <install directory>\Microsoft BizTalk Server 2006\EDI\Adapter\CodeLists\EDICodelists.mdb database. Use the correct code list according to the implementation guide, an example code list is here.

11. Save the schema as <DocumentNumber>Schema.xsd.

12. Load the schema into the EDI Adapter using <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\xsd2edi.exe “[Path to your XSD Schema]\<DocumentNumber>Schema.xsd”

13. Use <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\compeif.exe utility to complete import.

14. Deploy the schema

If there is a problem with the XSD2EDI import process, to remove it you simply add the -r switch: <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\xsd2edi.exe “[Path to your XSD Schema]\<DocumentNumber>Schema.xsd” -r

As a side note, if you would like to save yourself some time, you can easly contact me through my contact page and I can assist in producing a valid EDI schema.