Travel agencies often have to check what customer is booked on what flights (see the
Flight Model). The corresponding data is distributed on several tables:You therefore have to create a view on tables SCUSTOM, SBOOK and SPFLI for the necessary view on the booking data.
All the bookings in table SBOOK for this customer number (CUSTOMID) can be determined 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.
In this case the join conditions are:
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 (see
Foreign 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 following selection condition:
SBOOK-CANCELLED <> ‘X’
Data Selection with the View SCUS_BOOK
You can access the data of a view in ABAP programs. A view can therefore be used for selecting 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.