0% found this document useful (0 votes)
122 views

ABAP Code Sample To Learn Basic Concept of Object-Oriented Programming

abap abap

Uploaded by

mudit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

ABAP Code Sample To Learn Basic Concept of Object-Oriented Programming

abap abap

Uploaded by

mudit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ABAP Code Sample to Learn Basic

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”).

By: Kavitha Bhuvaneswaran, Wipro Technologies


Date: 18 Jan 2005

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.

DATA : obj TYPE REF TO number1.


DATA : z1 TYPE i.

PARAMETERS : s_x1 type i obligatory.


PARAMETERS : s_y1 type i obligatory.

START-OF-SELECTION.
CREATE OBJECT obj EXPORTING x1 = s_x1
y1 = s_y1.
Selection screen
Output list

Disclaimer & Liability Notice

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.

You might also like