Click here to Skip to main content
6,295,667 members and growing! (12,504 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Intermediate

Creating an Automated Purchase Order Workflow using BizTalk Server 2004

By Naveen Karamchetti

This article explains the various aspects of creating a automated Purchase Order Workflow system using BizTalk Server 2004.
C#, Windows, .NET, Visual Studio, Dev
Posted:22 Mar 2006
Updated:30 Apr 2006
Views:37,231
Bookmarked:20 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
11 votes for this article.
Popularity: 2.82 Rating: 2.70 out of 5
4 votes, 36.4%
1
1 vote, 9.1%
2

3
1 vote, 9.1%
4
5 votes, 45.5%
5

Introduction

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.

Purchase Order (PO) - Workflow

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.

  • Clerk - Processes a PO request and sends it to the Supervisor for Approval.
  • Supervisor - If a Supervisor does not have enough rights to Approve a PO, the PO is sent to the Manager. A Supervisor may also send back a PO, to the Clerk for corrections.
  • Manager - The Manager Approves or Rejects a PO based on certain rules. He may also send back a PO, to the Clerk.

Various <STATES> in the PO Workflow

POWorkflow

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 Purchase Order (PO) - Schema

POSchema

The PO schema has the following elements

  • PONum - This field is used to set the Purchase Order number.
  • POAmount - This field is used to set the Purchase Order value.
  • POStatus - This field is used to set the Status of the PO.
  • PODate - This field is used to set the date on which the PO was created.
  • POQty - This field is used to set the total quantity in the PO request.
  • POAuthorize - The role (CLERK, SUPERVISOR or MANAGER) of the person who authorized the PO request.
  • POComments - This field is used to set the comments by various parties in the workflow.

The Purchase Order Workflow - Orchestrations

"CREATE" message - Business Process

CreateMessage

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.

Clerk - Business Process

Clerk

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.

Supervisor - Business Process

Supervisor

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.

Manager - Business Process

Manager

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

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")

Executing the DEMO

Input File

InputXML

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.

Event Viewer

evtvwr

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

BizTalk Explorer

BizTalkExplorer

Notice the Send and Receive Ports in the BizTalk Explorer.

Output File

OutputXML

The final approved output file generated after the "MANAGER" approves the POMessage.

About the Downloadable Code

  • Unzip the file with the folder names in the C:\ drive.
  • The folder KeyAndBindings contains the Bindings.xml file, which can be imported after the solution is built and deployed.
  • Place the POMessage in the In folder and observe the Event log to find out where the message is getting routed to.

Some Takeaways

  1. Using BizTalk workflows can be automated extensively. The example shown can be extended and customized. All the business rules can be placed in a separate DLL and placed in the GAC. This DLL can be updated independenty of the Orchestration.
  2. This article has demonstrated how a workflow can be automated using Message routing. More complex scenarios can be implemented using BizTalk.
  3. The PO approval logic of the Manager, Supervisor and the Clerk can be moved into a .NET component which can include several processing rules instead of just simple ones. This example can act a Proof-Of-Concept for complex scenarios, it also demonstrates the power of "DIRECT" message box binding.
  4. In the case of a decision to be made by Human, InfoPath can be used to display the XML documents and messages would need to be placed in a shared folder.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Naveen Karamchetti


Member
Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 8.5 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.
Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
GeneralNICE PinmemberThe_Myth3:48 22 Mar '06  
GeneralRe: NICE PinmemberNaveen Karamchetti3:56 22 Mar '06  
GeneralRe: Pinmemberrampalbarma6:13 27 Apr '06  
GeneralRe: PinmemberNaveen Karamchetti9:25 27 Apr '06  
GeneralRe: Pinmemberpragmastig5:01 23 Mar '07  
GeneralRe: PinmemberChenue1:37 23 May '06  
GeneralRe: Pinmemberrajasekhar.bathula10:52 20 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin 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