Click here to Skip to main content
12,299,731 members (58,263 online)
Click here to Skip to main content
Add your own
alternative version

Stats

68.3K views
615 downloads
29 bookmarked
Posted

Creating an Automated Purchase Order Workflow Using BizTalk Server 2004

, 30 Apr 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article explains the various aspects of creating an automated Purchase Order Workflow system using BizTalk Server 2004.

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 be sent to the procurement department. Let's 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 POs 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 Send Port 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 are bound directly to the message box, and hence 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 "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 Receive Port and Send Port are bound directly to the message box and hence automatically triggers a Manager/Clerk Orchestration.

Manager - Business Process

Manager

This Orchestration sets the POStatus of the incoming message from "LEVEL_2" to "LEVEL_0", or "APPROVED", or "REJECTED". The manager checks several conditions and updates the POStatus property accordingly. If the POAmount value exceeds $5000, POStatus is 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. POComments is left as blank so as to route the message back to the Clerk from the Supervisor. The value of POAmount is more than $1000, which enables the message to flow into the Manager Orchestration. The POQty value is greater than 100. This will again send the message back to the "Clerk", and then to "Supervisor", and finally get it 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 is 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 independently 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 as 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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Naveen Karamchetti
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.

Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

You may also be interested in...

Comments and Discussions

 
GeneralDoubt Clarification Pin
ravikumar198327-Mar-10 19:17
memberravikumar198327-Mar-10 19:17 
GeneralNICE Pin
The_Myth22-Mar-06 2:48
memberThe_Myth22-Mar-06 2:48 
GeneralRe: NICE Pin
Naveen Karamchetti22-Mar-06 2:56
memberNaveen Karamchetti22-Mar-06 2:56 
GeneralRe: Pin
rampalbarma27-Apr-06 5:13
memberrampalbarma27-Apr-06 5:13 
GeneralRe: Pin
Naveen Karamchetti27-Apr-06 8:25
memberNaveen Karamchetti27-Apr-06 8:25 
GeneralRe: Pin
pragmastig23-Mar-07 4:01
memberpragmastig23-Mar-07 4:01 
GeneralRe: Pin
Chenue23-May-06 0:37
memberChenue23-May-06 0:37 
GeneralRe: Pin
rajasekhar.bathula20-Feb-08 9:52
memberrajasekhar.bathula20-Feb-08 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 1 May 2006
Article Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid