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

Instance vs Static Method

Former Member
0 Likes
821

I am trying to create a BADI Definition in the Enhancement Spot.

When I am creating a method in the BADI interface; I have the option of INSTANCE and STATIC.

Please elaborate the difference between the two; giving examples.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
586

it's an elementary concept of object-oriented programming languages, please look at books or lots of threads in the forum.

briefly, you may call instance methods only on instances:

data instance_name type ref to class_name.
create object instance_name...
call method instance_name->instance_method( ... )

you may call static methods (also called class methods) only on class, does not need an instance

call method class_name=>static_method( ... )

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
587

it's an elementary concept of object-oriented programming languages, please look at books or lots of threads in the forum.

briefly, you may call instance methods only on instances:

data instance_name type ref to class_name.
create object instance_name...
call method instance_name->instance_method( ... )

you may call static methods (also called class methods) only on class, does not need an instance

call method class_name=>static_method( ... )

Read only

Former Member
0 Likes
586

Hi,

Instance methods are called using the following syntax:

CALL METHOD instance_name->instance_method_name.

A static method which is also called as class method can be called using the class and does not require an Instance. Static methods are called using the following syntax:

CALL METHOD class_name=>instance_method_name