0% found this document useful (0 votes)
37 views2 pages

OOPS

This document defines a CALC class with methods ADD, SUB, and MUL. It creates an instance of the CALC class and calls each method, performing addition, subtraction, and multiplication respectively using data members A and B defined in the class. The results are written to the output.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

OOPS

This document defines a CALC class with methods ADD, SUB, and MUL. It creates an instance of the CALC class and calls each method, performing addition, subtraction, and multiplication respectively using data members A and B defined in the class. The results are written to the output.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

*& Report ZABAP_OOPS2


*&
*&--------------------------------------------------------------------*
*&
*&
*&--------------------------------------------------------------------*
REPORT

ZABAP_OOPS2.

CLASS CALC DEFINITION.


PUBLIC SECTION.
DATA: A TYPE I VALUE 30,
B TYPE I VALUE 10,
C TYPE I.
METHODS: ADD.
METHODS: SUB.
METHODS: MUL.
ENDCLASS.
CLASS CALC IMPLEMENTATION.
METHOD: ADD.
C = A + B.
WRITE : / 'ADDITION =', C.
ENDMETHOD.
METHOD: SUB.
C = A - B.
WRITE : / 'SUBTRACTION =', C.
ENDMETHOD.
METHOD: MUL.
C = A * B.
WRITE : / 'MULTIPLY =', C.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.

DATA: OBJ2 TYPE REF TO CALC.


CREATE OBJECT OBJ2.
CALL METHOD: OBJ2->ADD.
CALL METHOD: OBJ2->SUB.
CALL METHOD: OBJ2->MUL.

You might also like