Tutorial - Supply Chain

Embed Size (px)

Citation preview

  • 8/7/2019 Tutorial - Supply Chain

    1/31

    Tutorial: Supply Chain

    Microsoft Corporation

    Published: September 2010

    Summary

    The supply chain tutorial walks you through a supply chain scenario that is likely to be used in a

    manufacturing organization.

  • 8/7/2019 Tutorial - Supply Chain

    2/31

    Copyright

    Information in this document, including URL and other Internet Web site references, is subject to

    change without notice. Unless otherwise noted, the companies, organizations, products, domain

    names, e-mail addresses, logos, people, places, and events depicted in examples herein are

    fictitious. No association with any real company, organization, product, domain name, e-mail

    address, logo, person, place, or event is intended or should be inferred. Complying with all

    applicable copyright laws is the responsibility of the user. Without limiting the rights under

    copyright, no part of this document may be reproduced, stored in or introduced into a retrieval

    system, or transmitted in any form or by any means (electronic, mechanical, photocopying,

    recording, or otherwise), or for any purpose, without the express written permission of Microsoft

    Corporation.

    Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectualproperty rights covering subject matter in this document. Except as expressly provided in any

    written license agreement from Microsoft, the furnishing of this document does not give you any

    license to these patents, trademarks, copyrights, or other intellectual property.

    2010 Microsoft Corporation. All rights reserved.

    Microsoft, MS-DOS, Windows, Windows Server, Windows Vista, Active Directory, BizTalk, Excel,

    SharePoint, Visio, Visual C#, and Visual Studio are either registered trademarks or trademarks of

    Microsoft Corporation in the United States and/or other countries.

    All other trademarks are property of their respective owners.

  • 8/7/2019 Tutorial - Supply Chain

    3/31

    Contents

    Tutorial: Supply Chain ................................................................................................................ 4Lesson 1: Set Up the BizTalk RFID Environment ....................... .......................... .................... 7

    Step 1: Install BizTalk RFID .......................... .......................... ............................ .................. 7Step 2: Run the Tutorial Setup Scripts ....................... .......................... ............................ ..... 8Step 3: Start the ContosoTestProcess Process .................................................................... 9

    Lesson 2: Receive Parts into Inventory ......................... .......................... ............................ ....10Step 1: Query Parts Before Receive .......................... .......................... ............................ ....11Step 2: Receive Parts .........................................................................................................12Step 3: Query Parts After Receive ......................... .......................... ............................ ........13Step 4: Assign Received Parts into Inventory ............................................... .......................14

    Lesson 3: Create Assemblies from Parts ...................... .......................... ............................ ....16Step 1: Query Assembled Parts Before Assembly ....................... ......................... ...............16Step 2: Create a New Tag for the Assembly ....................... .......................... .......................18Step 3: Verify the Assembly Tag .........................................................................................19Step 4: Assign Inventory Parts to Assembly ........................................................................22Step 5: Query Assembled Parts After Assembly .......................... ......................... ...............26

    Lesson 4: Decommission a Tag That Fails Quality Assurance ............................................... .27Step 1: Verify That the Tag Exists .......................................................................................27Step 2: Decommission the Tag............................................................................................29Step 3: Verify the Decommissioned Tag ......................... ......................... ............................30

  • 8/7/2019 Tutorial - Supply Chain

    4/31

    4

    Tutorial: Supply Chain

    BizTalk RFID can be used to scan and read RFID tags at all steps in an organization's supply

    chain. RFID tags can be used for item-level tagging, subassemblies, assemblies, cartons, pallets,

    and more.

    The supply chain tutorial walks you through a supply chain scenario that is likely to be used in a

    manufacturing organization. The scenario presented in this tutorial assumes that a manufacturer

    receives parts from a supplier and combines them into assemblies. Each part from the supplier

    has an item-level RFID tag on it to enable tracking of individual items. An RFID tag is generated

    for each assembly and the parts received into inventory are assigned to those assemblies.

    The supply chain scenario in this tutorial is not intended to be a complete end-to-end scenario,

    but rather one that illustrates the concepts of how BizTalk RFID can be used. Many of the

    concepts that you will learn in this tutorial will be repeated in other areas of a real-world supplychain scenario. For example, the concept of assigning parts to an assembly and generating an

    RFID tag for that assembly can be used to pack and ship the assemblies. For brevity, the pack-

    and-ship part of the supply chain is not discussed in this tutorial.

    The lessons in this tutorial use predefined scripts that are specifically designed to support this

    tutorial. Some lessons also use the Contoso device simulator that comes with BizTalk RFID to

    ensure that specific hardware is not needed to run this tutorial. For more information about using

    the Contoso device simulator, see Testing a Server Application.

    The premise of this tutorial is that the rfidclientconsole.exe command-line utility is used to add

    RFID events to the process pipeline of a process named ContosoTestProcess. You will use the

    rfidclientconsole utility to post three tag-read events for three parts that are going to be used in an

    assembly. The ContosoTestProcess process uses the SQL Server sink event handler to store

    RFID events in the RFIDsink database..

    After parts are received into inventory, they are constructed into an assembly. This turorial also

    generates an RFID tag that is assigned to the new assembly. Because the RFIDsink database is

    not meant to be a permanent data store, tag data is inserted into a SupplyChain database, which

    is created as part of this tutorial.

    The following script and configuration files are provided as part of this tutorial and can be

    downloaded from http://go.microsoft.com/fwlink/?LinkId=191537.

    Script or configuration file name Purpose

    Tutorial1_Lesson1_Step2_CreateSupplyChainDB.sql SQL script that creates a new database

    named SupplyChain and creates tables to

    support the examples shown in this

    tutorial.

    Tutorial1_Lesson1_Step2_CreateFunctions.sql SQL script that creates a user-defined

    function named

  • 8/7/2019 Tutorial - Supply Chain

    5/31

    5

    Script or configuration file name Purpose

    udf_ConvertBase64ToASCII in the

    SupplyChain database. This function is

    used to convert a Base64-encoded stringto an ASCII string. Base64-encoded

    strings are used in the BizTalk RFID XML

    tag files, but are not human-readable. The

    ASCII string is human-readable.

    Tutorial1_DataReset.sql Deletes all data in the SupplyChain

    database to enable you to run through

    tutorial steps multiple times.

    ContosoSimulatorConfig.xml Configuration file used to run the Contoso

    device simulator.

    Tutorial1_Lesson2_Step1.sql SQL script that selects the count of parts

    records read in the RFIDsink database.

    Tutorial1_Lesson2_Step2.cmd Script to run the rfidclientconsole.exe

    command-line tool that reads RFID tags

    from XML files, and posts the tags to the

    ContosoTestProcessprocess.

    PartsTag1.xml Parts tag with a TagID value of 1001,

    used in Lesson 2, Step 2

    PartsTag2.xml Parts tag with a TagID value of 1002,

    used in Lesson 2, Step 2

    PartsTag3.xml Parts tag with a TagID value of 1003,

    used in Lesson 2, Step 2

    Tutorial1_Lesson2_Step3.sql SQL script that reads the parts record

    data in the RFIDsink database.

    Tutorial1_Lesson2_Step4.sql SQL script that inserts parts data from the

    RFIDsink database into the SupplyChain

    database.

    Tutorial1_Lesson3_Step1.sql SQL script that selects the count of

    assemblies in the SupplyChain database.

    Tutorial1_Lesson3_Step2.cmd Script to run the rfidclientconsole.exe

    command-line tool that uses the Contoso

    device simulator to print RFID tags used

    to create new assemblies from XML files.

    AssemblyTag.xml Assembly tag with a TagID value of 2001,

  • 8/7/2019 Tutorial - Supply Chain

    6/31

    6

    Script or configuration file name Purpose

    used in Lesson 3, Step 2

    Tutorial1_Lesson3_Step3.sql SQL script that selects serialized data

    from the GenericEvents table in the

    RFIDsink database.

    Tutorial1_Lesson3_Step4.sql SQL script that selects serialized data

    from the GenericEvents table in the

    RFIDsink database and joins it with parts

    data. The resulting data is stored in the

    SupplyChain database.

    Tutorial1_Lesson3_Step5.sql SQL script that selects parts that are

    assigned to assemblies in the

    SupplyChain database.

    Tutorial1_Lesson4_Step1.cmd Script to run the rfidclientconsole.exe

    command-line tool to verify that assembly

    tag data exists in BizTalk RFID.

    TagMetadata.xml Assembly tag to test for existence in

    BizTalk RFID, used in Lesson 4, Step 1

    and Step 3.

    Tutorial1_Lesson4_Step2.cmd Script to run the rfidclientconsole.exe

    command-line tool to decommission (or

    kill) a tag.

    AssemblyKillTag.xml Assembly tag to decommission, used in

    Lesson 4, Step 2.

    Tutorial1_Lesson4_Step3.cmd Script that verifies assembly tag data was

    decommissioned in BizTalk RFID.

    In This Sectiony Lesson 1: Set Up the BizTalk RFID Environment

    y Lesson 2: Receive Parts into Inventory

    y Lesson 3: Create Assemblies from Parts

    y Lesson 4: Decommission a Tag That Fails Quality Assurance

  • 8/7/2019 Tutorial - Supply Chain

    7/31

    7

    Lesson 1: Set Up the BizTalk RFID EnvironmentIn this lesson, you set up the BizTalk RFID environment. This includes installing BizTalk RFID,

    running setup scripts that support the Supply Chain scenario, and running and testing the device

    simulator.

    In This Section

    y Step 1: Install BizTalk RFID

    y Step 2: Run the Tutorial Setup Scripts

    y Step 3: Start the ContosoTestProcess Process

    Step 1: Install BizTalk RFID

    Time to complete: 10 minutes

    Objective: In this step, you will install BizTalk RFID.

    Prerequisites

    Note the following requirements before you begin this step:

    y You must log on as a member of the local Administrators group.

    1. Identify a computer that you will use to run the tutorial.

    2. Install BizTalk RFID according to the instructions found in the BizTalk RFID Installation

    Guide.

    3. Verify that the RFID service is running by opening RFID Manager. If you are able to open

    RFID Manager and click the server name to view the Service Summary page without

    errors, you are ready to continue with the tutorial. For more information about RFID

    Manager, see How to Monitor BizTalk RFID Using RFID Manager [RFID11].

    What did I just do?

    In this step, you installed BizTalk RFID to prepare for the rest of the lessons in this tutorial.

    Next Steps

    Run the setup script according to Step 2: Run the Tutorial Setup Scripts

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    Step 2: Run the Tutorial Setup Scripts

    Step 3: Start the ContosoTestProcess Process

    To install BizTalk RFID

  • 8/7/2019 Tutorial - Supply Chain

    8/31

    8

    Step 2: Run the Tutorial Setup Scripts

    Time to complete: 5 minutes

    Objective: In this step, you will set up the SQL Server environment that is used throughout the

    rest of the lessons in this tutorial.

    Prerequisites

    Note the following requirements before you begin this step:

    y SQL Server Management Studio must be installed.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Open and execute the Tutorial1_Lesson1_Step2_CreateSupplyChainDB.sql file.

    This file creates the SupplyChain database that will be used throughout this tutorial. The

    SupplyChain database includes three tables named Assembly, Parts, and

    PartsAssembly. It also creates foreign key relationships between the tables. The

    SupplyChain database is used to store inventory, whereas the RFIDsink database is

    used to temporarily store tag data as it is read by the SQL Server Sink event handler, but

    it is not meant to be a permanent data store.

    Caution

    The SupplyChain database is created in the C:\Program Files\Microsoft SQL

    Server\MSSQL10.\MSSQL\DATA\ folder. If you don't want the

    database created in this folder, you need to edit the

    Tutorial1_Lesson1_Step2_CreateSupplyChainDB.sql file before executing it.

    4. Open and execute the Tutorial1_Lesson1_Step2_CreateFunctions.sql file. This file

    creates a user-defined function, called udf_ConvertBase64ToASCII. This function

    converts Base64 strings (as they are stored in the TagID, TagData, and other RFID XML

    fields) to ASCII strings. This is useful in later steps in the tutorial.

    What did I just do?

    In this step, you created the SQL Server environment, including the database and all required

    database objects that are needed to run this tutorial.

    If you want to delete all data in the SupplyChain database, but do not want to delete its

    objects, you can execute the Tutorial1_DataReset.sql file.

    Next Steps

    Test the Contoso device simulator in Step 3: Start the ContosoTestProcess Process.

    To run the tutorial setup scripts

    Note

  • 8/7/2019 Tutorial - Supply Chain

    9/31

    9

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    Step 1: Install BizTalk RFID

    Step 3: Start the ContosoTestProcess Process

    Step 3: Start the ContosoTestProcess Process

    Time to complete: 5 minutes

    Objective: In this step, you will run the ContosoTestProcess process and the Contoso device

    simulator, which will be used in later lessons in this tutorial.

    Prerequisites

    Note the following requirements before you begin this step:

    y

    BizTalk RFID must be installed and running.

    1. Navigate to the %rfidinstalldir%\Samples\Device Service

    Provider\Contoso\ContosoEndToEnd folder.

    2. Execute the Contososetup.cmd file. The commands in this file perform the following

    operations:

    a. Registers and starts the ContosoDeviceProvider device provider.

    b. Imports a device named ContosoTestDevice.

    c. Imports a process named ContosoTestProcess, which has logical device

    mylogicaldevice, and a SqlServerSink event handler.

    d. Deploys and starts the ContosoTestProcess process.

    3. Execute the runContososimulator.cmd file that is part of this tutorial. This opens a

    command window and runs the Contoso device simulator, but differs slightly from the

    same command file that exists in the %rfidinstalldir%\Samples\Device Service

    Provider\Contoso\ContosoEndToEnd\ContosoDeviceSimulator folder. The file that is part

    of this tutorial does not show unnecessary notifications that are not part of this tutorial.

    However, because of this modification, you may see an error that indicates "Notification

    XML not specified." This message can be ignored for this tutorial.

    4. Verify that no other errors are displayed in the command window and that the device

    simulator is ready to receive tags. You should see the following in the command window:

    1|Device Simulator web service started successfully

    4|Accepting new Reader Client at 0.0.0.0:6666

    5. If the device simulator is not started or if any other errors appear, make sure that you

    correct these errors before continuing. For additional information about running the

    Contoso device simulator, see Testing a Server Application.

    To run the Contoso device simulator

  • 8/7/2019 Tutorial - Supply Chain

    10/31

    10

    What did I just do?

    In this step, you started the ContosoTestProcess process and the Contoso device simulator. This

    simulator is not used until Lesson 3: Create Assemblies from Parts, Step 2: Create a New Tag for

    the Assembly, but is included here as part of the setup for the tutorial.

    Next Steps

    Receive parts into inventory to make them into assemblies in Lesson 2: Receive Parts into

    Inventory.

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    Step 1: Install BizTalk RFID

    Step 2: Run the Tutorial Setup Scripts

    Lesson 2: Receive Parts into InventoryIn Lesson 1: Set Up the BizTalk RFID Environment, you completed the setup of the BizTalk RFID

    environment. In this lesson, you will learn how to use the BizTalk RFID event processing pipeline

    to receive three parts that are individually tagged with item-level RFID tags. The data for these

    tags is stored in three separate XML files, one for each item. The tag data stored in each RFID

    tag is the Universal Product Code (UPC) number that uniquely identifies a manufacturer's

    product.

    The ContosoTestProcess process uses the RFID sink event handler to store the tag data read by

    BizTalk RFID. The data is stored in the RFIDsink database in the TagEvents table. This lesson

    shows how to use SQL to move the parts into inventory by inserting them into the SupplyChain

    database, which was created as part ofLesson 1: Set Up the BizTalk RFID Environment, Step 2:

    Run the Tutorial Setup Scripts.

    In This Section

    y Step 1: Query Parts Before Receive

    y Step 2: Receive Parts

    y Step 3: Query Parts After Receive

    y Step 4: Assign Received Parts into Inventory

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    SQLServerSink EventHandler [RFID11]

  • 8/7/2019 Tutorial - Supply Chain

    11/31

    11

    Step 1: Query Parts Before Receive

    Time to complete: 10 minutes

    Objective: In this step, you will query the RFIDsink database to ensure that it contains no parts

    data previously read by the ContosoTestProcess process. This ensures a clean database withwhich to run the rest of this tutorial.

    Prerequisites

    Note the following requirements before you begin this step:

    y The ContosoTestProcess process must be running without errors.

    y SQL Server Management Studio must be installed and connected to the RFIDsink database

    on the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson2_Step1.sql file):

    SELECT COUNT(*)

    FROM TagEvents

    WHERE TagSource = 'Antenna3'

    AND LEN(CONVERT(VARCHAR, CONVERT(VARBINARY,

    TagData))) = 12

    4. Verify that the count of records returned from this query is zero. If you have already

    completed this tutorial and there are parts in the database, you can clear the RFIDsinkand SupplyChain databases by running the Tutorial1_DataReset.sql SQL script.

    What did I just do?

    In this step, you verified that the RFIDsink database contains no parts data that was read by the

    ContosoTestProcess process before receiving parts into inventory. You did this by selecting a

    count of the number of records that are read by Antenna3 and have a 12-character UPC in the

    TagData field.

    Next Steps

    Receive parts into inventory to by following the steps mentioned in the next step: Step 2: ReceiveParts

    See Also

    Lesson 2: Receive Parts into Inventory

    Step 2: Receive Parts

    To query for parts in the RFIDsink database

  • 8/7/2019 Tutorial - Supply Chain

    12/31

    12

    Step 3: Query Parts After Receive

    Step 4: Assign Received Parts into Inventory

    Step 2: Receive PartsTime to complete: 10 minutes

    Objective: In this step, you will execute a script in a command prompt that simulates reading

    three RFID tags. These tags are located on parts that your company has just received from the

    loading dock. As they are scanned, they are placed into inventory to be ready to install into

    assemblies.

    Prerequisites

    Note the following requirements before you begin this step:

    y The ContosoTestProcess process must be running without errors.

    1. Navigate to the folder that contains the tutorial script files.

    2. Use the rfidclientconsole.exe command-line utility to add each RFID tag to the process

    pipeline. The three tags are simulated in three separate XML files. All XML files are read

    from a command-line text file named Tutorial1_Lesson2_Step2.cmd, go to the location in

    the command prompt which has Tutorial1_Lesson2_Step2.cmd and then, run the

    command

    set exe="%RFIDINSTALLDIR%\bin\rfidclientconsole.exe"

    %exe% -m localhost AddEventToProcessPipeline

    ContosoTestProcess PartsTag1.xml mylogicaldevice

    %exe% -m localhost AddEventToProcessPipeline

    ContosoTestProcess PartsTag2.xml mylogicaldevice

    %exe% -m localhost AddEventToProcessPipeline

    ContosoTestProcess PartsTag3.xml mylogicaldevice

    echo "TagReadParts"

    pause

    3. Verify that there are no errors in executing the Tutorial1_Lesson2_Step2.cmd file.

    What did I just do?

    In this step, you executed the Tutorial1_Lesson2_Step2.cmd file that used the

    rfidclientconsole.exe command-line tool to add RFID read events into the event processing

    To receive parts by using the Contoso device simulator

  • 8/7/2019 Tutorial - Supply Chain

    13/31

    13

    pipeline of the ContosoTestProcess process. The SqlServerSink event handler in the pipeline

    stores the event information in the RfidSink database.

    Next StepsIn the next step, Step 3: Query Parts After Receive , you'll learn how to query the RFIDsink

    database to determine if the parts were actually received by the ContosoTestProcess process.

    See Also

    Lesson 2: Receive Parts into Inventory

    Step 1: Query Parts Before Receive

    Step 3: Query Parts After Receive

    Step 4: Assign Received Parts into Inventory

    Step 3: Query Parts After Receive

    Time to complete: 10 minutes

    Objective: In this step, you will query the RFIDsink database to view the tag data stored by the

    SqlServerSink event handler from the ContosoTestProcess process in the preceding step.

    Prerequisites

    Note the following requirements before you begin this step:

    y RFID tags must have been successfully read by the ContosoTestProcess process and

    inserted into the RFIDsink database by using the SqlServerSink event handler.

    y SQL Server Management Studio must be installed and connected to the RFIDsink databaseon the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson2_Step3.sql file):

    SELECT ID AS RowID,

    SinkTime,

    TagID,

    CONVERT(VARCHAR, CONVERT(VARBINARY, TagID)) AS

    TagIDDecoded,

    TagData,

    CONVERT(VARCHAR, CONVERT(VARBINARY, TagData)) AS

    TagDataDecoded

    To query for parts in the RFIDsink database

  • 8/7/2019 Tutorial - Supply Chain

    14/31

    14

    FROM TagEvents

    WHERE TagSource = 'Antenna3'

    AND LEN(CONVERT(VARCHAR, CONVERT(VARBINARY,

    TagData))) = 12

    ORDER BY SinkTime DESC

    4. Verify that three records are returned from this query. If these records do not appear after

    running the query, ensure that you properly ran Step 2: Receive Parts and no errors

    occurred.

    What did I just do?

    In this step, you queried the RFIDsink database to view the RFID tags read by the

    ContosoTestProcess process. These tags will be used in later lessons to build assemblies of the

    parts that were just read.

    When a tag is read by the ContosoTestProcess process, it is read by an antenna called

    Antenna3. The data encoded in the tag represents the Universal Product Code (UPC) that the

    part manufacturer assigned to the part.

    Using the SqlServerSink event handler, tag data is stored in the RFIDsink database as binary

    data. Because the query executed in this step is expected to contain UPC data in the TagData

    field in the TagEvents table, the WHERE clause in the SQL statement converts the datatype of

    this field. First it converts from an image datatype, which is the datatype of the TagData column in

    the TagEvents table, to a varbinary datatype. Then it converts from varbinary to varchar. This

    "double conversion" is done because you cannot convert from an image datatype to a varchar

    datatype directly. After the datatype is a varchar, the length can be tested.

    The preceding query tests that the TagData column contains 12 characters because that is thenumber of characters in a UPC value. If the number of characters in this column is not equal to

    12, it is assumed that this is not one of the tags that was read as part of this tutorial.

    Next Steps

    Receive parts into inventory in Step 4: Assign Received Parts into Inventory.

    See Also

    Lesson 2: Receive Parts into Inventory

    Step 1: Query Parts Before Receive

    Step 2: Receive Parts

    Step 4: Assign Received Parts into Inventory

    Step 4: Assign Received Parts into Inventory

    Time to complete: 10 minutes

  • 8/7/2019 Tutorial - Supply Chain

    15/31

    15

    Objective: In this step, you will copy the data read by the ContosoTestProcess process (which

    uses the SqlServerSink event handler) to the SupplyChain database that you created in Lesson

    1: Set Up the BizTalk RFID Environment, Step 2: Run the Tutorial Setup Scripts. Because it is a

    recommended practice to periodically purge the RFIDsink database, it is not practical to leave the

    RFID tag data in the TagEvents table, so the data is copied to the SupplyChain database, which

    is a permanent data store.

    Prerequisites

    Note the following requirements before you begin this step:

    y The SupplyChain database must already be created.

    y SQL Server Management Studio must be installed and connected to the SupplyChain

    database on the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson2_Step4.sql file):

    USE [SupplyChain]

    GO

    INSERT INTO Parts

    (

    PartID,

    TagID,TagData,

    SinkTime

    )

    SELECT ID,

    CONVERT(VARCHAR, CONVERT(VARBINARY, TagID)),

    CONVERT(VARCHAR, CONVERT(VARBINARY, TagData)),

    SinkTime

    FROM RFIDSink.dbo.TagEvents

    WHERE TagSource = 'Antenna3'

    AND LEN(CONVERT(VARCHAR, CONVERT(VARBINARY,

    TagData))) = 12

    4. Verify that there are no errors after executing the query.

    To insert received parts read by the Contoso device simulator into inventory

  • 8/7/2019 Tutorial - Supply Chain

    16/31

    16

    What did I just do?

    In this step, you inserted the data read by the ContosoTestProcess process into the SupplyChain

    database, which is used to store inventory data for this tutorial

    Next Steps

    In Lesson 3: Create Assemblies from Parts, you will create an assembly for the parts that were

    just received into inventory.

    See Also

    Lesson 2: Receive Parts into Inventory

    Step 1: Query Parts Before Receive

    Step 2: Receive Parts

    Step 3: Query Parts After Receive

    Lesson 3: Create Assemblies from PartsIn Lesson 2: Receive Parts into Inventory, you learned how to use BizTalk RFID to receive parts

    by using the ContosoTestProcess process and insert them into the RFIDsink database. You also

    learned how to move the parts into the SupplyChain database for inventory purposes. Parts in the

    SupplyChain database are stored until they are used to build assemblies of parts that your

    company can ship to customers.

    In this lesson, you will learn how to use the parts that are now in inventory to create assemblies of

    those parts. Using the Contoso device simulator, an RFID tag is printed as part of this lesson to

    be placed on the finished assembly.

    In This Section

    y Step 1: Query Assembled Parts Before Assembly

    y Step 2: Create a New Tag for the Assembly

    y Step 3: Verify the Assembly Tag

    y Step 4: Assign Inventory Parts to Assembly

    y Step 5: Query Assembled Parts After Assembly

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    Lesson 2: Receive Parts into Inventory

    Step 1: Query Assembled Parts Before Assembly

    Time to complete: 10 minutes

  • 8/7/2019 Tutorial - Supply Chain

    17/31

    17

    Objective: In this step, you will query the SupplyChain database (which was created as part of

    this tutorial) to ensure that it contains no assemblies that were previously created from parts

    scanned into inventory. This ensures a clean database with which to run the rest of this tutorial.

    Prerequisites

    Note the following requirements before you begin this step:

    y SQL Server Management Studio must be installed and connected to the SupplyChain

    database on the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson3_Step1.sql file):

    USE [SupplyChain]

    GO

    SELECT COUNT(*)

    FROM [Assembly] a

    JOIN [AssemblyParts] ap

    JOIN [Parts] p

    ON p.PartID = ap.PartID

    ON ap.AssemblyID = a.AssemblyID

    4. Verify that the count of records returned from this query is zero. If you have already

    completed this tutorial and there are assemblies in the database, you can clear the

    RFIDsink and SupplyChain databases by running the Tutorial1_DataReset.sql SQL

    script.

    What did I just do?

    In this step, you verified that there are no assemblies in the SupplyChain database that were

    created from parts read by the ContosoTestProcess process.

    Next Steps

    In Step 2: Create a New Tag for the Assembly, you will assign and print a tag for the new

    assembly, and then you will assign the inventory parts to the new assembly.

    See Also

    Lesson 3: Create Assemblies from Parts

    Step 2: Create a New Tag for the Assembly

    Step 3: Verify the Assembly Tag

    To query for assembled parts in the SupplyChain database

  • 8/7/2019 Tutorial - Supply Chain

    18/31

    18

    Step 4: Assign Inventory Parts to Assembly

    Step 5: Query Assembled Parts After Assembly

    Step 2: Create a New Tag for the AssemblyTime to complete: 10 minutes

    Objective: In this step, you will use the Contoso device simulator to create a tag for a new

    assembly that will consist of multiple inventory parts. Assigning inventory parts to the assembly is

    shown in Lesson 3: Create Assemblies from Parts, Step 4: Assign Inventory Parts to Assembly.

    Prerequisites

    Note the following requirements before you begin this step:

    y The Contoso device simulator must be running without errors.

    1. Navigate to the folder that contains the tutorial script files.

    2. Use the rfidclientconsole.exe command-line tool to print a simulated RFID tag that is

    stored in a separate XML file named AssemblyTag.xml. The XML file is read from a

    command-line text file named Tutorial1_Lesson3_Step2.cmd, as follows:

    set exe="%RFIDINSTALLDIR%\bin\rfidclientconsole.exe"

    %exe% ExecuteCommands ContosoTestDevice AssemblyTag.xml

    echo "Assembly Tag Printed"

    pause

    3. Verify that there are no errors in executing the Tutorial1_Lesson3_Step2.cmd file.

    What did I just do?

    In this step, you executed the Tutorial1_Lesson3_Step2.cmd file. This file used the Contoso

    device simulator to print a new RFID tag that will be used to tag an assembly. The assembly will

    consist of parts that were scanned and placed into inventory in Lesson 2: Receive Parts into

    Inventory and it is created in Step 4: Assign Inventory Parts to Assembly.

    To print the RFID tag, the rfidclientconsole.exe command-line tool was used. The data for the tag

    is stored in an XML file named AssemblyTag.xml. The file was passed into the

    rfidclientconsole.exe command-line tool by using the Tutorial1_Lesson3_Step2.cmd file.

    Next Steps

    In the next step, Step 3: Verify the Assembly Tag, you'll learn how to query the RFIDsink

    database to determine that the assembly print tag was actually generated.

    To create a new tag for the assembly

  • 8/7/2019 Tutorial - Supply Chain

    19/31

    19

    See Also

    Lesson 3: Create Assemblies from Parts

    Step 1: Query Assembled Parts Before Assembly

    Step 3: Verify the Assembly Tag

    Step 4: Assign Inventory Parts to Assembly

    Step 5: Query Assembled Parts After Assembly

    Using the RFID Client Console [RFID11]

    Step 3: Verify the Assembly Tag

    Time to complete: 30 minutes

    Objective: In this step, you will verify that the tag printed in Step 2: Create a New Tag for the

    Assembly by using the Contoso device simulator exists in the RFIDsink database. Using the

    Contoso device simulator, the RFID tag that is printed is stored in the GenericEvents table.The data that you need to look for in the GenericEvents table is stored in the Serialization

    column. This column stores XML data in a text field. Therefore, to verify that the tag is correctly

    printed using the Contoso device simulator from Step 2: Create a New Tag for the Assembly, you

    need to inspect the XML value stored in this column.

    Prerequisites

    Note the following requirements before you begin this step:

    y SQL Server Management Studio is installed and connected to the RFIDsink database on the

    BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson3_Step3.sql file):

    USE [RFIDSink]

    GO

    DECLARE @idoc int

    DECLARE @doc varchar(8000)

    -- Create a cursor that loops through all records

    DECLARE cur CURSOR FAST_FORWARD

    FOR SELECT Serialization

    FROM GenericEvents

    To verify that the assembly tag is printed

  • 8/7/2019 Tutorial - Supply Chain

    20/31

    20

    WHERE ProcessName = 'ContosoTestProcess'

    -- Open the cursor

    OPEN cur

    -- Get the first record

    FETCH NEXT FROM cur INTO @doc

    WHILE @@FETCH_STATUS = 0

    BEGIN

    -- Create an internal representation of the XML document

    - specifying the delcared namespace in the XML doc.

    EXEC sp_xml_preparedocument @idoc OUTPUT, @doc, ''

    -- Execute a SELECT statement that uses the OPENXML

    rowset provider.

    SELECT TagData,

    SupplyChain.dbo.udf_ConvertBase64ToASCII(TagData)

    AS tagDataDecoded,

    TagID,

    SupplyChain.dbo.udf_ConvertBase64ToASCII(TagID) AS

    tagIDDecoded

    FROM OPENXML (@idoc, '//rfid:printLabel/', 2)

    WITH (

    tagData varchar(8000) 'rfid:tagData',

    tagId varchar(100) 'rfid:tagId'

    )

    WHERE tagData IS NOT NULL

    --Remove the XML document from memory

    EXEC sp_xml_removedocument @idoc

    -- Get the first record

  • 8/7/2019 Tutorial - Supply Chain

    21/31

    21

    FETCH NEXT FROM cur INTO @doc

    END

    -- Close and deallocate the cursor

    CLOSE cur

    DEALLOCATE cur

    4. Verify that one record is returned from this query and that the tagDataDecodedfield

    returns a value of 2001. This indicates that the assembly tag was printed correctly.

    Note

    It can be inefficient to use a cursor in an SQL statement. However, this example

    uses a cursor to show you how you could loop through multiple rows, each

    containing an XML field. Such an approach would need to be taken to read anddecode each XML field separately. To make the cursor perform as well as

    possible, two things are shown. First, the cursor is declared as

    FAST_FORWARD, which is a forward-only, read-only cursor. Second, the

    cursor's SELECT statement limits the number of rows returned so that only the

    desired rows are iterated in the cursor.

    What did I just do?

    In this step, you verified that tag data was printed to the Contoso device simulator and was stored

    in the RFIDsink database in the GenericEvents table. To verify the data stored in the

    GenericEvents table, you inspected the XML value stored in the Serialization column. However,to read the values in this column, the following steps had to be taken:

    y Because the Serialization column is a text datatype that contains XML, the

    sp_xml_preparedocumentstored procedure was used to create a SQL Server internal

    representation of the XML document stored in the table. For more information about reading

    XML from a SQL Server database, refer to the SQL Server documentation.

    y The format of the XML data in the Serialization table is based on the XML data that was

    printed to the tag in Step 2: Create a New Tag for the Assembly.

    y The XML format is element-centric, which means that data is stored between elements,

    instead of values being assigned to XML attributes.

    y The TagData and TagID elements in the XML file store Base64-encoded strings. To review

    the actual string data, you need to decode these values. To make it easy to decode thesevalues, a function named udf_ConvertBase64ToStringwas created as part ofStep 2: Run

    the Tutorial Setup Scripts in Lesson 1: Set Up the BizTalk RFID Environment.

    Next Steps

    In Step 4: Assign Inventory Parts to Assembly, you will assign an assembly for which you just

    printed a tag to parts that have already been scanned into inventory.

  • 8/7/2019 Tutorial - Supply Chain

    22/31

    22

    See Also

    Lesson 3: Create Assemblies from Parts

    Step 1: Query Assembled Parts Before Assembly

    Step 2: Create a New Tag for the Assembly

    Step 4: Assign Inventory Parts to Assembly

    Step 5: Query Assembled Parts After Assembly

    Step 4: Assign Inventory Parts to Assembly

    Time to complete: 40 minutes

    Objective: In this step, you will assign the parts that were moved into inventory in Lesson 2:

    Receive Parts into Inventory, Step 4: Assign Received Parts into Inventory to an assembly,

    whose tag was created in Step 2: Create a New Tag for the Assembly.

    This step assigns the assembly to the parts shown in the following table:

    Assembly ID Assembly data Tag ID Tag data (UPC)

    2001 2001 1001 827188021012

    2001 2001 1002 827188021029

    2001 2001 1003 827188021036

    Prerequisites

    Note the following requirements before you begin this step:y The SupplyChain database must already be created.

    y Parts must have been received into inventory in the SupplyChain database.

    y The tag for the new assembly must have been created.

    y SQL Server Management Studio must be installed and connected to the SupplyChain

    database on the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson3_Step4.sql file):

    USE [RFIDSink]

    GO

    DECLARE @idoc int

    To assign inventory parts to assemblies

  • 8/7/2019 Tutorial - Supply Chain

    23/31

    23

    DECLARE @doc varchar(8000)

    DECLARE @SinkTime datetime

    -- Create a cursor that loops through all records

    DECLARE cur CURSOR FAST_FORWARD

    FOR SELECT Serialization,

    SinkTime

    FROM GenericEvents

    WHERE ProcessName = 'ContosoTestProcess'

    -- Open the cursor

    OPEN cur

    -- Get the first record

    FETCH NEXT FROM cur INTO @doc, @SinkTime

    WHILE @@FETCH_STATUS = 0

    BEGIN

    -- Create an internal representation of the XML document

    - specifying the delcared namespace in the XML doc.

    EXEC sp_xml_preparedocument @idoc OUTPUT, @doc, ''

    -- Execute a SELECT statement that uses the OPENXML

    rowset provider.

    -- Add the decoded TagID and TagData fields (decoded from

    Base64 to string)

    INSERT INTO SupplyChain.dbo.[Assembly] (

    TagID,

    TagData,

    SinkTime

    )

    SELECT SupplyChain.dbo.udf_ConvertBase64ToASCII(TagID) AS

    tagIDDecoded,

  • 8/7/2019 Tutorial - Supply Chain

    24/31

    24

    SupplyChain.dbo.udf_ConvertBase64ToASCII(TagData)

    AS tagDataDecoded,

    @SinkTime

    FROM OPENXML (@idoc, '//rfid:printLabel/', 2)

    WITH (

    tagData VARCHAR(8000) 'rfid:tagData',

    tagId VARCHAR(100) 'rfid:tagId'

    )

    WHERE tagData IS NOT NULL

    --Remove the XML document from memory

    EXEC sp_xml_removedocument @idoc

    -- Get the first record

    FETCH NEXT FROM cur INTO @doc, @SinkTime

    END

    -- Close and deallocate the cursor

    CLOSE cur

    DEALLOCATE cur

    -- NOTE: At this point, all Assembly Tag IDs from the decoded

    XML file are in the Assembly table

    USE [SupplyChain]

    GO

    -- Using the applicable IDs, assign parts with Tag ID 1001 -

    1003 to Assembly with Tag ID 2001

    INSERT INTO SupplyChain.dbo.AssemblyParts(

    AssemblyID,

    PartID

    )

    SELECT a.AssemblyID,

  • 8/7/2019 Tutorial - Supply Chain

    25/31

    25

    p.PartID

    FROM [Assembly] a

    CROSS JOIN Parts p

    WHERE a.TagID = '2001'

    AND p.TagID IN ('1001', '1002', '1003')

    4. Verify that there are no errors when executing the SQL script.

    What did I just do?

    In this step, you executed a SQL script that performed numerous actions, which can be broken up

    as follows:

    y As you learned in Step 3: Verify the Assembly Tag, the XML data stored in the

    GenericEvents table of the RFIDsink database can be queried to retrieve the tag ID and tagdata for tags that are printed to the Contoso device simulator.

    y The tags stored in the GenericEvents table are queried using a cursor that enables you to

    iterate through each tag to query the XML field. This example expects a single tag to be

    stored in the database, so it is not necessary to use a cursor for this example. However, it is

    included here to show how you would read multiple tags from the database.

    y As each assembly tag is retrieved from the GenericEvents table, the TagID, TagData, and

    SinkTime fields are inserted into the Assembly table in the SupplyChain database. The

    Assembly table is used to store all assemblies that are generated (printed) using the Contoso

    device simulator.

    y The Parts and Assembly tables are queried to return the IDs of each. These IDs are

    independent of the TagIDs read by the Contoso device simulator. The PartID andAssemblyID columns are SQL Server identity fields that auto-increment each time a row is

    added to the table.

    y A SQL Server cross join is performed to return all possible combinations of PartID and

    AssemblyID and insert it into the AssemblyParts table.

    Next Steps

    In Step 5: Query Assembled Parts After Assembly you will query the Assembly, Parts, and

    AssemblyParts tables in the SupplyChain database to ensure that parts were correctly assigned

    to assemblies.

    See Also

    Lesson 3: Create Assemblies from Parts

    Step 1: Query Assembled Parts Before Assembly

    Step 2: Create a New Tag for the Assembly

    Step 3: Verify the Assembly Tag

  • 8/7/2019 Tutorial - Supply Chain

    26/31

    26

    Step 5: Query Assembled Parts After Assembly

    Step 5: Query Assembled Parts After Assembly

    Time to complete: 15 minutes

    Objective: In this step, you will verify that parts that have been received and placed into

    inventory have been correctly assigned to an assembly. The assembly tag is printed in Step 2:

    Create a New Tag for the Assembly and verified in Step 3: Verify the Assembly Tag.

    Prerequisites

    Note the following requirements before you begin this step:

    y The SupplyChain database must already be created.

    y Parts must have been read and placed into inventory.

    y SQL Server Management Studio must be installed and connected to the SupplyChain

    database on the BizTalk RFID computer.

    1. Open SQL Server Management Studio.

    2. Open a new query window.

    3. Execute the following query (which can be found in the Tutorial1_Lesson3_Step5.sql file):

    USE [SupplyChain]

    GO

    SELECT

    a.TagID AS AssemblyTagID,

    a.TagData AS AssemblyTagData,

    p.TagID AS PartsTagID,

    p.TagData AS PartsTagData

    FROM [Assembly] a

    JOIN [AssemblyParts] ap

    JOIN [Parts] p

    ON p.PartID = ap.PartID

    ON ap.AssemblyID = a.AssemblyID4. Verify that three records are returned, one for each part assigned to an assembly.

    What did I just do?

    In this step, you queried the Assembly, Parts, and AssemblyParts tables in the SupplyChain

    database to verify that each inventoried part is now assigned to an assembly.

    To query for assemblies and parts in the SupplyChain database

  • 8/7/2019 Tutorial - Supply Chain

    27/31

    27

    Next Steps

    Lesson 4: Decommission a Tag That Fails Quality Assurance shows how to assign all assemblies

    to a carton for shipping.

    See Also

    Lesson 3: Create Assemblies from Parts

    Step 1: Query Assembled Parts Before Assembly

    Step 2: Create a New Tag for the Assembly

    Step 3: Verify the Assembly Tag

    Step 4: Assign Inventory Parts to Assembly

    Lesson 4: Decommission a Tag That Fails Quality

    AssuranceIn Lesson 3: Create Assemblies from Parts, you learned how to use BizTalk RFID to print an

    RFID tag for an assembly of parts by using the Contoso device simulator. The RFID tag was then

    used to group individual parts that were received into inventory into an assembly. In this lesson,

    you will learn how to decommission a tag after simulating that the assembly failed a quality

    assurance (QA) check.

    In practice, manufacturing companies will usually have automated testing equipment in place to

    run a series of QA checks. If the tests pass the checks, the assembly is permitted to be put into

    stock/inventory, shipped to a customer, or some other use. If the tests fail the checks, a separate

    process would take place to troubleshoot, repair, replace, or discard the assembly. This scenario

    assumes that the item is to be discarded and the assembly tag must be decommissioned so thatit contains no data.

    In This Section

    y Step 1: Verify That the Tag Exists

    y Step 2: Decommission the Tag

    y Step 3: Verify the Decommissioned Tag

    See Also

    Lesson 1: Set Up the BizTalk RFID Environment

    Lesson 2: Receive Parts into Inventory

    Lesson 3: Create Assemblies from Parts

    Step 1: Verify That the Tag Exists

    Time to complete: 10 minutes

  • 8/7/2019 Tutorial - Supply Chain

    28/31

    28

    Objective: In this step, you will verify that the assembly tag with a TagID ASCII value of "2001"

    (after converting the Base64 string value of "MTAwMQ==") exists before decommissioning it in

    the next step.

    Prerequisites

    Note the following requirements before you begin this step:

    y None

    1. Navigate to the folder that contains the tutorial script files.

    2. Use the rfidclientconsole.exe tool. The command to verify an RFID tag and view its

    metadata by using this tool is GetTagMetadataCommand. This command is specified in

    an XML file named TagMetadata.xml. This file is run using a command-line text file

    named Tutorial1_Lesson4_Step1.cmd, as follows:

    set exe="%RFIDINSTALLDIR%\bin\rfidclientconsole.exe"

    %exe% ExecuteCommands ContosoTestDevice TagMetadata.xml

    echo "Tag Metadata Returned"

    pause

    3. Verify that there are no errors in executing the Tutorial1_Lesson4_Step1.cmd file. If the

    RFID tag exists, you should see XML metadata output similar to the following:

    512

    true

    true

    true

    Contoso

    EPC Class 1 - Generation 2 tag

    3

    To verify if a tag exists

  • 8/7/2019 Tutorial - Supply Chain

    29/31

    29

    1024

    What did I just do?

    In this step, you executed the Tutorial1_Lesson4_Step1.cmd file. This file issues a

    GetTagMetadataCommandcommand to the rfidclientconsole.exe command-line tool to query

    the metadata stored in BizTalk RFID. If there are no errors, the metadata is returned in an XML

    format.

    Next Steps

    In the next step, Step 2: Decommission the Tag, you'll learn how to decommission the tag thatyou just verified in this step.

    See Also

    Lesson 4: Decommission a Tag That Fails Quality Assurance

    Step 2: Decommission the Tag

    Step 3: Verify the Decommissioned Tag

    Step 2: Decommission the Tag

    Time to complete: 10 minutes

    Objective: In this step, you will use the Contoso device simulator to decommission a tag for an

    assembly that failed a simulated QA check.

    Prerequisites

    Note the following requirements before you begin this step:

    y The Contoso device simulator must be running without errors.

    y You must have followed the prior lessons to ensure that an assembly tag is printed and

    stored in the RFIDsink database. Otherwise, the operation of decommissioning the tag will

    fail.

    1. Navigate to the folder that contains the tutorial script files.

    2. Use the Contoso device simulator to decommission the assembly tag that was printed in

    Lesson 3: Create Assemblies from Parts, Step 2: Create a New Tag for the Assembly.

    The assembly tag with the TagID ASCII value of "2001" (Base64 string value of

    "MTAwMQ==") is the one to be decommissioned. The command for decommissioning a

    To decommission a tag

  • 8/7/2019 Tutorial - Supply Chain

    30/31

    30

    tag by using the rfidclientconsole.exe tool is KillCommand. This command is specified in

    an XML file, along with the parameters required to kill the tag, such as the TagID. The

    XML file, named AssemblyKillTag.xml, is wrapped in a command-line text file named

    Tutorial1_Lesson4_Step2.cmd, as follows:

    set exe="%RFIDINSTALLDIR%\bin\rfidclientconsole.exe"

    %exe% ExecuteCommands ContosoTestDevice AssemblyKillTag.xml

    echo "Assembly Tag Decommissioned"

    pause

    3. Verify that there are no errors in executing the Tutorial1_Lesson4_Step1.cmd file.

    What did I just do?

    In this step, you executed the Tutorial1_Lesson4_Step2.cmd file. This file used the Contoso

    device simulator to kill (or decommission) the assembly tag that was printed in Lesson 3: Create

    Assemblies from Parts, Step 2: Create a New Tag for the Assembly. To kill the RFID tag, the

    rfidclientconsole.exe command-line tool was used. The data for the tag is stored in an XML file,

    named AssemblyKillTag.xml.

    Next Steps

    In the next step, Step 3: Verify the Decommissioned Tag, you'll learn how to query the RFIDsinkdatabase to verify that the tag was actually decommissioned.

    See Also

    Lesson 4: Decommission a Tag That Fails Quality Assurance

    Step 1: Verify That the Tag Exists

    Step 3: Verify the Decommissioned Tag

    Step 3: Verify the Decommissioned Tag

    Time to complete: 10 minutes

    Objective: In this step, you will verify that the assembly tag with a TagID ASCII value of "2001"

    (after converting the Base64 string value of " MTAwMQ==") was actually decommissioned. The

    procedure in this step is virtually the same as in Step 1: Verify That the Tag Exists, but the output

    you are looking for is different.

  • 8/7/2019 Tutorial - Supply Chain

    31/31

    31

    Prerequisites

    Note the following requirements before you begin this step:

    y None

    1. Navigate to the folder that contains the tutorial script files.

    2. Use the rfidclientconsole.exe tool. The command to verify an RFID tag and view its

    metadata by using this tool is GetTagMetadataCommand. This command is specified in

    an XML file named TagMetadata.xml. This file is run by using a command-line text file

    named Tutorial1_Lesson4_Step3.cmd, as follows:

    set exe="%RFIDINSTALLDIR%\bin\rfidclientconsole.exe"

    %exe% ExecuteCommands ContosoTestDevice TagMetadata.xml

    echo "Tag Metadata Returned"

    pause

    3. Verify that your output contains the following XML element:

    Tag Killed...

    What did I just do?

    In this step, you executed the Tutorial1_Lesson4_Step3.cmd file. This file issues a

    GetTagMetadataCommandcommand to the rfidclientconsole.exe command-line tool to query

    the metadata stored in BizTalk RFID. If a element is returned with a value of "Tag

    Killed" then the tag was decommissioned and cannot be used again.

    See Also

    Lesson 4: Decommission a Tag That Fails Quality Assurance

    Step 1: Verify That the Tag Exists

    Step 2: Decommission the Tag

    To verify if a tag was decommissioned