SAP CALL METHOD FUNCTIONAL ABAP Statements
Get Example source ABAP code based on a different SAP table
ABAP Syntax
What does it do? Functional call of a
The semantics of the syntax used to pass parameters is the same as in standalone method calls. The following differences from standalone method calls exist: The return value in functional method calls cannot be assigned to an actual parameter explicitly using
If the functional method has the same name as a
Latest notes: In functional method calls, class-based exceptions propagated from the method can be handled as usual in a
The same applies to
Functional method calls can be nested in any way, which means that inline declarations for actual parameters can produce confusing results. For this reason, inline declarations are not allowed.
If successful, each method call sets the system field
Example ABAP Coding
Functional call of a method. Unlike in the example for
PUBLIC SECTION.
CLASS-METHODS do_something IMPORTING p1 TYPE i
p2 TYPE i
EXPORTING p3 TYPE i
p4 TYPE i
RETURNING VALUE(r) TYPE i.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something.
...
ENDMETHOD.
ENDCLASS.
DATA: a1 TYPE i,
a2 TYPE i.
START-OF-SELECTION.
DATA(result) =
c1=>do_something( EXPORTING p1 = 333
p2 = 444
IMPORTING p3 = a1
p4 = a2 ).
Example ABAP Coding
The
RETURNING value(fact) TYPE int8. CLASS math DEFINITION.
PUBLIC SECTION.
METHODS factorial
IMPORTING n TYPE i
RETURNING value(fact) TYPE i.
ENDCLASS.
CLASS math IMPLEMENTATION.
METHOD factorial.
fact = 1.
IF n = 0.
RETURN.
ELSE.
DO n TIMES.
fact = fact * sy-index.
ENDDO.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(result) = 100 + NEW math( )->factorial( 4 ).
Return to menu