100% found this document useful (2 votes)
53 views

Abap Objects Program

The document defines a class called LCL_AIRPLANE with methods to set attributes of airplane objects like name and type. It has a method to display the attributes of an individual airplane and a class method to display the total number of airplanes. The code sample then creates an airplane object, sets its attributes, displays it, and shows the updated total count.

Uploaded by

api-3741414
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
53 views

Abap Objects Program

The document defines a class called LCL_AIRPLANE with methods to set attributes of airplane objects like name and type. It has a method to display the attributes of an individual airplane and a class method to display the total number of airplanes. The code sample then creates an airplane object, sets its attributes, displays it, and shows the updated total count.

Uploaded by

api-3741414
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

*&-------------------------------------------------------------------

--*
*& Report ZCLASSEXAMPLE
*&
*&-------------------------------------------------------------------
--*
*&
*&
*&-------------------------------------------------------------------
--*

REPORT ZCLASSEXAMPLE.

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.
TYPES: name_type(25) type c.
CONSTANTS : pos_1 type i VALUE 30.

METHODS:set_attributes IMPORTING
im_name type name_type
im_planetype TYPE saplane-planetype,
display_attributes.
CLASS-METHODS: display_n_o_airplanes.

PRIVATE SECTION.
DATA: name type name_type,
planetype TYPE saplane-planetype.
CLASS-DATA: n_o_airplanes type i.
ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD set_attributes.
name = im_name.
planetype = im_planetype.
n_o_airplanes = n_o_airplanes + 1.
ENDMETHOD.

METHOD display_attributes.

WRITE: /' name of the airplane:'(001) , AT pos_1 name,


/ ' plane type : '(002) ,AT pos_1 planetype.
ENDMETHOD.

METHOD display_n_o_airplanes.
WRITE: /,/ ' total number of airplanes:'(ca1),
AT pos_1 n_o_airplanes left-JUSTIFIED,/.
ENDMETHOD.
ENDCLASS.
*REPORT ZOBJECT.
INCLUDE ZCLASSEXAMPLE.

data: airplane type ref to lcl_airplane.


START-OF-SELECTION.
call METHOD lcl_airplane=>display_n_o_airplanes.
create object airplane.
call method airplane->set_attributes EXPORTING
im_name = 'LH B ERLIN'
IM_PLANETYPE = '747-400'.
CALL METHOD AIRPLANE->DISPLAY_ATTRIBUTES.
CALL METHOD LCL_AIRPLANE=>DISPLAY_N_O_AIRPLANES.

You might also like