You are on page 1of 19

Advanced Features in SAP Workflow from version 6.

40
Exception Handling in Workflow
SWITCH in "Multi-condition" step
Demo on "Local Workflow"

Exception Handling in SAP Business Workflow

From the release of SAPNW04 version, SAPhas introduced many new features among which exception
handling is one.
Exception handling is done in workflow using Blocks (TRY-CATCH mechanism). Blocks is one of the new
features introduced from NW04 version.
This document details about the usage of Blocks and the approach to trigger and handle the exceptions.
Pre-requisites
It is assumed that the reader of this article has some knowledge in SAPworkflow and has worked with the
steps Mail, Process control earlier.
Overview of Blocks
Blocks could be treated as folders combining a group of dependent work items. They are shown as
folders in the workflow log.
Each block would have start and end nodes.
Blocks can be deadline monitored (only Latest End)
Blocks can catch exceptions
Following are the screenshots representing how a Block appears in the workflow definition and in the
workflow log:

Fig: Appearance of Block in the Workflow definition.

Fig: Appearance of Block in the Workflow log
A Block is completed only if the dependent work items are complete or in the final state. If a Block is
cancelled, all its dependent work items are cancelled.
Each Block can have its own container elements. All the parent container elements are visible within the
Block.
Defining a Block
Start a new workflow definition using the transaction SWDD
Double-click on the Undefined step and select Block.

Enter the step name and leave the block type as Standard. Press Enter. The workflow definition
would be appearing as follows:

All the dependent steps could be defined with in the Block start and Block end.


As mentioned earlier, Blocks can handle exceptions. If an exception is caught, everything inside the block is
cancelled. If exception is not caught, process is set to an ERROR state (This could be compared to TRY-
CATCH in ABAP
TM
programs. If the exception is not caught, program results in dump)
Create a new workflow and define a new step Block as mentioned earlier page.
In the Block step, click on the tab Exceptions and make an entry of a new exception, for e.g.,
Dummy_Excep, which would be raised in the workflow definition.

Activate the exception defined above, by clicking on the button left to the exception name
Go back to the main screen. Two branches would be appearing between the block begin and block
end, as shown below. Exception branch is taken whenever the exception, Dummy_Excep, is triggered.

Exceptions are triggered using the step Process Control. Define a new step Process Control in the
normal branch. Enter the step name and the outcome name. Select Throw Exception in the function.
In the event name, select the exception name defined earlier (see the screenshot below).

Uncheck Step not in workflow log if you would like to see this step in the workflow log.
Define a mail step in the exception branch of the block (for testing purpose to ensure that this
exception branch is taken, when the exception is triggered). The execution flow of the exception
handling is shown below:



SWITCH in multiple condition

SAPhas introduced new features in Business Workflow in the releases 6.20, NW04 and NW04s.
This Tutorial introduces you to a new feature SWITCH provided in the step Multiple Condition of SAP
Workflow. It is assumed that the reader of this Tutorial has already some knowledge in Business Workflow and
has worked on Multiple Condition step earlier.
The SWITCH feature in the step Multiple Condition is provided from the release NW04. The only feature
available before NW04 with this step is CASE. In the case of CASE, the workflow system checks the value
of the basis of comparison against the defined comparison values (as shown below).

In SWITCH, each branch of it carries a condition definition. We can visualize Multiple Condition with SWITCH
as a group of Condition steps.
Small scenario using Multiple Condition with SWITCH is shown below:
Create a new workflow definition with a container element CARRID (Well known example for training
purposes).

Set the Properties as import.
Double click on the undefined step to create a step Multiple Condition. Following screen appears:

Select the Switch option in the Type field.



Different types of conditions can be defined for each Outcome. Please note that:
The conditions are defined in the given order.
The first branch whose condition is evaluated TRUE is considered.
If none of the condition is TRUE, a default branch is taken (Other values in the definition).
Following are the conditions used in our example:

The workflow definition would appear as follows:

Insert an email step for each branch and check the output for various Carrid values.

Understanding"LocalWorkflow"

In this tutorial, we would explain creating and working with a local workflow.
Go to Transaction SWDD. Create a new workflow definition.

Go to Basic data (hat symbol) as shown in above screenshot.

Fill-in the Abbreviation and Description and click on the tab Version-Dependent (Current Workflow
Version).

Enter a name for a local event.

Go back to the main screen and create a new step.

Select the step Event Creator. Provide the Step Name and Outcome Name. Also select Trigger Local
Event in the Event Creator.

Enter the name of the event we defined earlier.



Go back to the main screen and create a new step (See the screenshot below)

Select the step Local Workflow


In the screen shown below, enter the step name and also event name we created earlier.

Go back to the main screen. In the local workflow definition, right click and click on Create.

Create a new step Mail.

Go back to the main screen. The workflow definition would look as follows:

Activate your workflow and test your workflow definition. You might not be able to find the email in your
SAP inbox. Follow is the screenshot from the workflow log.

When the main workflow is ended, the local workflow would automatically end with a status Logically
deleted. The workflow would continue further after the step Event creator without waiting for the local
workflow to complete.
So let us create a step User Decision after the step Event Creator in the workflow definition.


Activate and test run your workflow definition. You would now observe an email and also work item
regarding the user decision step in your SAP Inbox (see the screenshot below)

You might also like