转 Raising exceptions in a method and handling the same in the workflow

Raising exceptions in a method and handling the same in the workflow

By Suresh Kumar Parvathaneni, from link.

This document details the procedure in defining exceptions in a method and using the same in a workflow. 
Let us first look at raising exceptions in a method: 

Go to Business Object Builder (Transaction SWO1). 

Create a business object. 
转 Raising exceptions in a method and handling the same in the workflow 

Now create a method.

转 Raising exceptions in a method and handling the same in the workflow 

Now select the method you have created and click on button “Exceptions” available on the toolbar.

Following screen appears:

 

Now click on Create. Following popup screen appears: 

转 Raising exceptions in a method and handling the same in the workflow 

Enter the information as shown above. The error type “Temporary error” is chosen in the case wherein the record is locked by somebody else or some required resource is not available. The error type “Application Error” is to be chosen when there is no authorization for the document you are processing. The error type “System error” is to be chosen if there are no values passed for the mandatory parameters. 

Click on continue.

转 Raising exceptions in a method and handling the same in the workflow

Go back to the main screen.

Now in the method, provide the following code:

 

Save the business object and release the same. 

转 Raising exceptions in a method and handling the same in the workflow 

Try executing the method by clicking on Test/Execute (F8). The exception would be raised as shown below: 

转 Raising exceptions in a method and handling the same in the workflow 

Capturing the exception raised by the method in the workflow: 

Go to Workflow Builder (TCode: SWO1). 

Create the step “Activity”

转 Raising exceptions in a method and handling the same in the workflow 

Create a task and provide the following details in the new task: 

转 Raising exceptions in a method and handling the same in the workflow 

Save your entries and return to the previous screen. 

转 Raising exceptions in a method and handling the same in the workflow 

Click on “Outcomes” tab. Here you can observe the exception you defined in your method:

转 Raising exceptions in a method and handling the same in the workflow 

As observed in the observe screen, the outcome is not active by default. If we do not handle the exception, the work item might go into the error status. Activate the outcome:

转 Raising exceptions in a method and handling the same in the workflow

Save your entries and go back to the main screen of Workflow builder. Please ensure that you have done the agent assignment for this task. 

转 Raising exceptions in a method and handling the same in the workflow 

You can now observe a new branch when the exception is raised. You can define your steps whenever the exception is raised. 

References:

http://help.sap.com/saphelp_nw04s/helpdata/en/c5/e4ad98453d11d189430000e829fbbd/frameset.htm

你可能感兴趣的:(exception)