We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
You can replace the source field in a MOVE statement with a functional method call. Functional methods are methods in
ABAP Objects that can have any number of IMPORTING parameters but have exactly one RETURNING parameter.
Depending on the number of IMPORTING parameters, the following options are available:
In variants 2 and the CALL METHOD statement is used to pass the actual parameters to the method's IMPORTING parameters.
When the system executes the MOVE statement, it calls the method meth and assigns this method's return values to the target field g.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS M1 RETURNING VALUE(R) TYPE I.
METHODS: M2 IMPORTING N TYPE I
RETURNING VALUE(R) TYPE I,
M3 IMPORTING N1 TYPE I
N2 TYPE I
RETURNING VALUE(R) TYPE I.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
r = 100.
ENDMETHOD.
METHOD m2.
r = 10 * n.
ENDMETHOD.
METHOD m3.
r = n1 + n2.
ENDMETHOD.
ENDCLASS.
DATA: oref TYPE REF TO c1,
number1 TYPE i VALUE 3,
number2 TYPE i VALUE 5,
result TYPE i.
START-OF-SELECTION.
CREATE OBJECT oref TYPE c1.
MOVE C1=>M1( ) TO RESULT.
WRITE / RESULT.
MOVE oref->m2( number1 ) TO result.
WRITE / RESULT.
RESULT = OREF->M3( N1 = NUMBER1 N2 = NUMBER2 ).
WRITE / RESULT.
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki