Sie sind auf Seite 1von 3

interface ZIF_JULY_PLANE

public .
methods fly.
methods load.
methods print_Airlines.
endinterface.

class ZAC_JULY_PLANE definition


public
abstract
create public .

public section.

interfaces ZIF_JULY_PLANE
abstract methods LOAD .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS ZAC_JULY_PLANE IMPLEMENTATION.


METHOD zif_july_plane~fly.
write : / 'Plane is running on Runway' ,
/ 'Plane is taking off',
/ 'Auto-pilot ON, Roger! we are in skies :)'.
ENDMETHOD.
METHOD zif_july_plane~print_airlines.

* data: itab type table of scarr,


* wa like line of itab.
""we can also put comma between column names which majority ofDB supports
select carrid, carrname from scarr into table @data(itab).

* loop at itab into data(wa).


* write : / wa-carrname.
* endloop.
loop at itab ASSIGNING field-symbol(<fs>).
WRITE : / <fs>-carrid, <fs>-carrname.
ENDLOOP.

ENDMETHOD.
ENDCLASS.

class ZCL_JULY_PLANE_PASS definition


public
inheriting from ZAC_JULY_PLANE
final
create public .

public section.

methods ZIF_JULY_PLANE~LOAD
redefinition .
protected section.
PRIVATE SECTION.
ENDCLASS.
CLASS ZCL_JULY_PLANE_PASS IMPLEMENTATION.

METHOD zif_july_plane~LOAD.
WRITE : 'Passengers are boarding'.
ENDMETHOD.
ENDCLASS.

class ZCL_JULY_PLANE_CARGO definition


public
inheriting from ZAC_JULY_PLANE
final
create public .

public section.

methods ZIF_JULY_PLANE~LOAD
redefinition .
protected section.
PRIVATE SECTION.
METHODS add_numbers.
ENDCLASS.

CLASS ZCL_JULY_PLANE_CARGO IMPLEMENTATION.

METHOD zif_july_plane~LOAD.
WRITE : 'Freight is getting loaded'.

add_numbers( ).

ENDMETHOD.

METHOD add_numbers.

DATA c TYPE i.
DATA b TYPE i VALUE 20.
DATA a TYPE i VALUE 10.

c = a + b.

ENDMETHOD.

ENDCLASS.

*&---------------------------------------------------------------------*
*& Report zjuly_consume_plane
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zjuly_consume_plane.

DATA: lo_plane TYPE REF TO zif_july_plane,


lo_cargo TYPE REF TO zcl_july_plane_cargo,
lo_pass TYPE REF TO zcl_july_plane_pass.

types: BEGIN OF ty_itab,


x type i,
y type string,
end of TY_ITAB.

data: itab type table of ty_itab,


lv_string type string.
* wa like line of itab.

*wa-x = 10.
*wa-y = 'A'.
append value #( x = 10 y = 'A' ) to itab.

*wa-x = 20.
*wa-y = 'B'.
*CONCATENATE 'the current logon user is ' sy-uname into lv_string.
append value #( x = 20 y = |The current user name is '{ sy-uname }'| ) to itab.

*loop at itab into data(wa).


* write : / wa-x, wa-y.
*endloop.

read table itab into data(wa) with key x = 20.


WRITE : / wa-y.

*CAUTION: use read expression when you are sure that data do exist for a column
data(lv_temp) = itab[ x = 20 ]-y.
WRITE : / lv_temp.

*PARAMETERS : p_typ TYPE c.


*
*IF p_typ = 'P'.
** CREATE OBJECT lo_pass.
* lo_pass = new zcl_july_plane_pass( ).
* lo_plane = lo_pass.
*ELSE.
** CREATE OBJECT lo_cargo.
* data(lo_cargo) = new zcl_july_plane_cargo( ).
* lo_plane = lo_cargo.
*ENDIF.
*
*lo_plane->load( ).
*lo_plane->fly( ).
*
*uline.
*lo_plane->print_airlines( ).

Das könnte Ihnen auch gefallen