Show TOC Start of Content Area

Procedure documentation Implementing the cancelBooking() Method  Locate the document in its SAP Library structure

 

The cancelBooking method sets the status of a booking to CANCELLED. If an error occurs, the method throws a QuickCarRentalException.

Prerequisites

This graphic is explained in the accompanying text

You have opened the bean class QuickOrderProcessorBean in the Java Editor.

 

Procedure

 

       1.      Add the following code in the cancelBooking() method:

try {

   QuickBookingLocal booking = bookingHome.findByPrimaryKey(bookingId);

   booking.setStatus(Constants.STATUS_CANCELLED);

   } catch (FinderException e) {

       e.printStackTrace();

       throw new QuickCarRentalException(e.getMessage());

    }

 

 

 

       2.      Replace the default return value return null; with:

 

return bookingId + " cancelled.";

 

 

       3.      To add the import statements, choose Source Organize Imports from the context menu.

       4.      If necessary, correct the formatting of these new lines of code.

       5.      Save the contents of the Editor.

Result

You have completely implemented the business method cancelBooking.

 

Next step:

Implementing the viewActiveBookings() Method

 

End of Content Area