CALL METHOD statement is sued for calling a method in ABAP Objects. Methods are coming under object oriented Programming concept. A method call can be static or dynamic. In static call the method id is already known in that program, but in dynamic call the method id is determined at runtime.
Syntax for static CALL METHOD
- CALL METHOD <meth> [EXPORTING … <ii> =.<f i>… ]
[IMPORTING … <ei> =.<g i>… ]
[CHANGING … <ci> =.<f i>… ]
[RECEIVING r = h ]
[EXCEPTIONS… <ei> = r i… ]
[PARAMETER-TABLE <ptab>]
[EXCEPTION-TABLE <etab>].
- [CALL METHOD]<meth>( … ).
See the sample usage structure
METHOD m1.
…
ENDMETHOD.
CALL METHOD m1
EXPORTING p1 = text
p2 = number
IMPORTING p3 = date
p4 = amount
EXCEPTIONS ex1 = 10
ex2 = 20
OTHERS = 30.
OR
METHOD m1.
…
ENDMETHOD.
m1( EXPORTING p1 = text
p2 = number
IMPORTING p3 = date
p4 = amount
EXCEPTIONS ex1 = 10
ex2 = 20
OTHERS = 30 ).
Syntax for dynamic CALL METHOD
CALL METHOD <meth>
In dynamic calling we cannot specify the parameters in parenthesis.
See the usage
class = ‘CL_GUI_FRONTEND_SERVICES’.
meth = ‘GUI_DOWNLOAD’.
CALL METHOD (class)=>(meth)
PARAMETER-TABLE
ptab
EXCEPTION-TABLE
etab.
CALL METHOD OF statement
It is used for calling a method in OLE2 automation.
Its syntax is
CALL METHOD OF <obj> <m>.
Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes