Create BizTalk Project for EDI processing
Take EDI850 (Purchase Order Transaction) as Example [ANSI ASC X12]
Introduce
What is EDI (Electronic Data Interchange)? The simple concept of EDI was to communicating information between companies (partners or parties….) that following the pre-defined standard (X12/EDIFACT/HIPAA….), such as purchase orders or invoices…
The article would be talk about how to use BizTalk server for handing EDI format data and transfer into enterprise database (could be ERP), then the company could deal the rest of business process and thus reduce the paperwork.
-- Below is the EDI sample of 850 (X12-V004010) --ISA*00* *00* *14*SENDERISA *ZZ*RECEIVERISA *210331*0307*U*00401*501045912*0*P*|~
GS*PO*SENDERGS*RECEIVERGS*20210331*0307*150912*X*004010~ST*850*1125~
BEG*00*DS*91101998**20160804~
CUR*BY*USD~
REF*CO*4540321299TEST~
REF*PRT*PN~
REF*YB*0~
FOB*DF***01*FCA~
ITD*01***********NET 30~
N1*ST*NEST LAB.*92*DS5435112-2689~
N3*GLOBE TELECOM PHILIPPINES*Lemcon Taguig Warehouse and Main Office~
N3*No 19 , Mars~
N4*Taguig City***PH~
N1*SF*Chicony LTD*92*12345678~
N3*12345 SOME ROAD~
N4*TOKYO**23678*JP~
N1*BT*NEST LAB.*92*701218~
N2*XXXXXXX Pte. Ltd.~
N3*XXXXXXXXXXX Pte. Ltd.*8 Marina View~
N3*Asia Square 1 #30-01~
N4*Singapore**018960*SG~
PER*CN*ALLEN.SMITH~
PO1*1*300*EA*85.9**BP*NC1102DE***MG*2345678901~
PID*F****Assy, Network Media Caching Device with QPSK Receiver~
REF*ZZ*YES~
DTM*002*20190804~
N9*L1**Letters and Notes~
MSG*NOTE TO VENDOR - Contact Name: ,Contact Number: ,Unit Selling Price:500 ,Consignee Address:~
PO1*2*200*EA*85.9**BP*NC1102DE***MG*2345678901~
PID*F****Assy, Network Media Caching Device with QPSK Receiver~
REF*ZZ*YES~
DTM*002*20190804~
N9*L1**Letters and Notes~
MSG*NOTE TO VENDOR - Contact Name: ,Contact Number: ,Unit Selling Price:500 ,Consignee Address:~
CTT*2~
SE*35*1125~
GE*1*1125~
IEA*1*100000125~
The detail definition of X12 of EDI850, please see here for more detail.
Implement — BizTalk Project
Open visual studio, create “New Empty BizTalk Project”
The deployment process requires that each assembly is strongly signed.
Configure the deploy target BizTalk server
Add new Adapter metadata from your database. (“Add” > “Add Generate Items” from your project solution window)
Select adapter.
- Configure your database setting (connection String).
- Connect.
- Select your target table.
- Choose your desire operation (Take insert as example).
- Add and OK.
Add EDI 850 schema. (“Add” > “Add Existing Item” from your project solution window)
Change target namespaces.
Now we have source XSD schema: X12_00401_850.xsd and target schema: Dell_SNP_850_Recv_DellB2B_SNPEDI850_PurchaseOrder_Header.xsd. So we could create our mapping between source and target.
Select source schema: X12_00401_850.xsd.
Select destination schema. (table you want to insert)
Create mapping line between source: EDI850 data to destination: your database. Example as green arrow from ST01 → MESSAGE_ID.
You need to read the definition of each EDI850 field for mapping to your company’s table structure.
Assume that mapping done well. Next we need to create “Orchestration”.
Delete default orchestration and add new orchestration (“Add ” > “Add New Item”)
Image the orchestration let us design the flow for triggering the whole process of transform EDI850 data to our destination database.
Create new Messages: MSG_EDI850_ORI, MSG_EDI850. (Orchestration View)
Note, MSG_EDI850 & MSG_EDI850_ORI: X12_00401_850 (same Message Type)
Create new Messages: MSG_850_HEADER. Note, MSG_850_HEADER: Dell_SNP_850_Recv_DellB2B_SNPEDI850_PruchaseOrder_Header.Insert (BizTalk will generate insert metadata for us)
Message might like the variable that stored the whole document and following the structure of schema (Message Type).
Create one way Receive Port (Green Arrow) with binding later and Receive (Blue Arrow) with MSG_ORI.
The receive port is logic port for receiving EDI raw data something like sample on the introduce section. The receive will get the file and store to MSG_ORI.
Create construct message and message assignment inside.
Double click message assignment. First we assign MSG_EDI850_ORI to MSG_EDI50, then we can store extra message into MSG_EDI850.
The tricky for the part is to fill some other information over the field(s) of EDI, so that we could bring them into our destination database.
Note: need to promote schema and add reference (Microsoft.BizTalk.BaseArtifacts)
Promote: ST.ST01, SE.SE01, BEG.BEG01, otherwise we could not have access right for the original field(s).
Create send with MSG_EDI850 and one way send port with binding later.
Create construct message and poll transform with MSG_850_HEADER inside.
Double click transform for configuration. Select “Existing Map” and Source: MSG_850, destination: MSG_850_HEADER.
Create send with MSG_850_HEADER and one way send port with binding later.
We have completed the project side. Build and deploy assemblies to BizTalk server. Then start to configure BizTalk server.
Implement — BizTalk Server
Launch to BizTalk console, then we could find out our application appear under the level of “Applications”.
Remember we have created 3 logic one way ports (Over BizTalk project): 1 receive port and 2 send ports and decide to bind it later. For this moment, we should create 3 psychical ports and binding correspond with those logic ports.
New > One-way Receive Port > Receive Location -> New
- Type: File, and configure the URI where the BizTalk will monitor.
- Receive handler: BizTalkServerApplication.
- Receive pipeline: EdiReceive.
If you could not find the pipeline of EdiReceive, please add reference “BizTalk EDI Application” into your current application.
New > Static One-way Send Port -> General
- Type: File, and configure the URI where the BizTalk will write to.
- Send handler: BizTalkServerApplication.
- Send pipeline: XML Transmit. The file will write in XML format.
New > Static One-way Send Port -> General
- Type: WCF-SQL
- Send handler: BizTalkServerApplication.
- Send pipeline: XML Transmit.
Configure WCF-SQL with the connection setting and paste SOAP Action header. We could refer the action under below, Go to project and find Dell_SNP_850_Recv_DellB2B_SNPEDI850_PruchaseOrder_Header.xsd, Click into and search the element name “Insert”, copy the value of the tag: <doc:action />.
Setup Parties > Agreement -> Identifiers, fill-in values ISA5, ISA6, ISA7, ISA8.
The agreement settings should be consistent between 2 parties. That means if any changes you should inform your party (If you are role A, contact role B for your changed)
Setup Parties > Agreement -> Validation, for 850.
Setup Parties > Agreement -> Local Host Settings, fill-in sender GS2 value for 850.
Start the current application, and drop one EDI850 raw data into the directory URI which setup on above physical send port. If everything went well then EDI850 should be inside your destination table according your mapping relationship:).