Show TOC Start of Content Area

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

 

The viewActiveBookings method returns all the bookings that have the status ACTIVE and fills the instances of the JavaBean QuickBookingModel with this booking data. The client can then use this data to display the bookings in the user interface. The instances of the QuickBookingModel are passed as an array to the client or Web service. If an error occurs, the method throws a QuickCarRentalException.

Prerequisites

This graphic is explained in the accompanying textThis 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 viewActiveBookings method:

 

ArrayList bookings = new ArrayList();

try {

   Collection active = bookingHome.findByStatus(Constants.STATUS_ACTIVE);

   for (Iterator iterator = active.iterator(); iterator.hasNext();) {

       bookings.add(

       getBookingModel((QuickBookingLocal) iterator.next()));

   }

 

   } catch (FinderException e) {

       e.printStackTrace();

       throw new QuickCarRentalException(e.getMessage());

       }

QuickBookingModel[] result = new QuickBookingModel[bookings.size()];

bookings.toArray(result);

 

 

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

 

return result;

 

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

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

       5.      In the selection dialog that appears, choose java.util.Iterator as the Iterator class.

       6.      Save the contents of the Editor.

Result

You have completely implemented the business method viewActiveBookings.

 

Next step:

Creating a JAR

 

 

End of Content Area