-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathABAP_OOP_Sample_5.36.txt
56 lines (43 loc) · 1.22 KB
/
ABAP_OOP_Sample_5.36.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"示例程序5.36
REPORT zrep_cls_016.
DATA:
sflight TYPE sflight.
*object define
DATA:
gi_get_flights TYPE REF TO zif_get_flights,
go_flight_p TYPE REF TO zcl_get_flight_price,
go_flight_d TYPE REF TO zcl_get_flight_dest,
gs_flights TYPE sflight,
gs_sflights TYPE sflights.
PARAMETERS:
s_connid TYPE sflight-connid.
*create object
START-OF-SELECTION.
CREATE OBJECT go_flight_p.
*call interface method.
CALL METHOD go_flight_p->zif_get_flights~get_flight_details
EXPORTING
iv_flight_no = s_connid
IMPORTING
es_sflight = gs_flights.
*display the price data
IF sy-subrc = 0.
cl_demo_output=>display_data( gs_flights ).
ENDIF.
"upcasting
CREATE OBJECT gi_get_flights TYPE zcl_get_flight_dest.
*call interface method.
CALL METHOD gi_get_flights->get_flight_details
EXPORTING
iv_flight_no = s_connid
IMPORTING
es_sflights = gs_sflights.
*display the Departure and Arrival city data
IF sy-subrc = 0.
cl_demo_output=>display_data( gs_sflights ).
ENDIF.
"Method "PRINT_FLIGHT_DEST(" is unknown or PROTECTED or PRIVATE.
"CALL METHOD gi_get_flights->print_flight_dest( ).
"downcasting
go_flight_d ?= gi_get_flights.
CALL METHOD go_flight_d->print_flight_dest( ).