Show TOC Start of Content Area

Procedure documentation Handling Exceptions  Locate the document in its SAP Library structure

Use

You create an exception in the service component, include it in your custom operation, and define its function by adding the Java code that throws the exception. It is usual to also create an exception message.

Prerequisites

You have created:

      A Mobile Service Component

More information: Creating a Mobile Service Component

      A custom operation, to which you want to add one or more exceptions

More information: Creating a Custom Operation

Procedure

1. Create an Exception

…...

       1.      In the Service Explorer, select the Exceptions node under your service component.

       2.      From the context menu, choose Create Exception.

       3.      In the Create Exception dialog box, enter an Exception Name.

       4.      Enter a Description (recommended).

       5.      Repeat the steps above to create additional exceptions.

2. Include the Exception in Your Operation

…...

       1.      Open the Custom Operation Designer for your custom operation.

       2.      Select the Exceptions from the dropdown list.

Alternatively, you can drag the exceptions into the Exceptions field from the data tree.

       3.      Repeat the steps above to include additional exceptions.

3. Insert the Java Code for Your Exception

…...

       1.      Select your service under the Services node containing your operation.

       2.      In the context menu of the service, choose Open with Java Editor.

Alternatively, you can Open with Service Editor and Java Editor and the <service>.java tab page).

       3.      In the Java Editor, enter the appropriate code for your exception under the appropriate method.

You can now implement the operation’s implementations between the tags //@@begin implementation and //@@end. The generation ensures that any code between those tags will always be preserved, even if the operation’s signature is changed.

4. Add a Message for Your Exception (Optional)

...

       1.      Double-click the Message Pool node.

Alternatively, press F3, or in the Message Pool context menu, choose Open.

       2.      In the Resource Text tab page, click Add to add a new resource.

       3.      In the New Resource dialog window, choose errorMessage as the Resource Type.

       4.      Enter a Resource Name.

Use an ID for the exception, such as InvalidEmployyeNameID.

       5.      Enter a Text.

Use a text targeted for the user, such as Employee ID is not valid!

The created resource appears in the table of the *appmessages.xlf tab page.

       6.      Save your data.

Note

By using the message pool, you can ensure internationalization of your application.

More information: Internationalization of Web Dynpro Projects

 

End of Content Area