Travel agencies often have to check what customer is booked on what flights (see theFlight Model). The corresponding data is distributed on several tables:
You can get an overall view of all existing bookings by creating a view on 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
The join conditions can also be derived from the existing foreign key relationships between the tables of the view (seeForeign Key Relationship and Join Condition).
If you only want to display 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.