Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

I need a simple addition program on OOPS ABAP

Dear sir,

I need a simple addition of two numbers program on OOPS ABAP concept. including the class and method creation methods, and the object creation methods.. if possible give me the sample programs on OOPS ABAP.

regards

patil.

replied

Hi Rachu,

Yes you need to write this code in se38 & execute in se38..

Here is one more program for your reference....

CLASS counter DEFINITION.

PUBLIC SECTION.

METHODS: set IMPORTING value(set_value) TYPE i,

increment,

get EXPORTING value(get_value) TYPE i.

PRIVATE SECTION.

DATA count TYPE i.

ENDCLASS.

CLASS counter IMPLEMENTATION.

METHOD set.

count = set_value.

ENDMETHOD.

METHOD increment.

ADD 1 TO count.

ENDMETHOD.

METHOD get.

get_value = count.

ENDMETHOD.

ENDCLASS.

DATA number TYPE i VALUE 5.

DATA cnt TYPE REF TO counter.

START-OF-SELECTION.

CREATE OBJECT cnt.

CALL METHOD cnt->set EXPORTING set_value = number.

DO 3 TIMES.

CALL METHOD cnt->increment.

ENDDO.

CALL METHOD cnt->get IMPORTING get_value = number.

WRITE number.

Regards,

Nikita

Edited by: Nikita Jain on Oct 13, 2008 11:47 AM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question