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

Difference between Function and Method

Former Member
0 Likes
3,476

Hello Gurus,

I'm a beginner of ABAP now.

Is there anybody can explain what's different between Function and Method.

I could find pre-defined Function from

Menu -> Edit -> Pattern

but could't do the same thing with Method.

The method I wanted to find was CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG.

ps.Any tips to find method is going to be welcomed too.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,836

HI,

Select AABAP Object Patterns Radio button which is just below call function radio button . Then give the instance which u'v created and class name and then u can get methods existing for that particular Class.

Check Pattern button just before Pretty Printer button on the application tool bar.

Reward if helpful,

Iyswarya

8 REPLIES 8
Read only

Former Member
0 Likes
1,837

HI,

Select AABAP Object Patterns Radio button which is just below call function radio button . Then give the instance which u'v created and class name and then u can get methods existing for that particular Class.

Check Pattern button just before Pretty Printer button on the application tool bar.

Reward if helpful,

Iyswarya

Read only

Former Member
0 Likes
1,836

hi,

Follow the same path Menu -> Edit -> Pattern ... check the radio button below the defaulted radio button and press enter ... that takes you to another popup screen ... there give the class( CL_GUI_FRONTEND_SERVICES) and method(FILE_OPEN_DIALOG) name to call the method ....

Read only

Former Member
0 Likes
1,836

Thanks you.

then I'd like to know the difference between Function and Method.

They looks the same but

I think there would be a resaon that they are separated in defferent name.

Can anybody explain?

Read only

0 Likes
1,836

Refer to the below related threads which has the answer for your query ...

Regards,

Santosh

Read only

Read only

Former Member
0 Likes
1,836

Hi,

Please look into this...

Methods are calling using objects.

FUNCTIONS ARE DIRECTLY CALLING

The major difference between methods and functions is that methods called by the reference variables called objects where as the functions do not having any reference variables.

if its useful reward points

Read only

1,836

Functions:

are part of function groups. They are designed for global use and have a unique name. Function Modules also have a formal interface using IMPORTING, EXPORTING, CHANGING and TABLES parameters. The interface parameters can be passed BY VALUE or BY REFERENCE. Specific EXCEPTIONS can be defined for error handling. A function module can also have local data.

In theory, a function module can only use data a)from the interface parameters, b) defined locally in the function module and c) defined globally in the function group. However, it is possible to see global data from calling programs using field-symbols.

Remote Function Modules are function modules that can be called from other SAP or NON-SAP systems. BAPI's are examples of RFC-enabled function modules.

Function Groups and Function Modules are maintained using transaction SE37 (or SE80).

Methods:

are part of CLASSES. Here we are talking about ABAP Objects, supporting inheritance, instantiation, encapsulation, polymorphism, events, Interfaces, visibility sections (PUBLIC, PROTECTED, PRIVATE) and lifetime options STATIC and INSTANCE.

Classes can be defined locally or globally: a) Local Classes are classes, defined as part of an ABAP program. They can be used only within this program. b) The functionality of Global Classes is identical, but these classes are maintained using the Class Builder (SE24 or SE80).

The name of a method is not unique; you always need the name of the object to create the unique name. As a result, several classes will have exactly the same method name.

Methods also have a formal interface using IMPORTING, EXPORTING, CHANGING and RETURNING parameters. The interface parameters can be passed BY VALUE or BY REFERENCE. Specific EXCEPTIONS can be defined for error handling. A method can also have local data.

In general, using classes is considered a much better alternative to using subroutines and function modules, especially with regards to maintenance costs. Actually, you do not need subroutines anymore. Function Modules are only needed is some cases, for example as RFC's because the classes don't support remote calls.

Read only

0 Likes
1,836

Thank you all,

Now I roughly understand the difference between Function module and Method.