ABAP Code Sample To Learn Basic Concept of Object-Oriented Programming
ABAP Code Sample To Learn Basic Concept of Object-Oriented Programming
Concept of Object-Oriented
Programming
Code samples are intended for educational use only, not deployment. They are untested and
unsupported by SAP. SAP disclaims all liability to any person in respect to any damage that is
incurred, whether wholly or partially, from use of the code.
Applies To:
ABAP
Summary
This ABAP code sample helps to explain the basic concept of Object-Oriented Programming
(often referred to here as “OOPS”).
Code Sample
REPORT zkclass1.
*------------------------------------------------------------------*
* CLASS number1 DEFINITION
*------------------------------------------------------------------*
* ........
*
*------------------------------------------------------------------*
CLASS number1 DEFINITION.
PUBLIC SECTION.
METHODS : constructor IMPORTING x1 TYPE i
y1 TYPE i.
METHODS : findsum EXPORTING z TYPE i.
PRIVATE SECTION.
DATA : x TYPE i,
y TYPE i.
ENDCLASS.
*------------------------------------------------------------------*
* CLASS number IMPLEMENTATION
*------------------------------------------------------------------*
* ........
*
*------------------------------------------------------------------*
CLASS number1 IMPLEMENTATION.
METHOD constructor.
x = x1.
y = y1.
ENDMETHOD.
METHOD findsum.
z = x + y.
WRITE : / z.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT obj EXPORTING x1 = s_x1
y1 = s_y1.
Selection screen
Output list
This document may discuss sample coding, which does not include official interfaces and
therefore is not supported. Changes made based on this information are not supported and can
be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing of the code and
methods suggested here, and anyone using these methods, is doing it under his/her own
responsibility.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the
content of the technical article, including any liability resulting from incompatibility between the
content of the technical article and the materials and services offered by SAP. You agree that you
will not hold SAP responsible or liable with respect to the content of the Technical Article or seek
to do so.
Copyright © 2004 SAP AG, Inc. All Rights Reserved. SAP, mySAP, mySAP.com,
xApps, xApp, and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP AG in
Germany and in several other countries all over the world. All other product,
service names, trademarks and registered trademarks mentioned are the
trademarks of their respective owners.