Professional Documents
Culture Documents
An airline creates new flights and publicizes them in the media. Travel agencies
can then include these flights in their offerings.
A travel agent needs to register all the new flights, offered by a business partner, in the system
and offer the same towards their customers.
SOLUTION:
Enter the flight type (ex_carrid) flight number (ex_connid) and the flight date (ex_fldate)
and a reference to the event trigger (sender) as IMPORTING parameters.
When implementing the add_a_new_flight method, enter the airline, the flight number
and the
flight date in the list of flights (list_of_flights). To do this, create a table work area in the
method. This table work area must have the same structure as the internal tablelist_of_flights.
Use the APPEND statement to fill the table.
Define and implement the public instance method display_list_of_flights to display the
flight list
list_of_flights. This method does not have any transfer parameters.
CODE:
DATA:
list_of_flights TYPE TABLE OF flight_list_type,
wa_list_of_flights TYPE flight_list_type.
METHODS:
** Handler method for event FLIGHT_CREATED
add_a_new_flight FOR EVENT flight_created
OF lcl_plane
IMPORTING ex_carrid ex_connid ex_fldate sender,
** Display flight list
display_list_of_flights.
START-OF-SELECTION.
* Instantiating for class lcl_plane
CREATE OBJECT new_plane TYPE lcl_plane.
* Instantiating for class lcl_travel_agency
CREATE OBJECT ta TYPE lcl_travel_agency.
* Setting the handler for event FLIGHT_CREATED
SET HANDLER ta->add_a_new_flight FOR new_plane.
* Exporting values for the new flight created
CALL METHOD new_plane->create_a_new_flight
EXPORTING
im_carrid = 'LH'
im_connid = '1234'
im_fldate = '05272009'.
* Displaying the values for the new flight added.
CALL METHOD ta->display_list_of_flights.
METHOD create_a_new_flight.
wa_list_of_flights-carrid = im_carrid.
wa_list_of_flights-connid = im_connid.
wa_list_of_flights-fldate = im_fldate.
APPEND wa_list_of_flights TO list_of_flights.
** Raise event FLIGHT_CREATED
RAISE EVENT flight_created EXPORTING ex_carrid = im_carrid
ex_connid = im_connid ex_fldate = im_fldate.
ENDMETHOD. "create_a_new_flight
METHOD add_a_new_flight.
wa_partner_list-carrid = ex_carrid.
wa_partner_list-connid = ex_connid.
wa_partner_list-fldate = ex_fldate.
APPEND wa_partner_list TO it_partner_list.
CLEAR wa_partner_list.
ENDMETHOD. "add_a_new_flight
METHOD display_list_of_flights.
WRITE: /'Plane type ', 'Flight Number', ' Flight Date'.
ULINE.
LOOP AT it_partner_list INTO wa_partner_list.
WRITE:/ wa_partner_list-carrid,wa_partner_list-connid, wa_partner_list-fldate.
CLEAR wa_partner_list.
ENDLOOP.
ENDMETHOD. "display_list_flights