Show TOC Start of Content Area

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

 

The saveBooking method passes the booking data that it receives as parameters to the entity bean QuickBookingBean. The entity bean then writes the record to the database instance of the QCR_RESERVATION table. 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 saveBooking method:

 

       Date dateFrom=getDate(dateFromString);

       Date dateTo=getDate(dateToString);

       QuickBookingLocal booking = null;

       java.util.Date reservationDate = new java.util.Date();

      

       java.lang.String bookingId = generateId();

       try {

          booking =

              bookingHome.create(

                 bookingId,

                 vehicleTypeId,

                 reservationDate,

                 dateFrom,

                 dateTo,

                 pickupLocation,

                 dropoffLocation,

                 Constants.STATUS_ACTIVE);

       } catch (CreateException e) {

          e.printStackTrace();

          throw new QuickCarRentalException(e.getMessage());

       }

 

 

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

 

return getBookingModel(booking);

 

 

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

       4.      If necessary, correct the formatting of these lines by choosing Format from the context menu.

       5.      Save the contents of the editor by choosing the appropriate icon from the toolbar.

Result

You have completely implemented the business method saveBooking.

 

Next step:

Implementing the cancelBooking() Method

 

 

End of Content Area