Step 1: Add the X12 SalesOrder (840) Schema and Transform to the Visual Studio Project
Important
Microsoft Azure BizTalk Services (MABS) is being retired, and replaced with Azure Logic Apps. If you currently use MABS, then Move from BizTalk Services to Logic Appsprovides some guidance on moving your integration solutions to Logic Apps.
If you're brand new to Logic Apps, then we suggest getting started here:
-
Create your first logic app, or quickly get started using a pre-built template
-
View all the available connectors you can use in your logic apps
In this step, you include the X12 840 sales order schema in your project. You also create a Transform to map the elements in the X12 schema and the SalesOrder schema you created in Step 2: Create SalesOrder Schema. This is required because the EDI bridge configured using the BizTalk Services Portal sends the message to the EAI bridge, which expects the incoming messages in the SalesOrder schema.
Note
In this step, you add the X12 840 sales order schema and the Transform to the EAIEDITutorial BizTalk Service project. However, you can always create a new project for just the schema and the Transform. Typically, you should create a BizTalk Service Artifacts project for such schemas and Transforms. For more information about this project type, see Get started with a Visual Studio project.
To include the X12 840 schema in the Visual Studio project
Download the EDI X12 schemas from https://go.microsoft.com/fwlink/p/?LinkId=235057. The schema is available as part of the MicrosoftEdiXSDTemplates.zip package.
Right click the EAIEDITutorial project in Visual Studio, point to Add, and then click Existing Item. Navigate to the location where you downloaded and extracted the schemas, select the X12 840 schema (X12_00401_840.xsd), and add it to the project.
Create a Transform between the X12 840 schema and the SalesOrder schema. You must create a Transform to extract the values you want from the X12 message and reflect them in the SalesOrder message. Specify the name of the map as EDI840ToSalesOrder.trfm. For instructions, see Create a Transform or Map.
To include a transform
In Visual Studio, right-click the EAIEDITutorial project, point to Add, and then click New Item.
Note
If you want to use an already created map, you can use the EDI840ToSalesOrder.trfm map. This map is available as part of the sample available from the MSDN Code Gallery.
In the Add New Item dialog box, select Map, specify the map name as EDI840ToSalesOrder.trfm, and then click OK.
In Solution Explorer, double-click the EDI840ToSalesOrder.trfm file to open the map.
In the Transform window, select the source schema to X12_00401_840.xsd and the destination schema to ECommerceSalesOrder.xsd.
Directly map the following nodes in the source and destination schemas:
Source Schema
Destination Schema
N1Loop1/N2/N201
CompanyCode
PO1Loop1/PO1/PO107
PartID
PO1Loop1/PO1/PO102
Quantity
PO1Loop1/PO1/PO104
AskPrice
N1Loop1/N3/N301
Address/Line1
N1Loop1/N3/N302
Address/Line2
N1Loop1/N4/N401
Address/City
N1Loop1/N3/N402
Address/State
N1Loop1/N4/N404
Address/Country
N1Loop1/N4/N403
Address/Zipcode
PER/PER02
Contact/Firstname
PER/PER04
Contact/Lastname
Map the elements from the source schema (X12_00401_840) to the RequestShipmentDate element. The element in the source message that has the requested shipment date is BQT05. The value in that element is in the format YYYYMMDD. The value that must be entered in SalesOrder schema must be of the form YYYY-MM-DD. So, to achieve that, you must map the BQT05 and RequestShipmentDate elements as shown in the screenshot below:
To achieve this mapping, this is what you must do:
Drag and drop a String Extract Map Operation on the mapper surface and connect it to the BTS05 element from the source schema. Double-click the String Extract Map Operation and set the Start Index property to 1 and the End Index property to 4.
Drag and drop a String Extract Map Operation on the mapper surface and connect it to the BTS05 element from the source schema. Double-click the String Extract Map Operation and set the Start Index property to 5 and the End Index property to 6.
Drag and drop a String Extract Map Operation on the mapper surface and connect it to the BTS05 element from the source schema. Double-click the String Extract Map Operation and set the Start Index property to 7 and the End Index property to 8.
With this, you have now extracted the values for YYYY, MM, and DD. You must now use the String Concatenate Map Operation to join the extracted values using a hyphen (-). This is how the configuration for the String Concatenate Map Operation looks like.
In this screenshot, Input_0, Input_2, and Input_4 are from the String Extract Map Operations that are connected to the String Concatenate Map Operation. Values for Input_1 and Input_3 are set as hyphens (-). After this Map Operation, the value that will be transferred to the RequestShipmentDate element will be in the format YYYY-MM-DD.
You must now connect the String Concatenate Map Operation to the RequestShipmentDate element in the destination schema.
Repeat the tasks in the previous step to map the BQT03 element in the source schema to the DateNow element in the destination schema. The mapped elements must look like the following:
To populate a value in the Comments element, map the N201 element in the source schema with the Comments element in the destination schema using the String Concatenate Map Operation.
Drag and drop a String Concatenate Map Operation on the mapper surface.
Double-click the Map Operation to open the Configure String Concatenate dialog box and set the Input_0 property to “Order from partner “. Click OK.
Connect the N201 element in the source schema to the String Concatenate Map Operation and then join the mapop to the Comments element in the destination schema. The configuration for the Map Operation must resemble the following:
With this configuration, if the value in the N201 element in the source schema is XYZ, for example, the value in the Comments element in the destination schema will be set to Order from Partner XYZ.
Save changes to the map.