Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to call a method?

Sultanuddin
Explorer
0 Likes
3,878

What is the right method to call a method,

Is CALL METHOD <class> => <interface-method>

(or) CALL METHOD <class> => <interface~method>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,464

Hi,

Assume C1 is class, M1 is method.

fist declare a refrence variable, then create object to the class.

Data:obj1 type ref to C1.

create object obj1.

now call the method in this way:

call method obj1->m1.

if it is static method then also you can call using the object as above or you can directly call static method with the class name without creating object to the class

call method c1=>m1.

=> is clas reference variable

->object reference variable

to call an interface method use tilde (~)

call method obj1->I1~M2.

I1 is the interface name and M2 is the method of the interface

I hope you got some idea now.

Regards,

Sowjanya

4 REPLIES 4
Read only

Former Member
0 Likes
1,464

Hi,

The right way to call a method is as follows .

assume there a class ABC with a method declare and object is lo_abc.

if the method is not static then it is called as

call method lo_abc->declare().

if the method is statis then

call method abc->declare .

Please reward if useful.

Read only

Former Member
0 Likes
1,464

Hello,

You can use the pattern button on ABAP editor (se80),click on radio button ABAP objects in the PATTERNS pop-up,give the object instance and the method you need and click continue.The method will automatically be inserted in your code with all the importing and exporting parameters.

Regards,

Beejal

**Reward if this helps

Read only

Former Member
0 Likes
1,465

Hi,

Assume C1 is class, M1 is method.

fist declare a refrence variable, then create object to the class.

Data:obj1 type ref to C1.

create object obj1.

now call the method in this way:

call method obj1->m1.

if it is static method then also you can call using the object as above or you can directly call static method with the class name without creating object to the class

call method c1=>m1.

=> is clas reference variable

->object reference variable

to call an interface method use tilde (~)

call method obj1->I1~M2.

I1 is the interface name and M2 is the method of the interface

I hope you got some idea now.

Regards,

Sowjanya

Read only

Former Member
0 Likes
1,464