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

call a method in a function module

Former Member
0 Likes
4,848

Hello,

Function modules are pretty usefull for standard tasks and can be tested in SE37.

I use them remotly for reports (with saprfc).

Unfortunatly SAP started to replace those with methods in new releases with objects programming.

Therefore I cannot use the new methods remotly.

before : FUNCTION_MODULE()

after  : OBJECT->METHOD()

The solution would be to call the method with a specific function module.

Do you know if SAP provide a standard function module for this?

I found the function SETS_FA_METHOD_INVOKE but I don't know if it is its purpose.

any idea ?

3 REPLIES 3
Read only

Former Member
2,234

hello,

For calling class methods try this -

On the application tool bar when in SE38 (edit code mode), there is a pushbutton called 'PATTERN ' is there. click that.

then one pop-up will come, within pop-up select 'ABAP objects pattern', radio button. then press enter.

select call method radiobutton & then give the class name & method of that class which you want to call.

For class see transaction SE24.

best regards,

swanand

Read only

0 Likes
2,234

Hello Swanand,

Thank for your answer. Unfortunately it is not exactly what I need.

I know how to call a method but the issue is that I am using a tool called saprfc which basically is the same as having only the possibility to use the tcode SE37 > select a function module > execute it with parameters > retrieve result.

Your solution require to create a function module for each method which is problematic in my scenario :

Unfortunately I have several standard methods to call in numerous systems remotely that shouldn't be modified. At the moment the FM are only executed remotely without modification (adding of code) to the remote systems.

I would like to know if someone knows if it's possible or not to import the name of the method to invoke into a generic function module which could then execute it (and if SAP already made a standard generic FM for this). For example the standard FM SETS_FA_METHOD_INVOKE import a class name and a method name.

Best Regards,

Remi.

Read only

0 Likes
2,234

Hello Remi,

Yes, it is possible to pass the name of a method to a Generic RFC FM and then invoke a method call dynamically, however I have a few concerns here. The scenario would be absolutely perfect as along as you are calling static methods, but in the case of Instance methods , I believe it would be nearly impossible or too complicated - Especially due to factors such as instantiation, you cannot have an unfied instantiation model - unless you build one by yourself which is tedious. I am not aware of a SAP FM which could mimic what you need.

However with BOR objects ( My experience working with them is less! ), the scenario is a little different . You could use methods such as SWO_CREATE,SWO_INVOKE etc and could build a generic interface.

SETS_FA_METHOD_INVOKE - is used typically for testing BOR object methods.

A few days back i saw a forum post which is similar to your requirement.

http://scn.sap.com/thread/3156066

Thanks,

Venkat.