Application Development 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: 

Difference between function module and a method?

Former Member
0 Kudos
4,790

Hi Experts

Can anybody pls tell me the technical and functional difference between function moduel and a method?

Thanks

Sudhansu

1 ACCEPTED SOLUTION

Former Member
0 Kudos
702

Hi,

Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.

Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.

You can declare methods in the declaration part of a class or in an interface. To declare instance methods, use the following statement:

METHODS <meth> IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..

EXPORTING.. [VALUE(]<ei>[)] TYPE type [OPTIONAL]..

CHANGING.. [VALUE(]<ci>[)] TYPE type [OPTIONAL]..

RETURNING VALUE(<r>)

EXCEPTIONS.. <ei>..

When you declare a method, you also define its parameter interface using the additions IMPORTING, EXPORTING, CHANGING, and RETURNING. The additions define the input, output, and input/output parameters, and the return code. They also define the attributes of the interface parameters, namely whether a parameter is to be passed by reference or value (VALUE), its type (TYPE), and whether it is optional (OPTIONAL, DEFAULT).

Unlike in function modules, the default way of passing a parameter in a method is by reference.

As in function modules, you can use exception parameters (EXCEPTIONS) to allow the user to react to error situations when the method is executed.

As in function modules, you can use the RAISE <exception> and MESSAGE RAISING statements to handle error situations.

Regards,

Sruthi

2 REPLIES 2

Former Member
0 Kudos
703

Hi,

Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.

Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.

You can declare methods in the declaration part of a class or in an interface. To declare instance methods, use the following statement:

METHODS <meth> IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..

EXPORTING.. [VALUE(]<ei>[)] TYPE type [OPTIONAL]..

CHANGING.. [VALUE(]<ci>[)] TYPE type [OPTIONAL]..

RETURNING VALUE(<r>)

EXCEPTIONS.. <ei>..

When you declare a method, you also define its parameter interface using the additions IMPORTING, EXPORTING, CHANGING, and RETURNING. The additions define the input, output, and input/output parameters, and the return code. They also define the attributes of the interface parameters, namely whether a parameter is to be passed by reference or value (VALUE), its type (TYPE), and whether it is optional (OPTIONAL, DEFAULT).

Unlike in function modules, the default way of passing a parameter in a method is by reference.

As in function modules, you can use exception parameters (EXCEPTIONS) to allow the user to react to error situations when the method is executed.

As in function modules, you can use the RAISE <exception> and MESSAGE RAISING statements to handle error situations.

Regards,

Sruthi

Former Member
0 Kudos
702

Please have a look at below link. It will give you the details related to same.

http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm

Also have a look at below thread.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers