Travel agencies have to check which flights a customer has booked (see the Flight Model ). To find the corresponding data you must perform a search using the following tables:
You can get an overall view of all existing bookings by creating a view of tables SCUSTOM, SBOOK and SPFLI.
You can determine all the bookings in table SBOOK for a customer number (ID) for the customer number in table SCUSTOM. Using the carrier ID (CARRID) and the flight number (CONNID), the flight information can be read from table SPFLI for a booking that is found.
This results in the following join conditions for the view:
SBOOK-MANDT = SCUSTOM-MANDT
SBOOK-CUSTOMID = SCUSTOM-ID
SPFLI-MANDT = SBOOK-MANDT
SPFLI-CARRID = SBOOK-CARRID
SPFLI-CONNID = SBOOK-CONNID
You can see in the figure below how the search is performed.
The join conditions can also be derived from the existing foreign key relationships between the tables of the view (see Foreign Key Relationship and Join Condition ).
If you want to display only the customer bookings that were not canceled with the view, you can do this with the selection condition SBOOK-CANCELLED <> 'X'.
Data Selection with View SCUS_BOOK
A view can be used to select data in an ABAP program.
The following example program determines the existing flight bookings for a customer. The data is selected with view SCUS_BOOK.