sapdev logo background
sapdev logo sapdev logo
Comments

ABAP CLASS-METHODS FUNCTIONAL Statement syntax, information and example SAP source code



Return to Statement index



CLASS-METHODS - RETURNING

Short Reference

ABAP Syntax CLASS-METHODS meth
[IMPORTING parameters [PREFERRED PARAMETER p]]
[EXPORTING parameters ]
[CHANGING parameters ]
RETURNING VALUE(r) typing
[{RAISING exc1|RESUMABLE(exc1) exc2|RESUMABLE(exc2) ...}
|{EXCEPTIONS exc1 exc2 ...}].

What does it do? This statement declares a functional
static method meth . The additions have exactly the same syntax and meaning as those for functional instance methods .

Example ABAP Coding The class circle contains two functional static methods, circumference and area , which work with the constant pi .
CLASS circle DEFINITION.
PUBLIC SECTION.
CONSTANTS pi TYPE decfloat34
VALUE '3.141592653589793238462643383279503'.
CLASS-METHODS: circumference IMPORTING r TYPE decfloat34
RETURNING value(c) TYPE decfloat34,
area IMPORTING r TYPE decfloat34
RETURNING value(a) TYPE decfloat34.
ENDCLASS.

CLASS circle IMPLEMENTATION.
METHOD circumference.
c = 2 * pi * r.
ENDMETHOD.
METHOD area.
a = pi * r ** 2.
ENDMETHOD.
ENDCLASS.

DATA: circ TYPE decfloat34,
area TYPE decfloat34,
radius TYPE decfloat34.

START-OF-SELECTION.

radius = '1.00'.
circ = circle=>circumference( radius ).
area = circle=>area( radius ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




CLASS-METHODS_EVENT_HANDLER
CLASS-METHODS_GENERAL




comments powered by Disqus