![]() |
Enterprise Systems »
Microsoft BizTalk Server »
General
Intermediate
Creating an Automated Purchase Order Workflow using BizTalk Server 2004By Naveen KaramchettiThis article explains the various aspects of creating a automated Purchase Order Workflow system using BizTalk Server 2004. |
C#, Windows, .NET, Visual Studio, Dev
|
||||||||||
|
Advanced Search |
|
|
|
||||||||||||||||
This article shows how BizTalk can be used to Automate workflows which do not require Human intervention. A Message can be routed to various users, based just on business logic. This is similar to a state machine wherein a system moves through several states/stages based on external inputs/stimuli. For user oriented workflows, BizTalk Human Workflow Services (HWS) can be used.
Consider a scenario where a Purchase Order (PO) request needs to be approved by various people in an organization, before it can sent to the procurement department. Lets consider three roles in an organization, where the PO Workflow happens. A Clerk, Supervisor and a Manager.

| PO Status | Explanation |
| CREATE | This is the initial state of a PO, which is processed by the Clerk. This state is changed to LEVEL_0 and is sent to the CLERK. |
| LEVEL_0 | Only the PO's with this PO status is processed by the Clerk. The Clerk changes the status to LEVEL_1. |
| LEVEL_1 | A Supervisor processes a PO with status "LEVEL_1". A Supervisor can set the status of the PO to either "LEVEL_0" or "LEVEL_2" or "APPROVED" or "REJECTED". |
| LEVEL_2 | A Manager processes a PO with status "LEVEL_2". A Manager can set the status of the PO to either "LEVEL_0" or "APPROVED" or "REJECTED". |
| APPROVED | This is the final status of the PO. This can be set either by a Manager or a Supervisor. |
| REJECTED | This is the final status of the PO. This can be set either by a Manager or a Supervisor. |

The PO schema has the following elements
This Orchestration sets the status of the incoming message from "CREATE" to "LEVEL_0". The SendPort is bound directly to the message box and hence it automatically triggers a Clerk Orchestration which is filtered on "LEVEL_0" status messages.

This Orchestration sets the POStatus of the incoming message from "LEVEL_0" to "LEVEL_1". It checks the POAuthorize field of the message, and if it is "SUPERVISOR", it fills in the POComments property.
POOut = POIn; POOut(POWorkflow.PropertySchema.POStatus) = "LEVEL_1"; POOut(POWorkflow.PropertySchema.POAuthorize) = "CLERK"; POOut(POWorkflow.PropertySchema.POComments) = "Supervisor! Please approve this PO.";
If the POAuthorize field contains "MANAGER", then the POQty field is set to "99". The reason being, a manager will not approve a PO with a POQty value of "100".
POOut = POIn; POOut(POWorkflow.PropertySchema.POStatus) = "LEVEL_1"; POOut(POWorkflow.PropertySchema.POAuthorize) = "CLERK"; // The quantity is set 99, so as to get Approval from Manager. POOut(POWorkflow.PropertySchema.POQty) = 99; POOut(POWorkflow.PropertySchema.POComments) = "The quantity is set 99, so as to get Approval from Manager";
The Receive Port and Send Port is bound directly to the message box and hence it automatically triggers a Supervisor orchestration which is filtered on "LEVEL_1" status messages.

This Orchestration sets the POStatus of the incoming message from "LEVEL_1" to either "LEVEL_2" or "APPROVED" or "REJECTED". The supervisor checks several conditions and updates the POStatus property accordingly.
POOut = POIn; // Send the message to Manager for Approval. POOut(POWorkflow.PropertySchema.POStatus) = "LEVEL_2"; POOut(POWorkflow.PropertySchema.POAuthorize) = "SUPERVISOR"; POOut(POWorkflow.PropertySchema.POComments) = "Manager, please approve this PO.";
The ReceivePort and SendPort is bound directly to the message box and hence it automatically triggers a Manager/Clerk Orchestration.

This Orchestration sets the POStatus of the incoming message from "LEVEL_2" to either "LEVEL_0" or "APPROVED" or "REJECTED". The manager checks several conditions and updates the POStatus property accordingly. If the POAmount value exceeds $5000, the POStatusis set to "REJECTED".
POOut = POIn; POOut(POWorkflow.PropertySchema.POStatus) = "REJECTED"; POOut(POWorkflow.PropertySchema.POAuthorize) = "MANAGER"; POOut(POWorkflow.PropertySchema.POComments) = "Rejected due to cost overrun.";
The "Filter Expression" property in the "Receive" shape in every orchestration ensures that only messages which are intended to be processed arrive in the orchestration.
Clerk Orchestration - Filter Expression
(POWorkflow.PropertySchema.POStatus == "LEVEL_0")
Supervisor Orchestration - Filter Expression
(POWorkflow.PropertySchema.POStatus == "LEVEL_1")
Manager Orchestration - Filter Expression
(POWorkflow.PropertySchema.POStatus == "LEVEL_2")

Notice the input file data. The POComments is left as blank, so as to route the message back to Clerk from Supervisor. The value of POAmount is more than $1000, which enables the message to flow into Manager Orchestration. The POQty value is greater than 100. This will again send the message back to "CLERK" and then again to "SUPERVISOR" and finally get approved by the "MANAGER". This data in the input file covers most of the flows.

The Event Viewer shows the various logged messages during the routing of the POMessage for the scenario just described.

Notice the Send and Receive Ports in the BizTalk Explorer.

The final approved output file generated after the "MANAGER" approves the POMessage.
C:\ drive.
KeyAndBindings contains the Bindings.xml file, which can be imported after the solution is built and deployed.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 30 Apr 2006 Editor: |
Copyright 2006 by Naveen Karamchetti Everything else Copyright © CodeProject, 1999-2009 Web12 | Advertise on the Code Project |