Show TOC Start of Content Area

Procedure documentation Implementing Exception Handling  Locate the document in its SAP Library structure

Use

In a Guided Procedures (GP) process you can create actions that handle exceptions raised by callable object execution. Additionally, you can choose a strategy to repeat or skip the activity that caused the exception.  

Prerequisites

      You have instantiated the IGPDesigntimeUpdateManager.

See Instantiating the Design Time Manager.

      You have familiarized yourself with the implementation of development objects with the GP design time API.

See Creating GP Development Objects.

      You have created a block.

See Creating Blocks.

Procedure

...

       1.      Create a callable object and define an exception for it.

Note

To define result states, exceptions and other configuration parameters, use the IGPPhysicalCallableObject associated with the callable object. The physical callable object stores technical information about the object that should be invoked during action execution.

Example

Creating a Callable Object with Process Exception

import com.sap.caf.eu.gp.co.api.IGPCallableObject;

import com.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager;

import com.sap.caf.eu.gp.co.api.IGPPhysicalCallableObject;

 

// create a callable object

IGPCallableObject co = manager.createCallableObject(

            coType,

            locale,

            coTitle,

            coDescription,

            cat.getID()

            );

// retrieve the physical callable object

IGPPhysicalCallableObject pco = co.resolvePhysicalCallableObject();

// define one process exception "e"

pco.addProcessException("e", "E");

// save and activate the object

manager.save(co);

manager.activate(co);

 

For more information on how to create callable objects, see Creating Callable Objects.

       2.      Insert the callable object into an action and add the action to the block structure.

Example

Inserting the Callable Object into Action and Block

import com.sap.caf.eu.gp.process.api.IGPModifiableAction;
import com.sap.caf.eu.gp.process.api.IGPModifiableBlock;
 

// set execute callable object co to action a_2

a_2.setExecuteCallableObject(co);

manager.save(a_2);

 

// add a_2 to the block structure

b.getModifiableStructure().addItem(a_2);

 

For more information on how to create actions, see Creating Actions.

       3.      Create an exception handling action.

During process execution, the callable object that you created may raise a process exception. You need a mechanism to handle this exception. For this purpose you create an additional action, which determines the processing strategy and informs the user about possible problems.

This action is executed whenever such an exception is raised. Its implementation is standard:

Example

Creating an Exception Handling Action

//define action for the exception handler

IGPModifiableAction ae = manager.createAction(

                                      locale,

                                      "ae",

                                      "ae description",

                                      cat.getID()

                                      );

// save and activate the action

manager.save(ae);

manager.activate(ae);

  

       4.      Assign the exception handling action to the block structure item corresponding to the action with the process exception.

Note

All activities added to a block structure are represented by block structure items (IGPModifiableBlockStructureItem). Items hold information about result state transitions, exception handling and parameter mapping.

Example

Setting the Exception Handler

import com.sap.caf.eu.gp.process.api.IGPModifiableBlockStructureItem;

import com.sap.caf.eu.gp.process.api.GPExceptionHandlingStrategy;

 

// retrieve block structure item of action a_2

IGPModifiableBlockStructureItem ia_2 = b.getModifiableStructure().getModifiableItem(1);

 

// create exception handler on ia_2

ia_2.setExceptionHandler("e", GPExceptionHandlingStrategy.STRATEGY_CONTINUE, ae);

 

The example above also specifies the processing strategy after the exception handling action has been executed. The strategies you can choose from are:

       STRATEGY_CONTINUE – process flow continues with the next item in the structure

       STRATEGY_REPEAT – process flow repeats the item that caused the exception

End of Content Area