cancel
Showing results for 
Search instead for 
Did you mean: 

Call different RFC Functions depending on variable

Former Member
0 Kudos

Hi,

I have to implement following requirement:

My program generates a report for the user and the user can choose which data he wants to have.

Depending on the user decissions, I have to use different RFC - Functions to get the data.

I have the name of the RFC Function und I want to call the RFC Function with this name dynamically.

For example:


rfcName = "Z_FUNC_1";

rfc = get the object for Z_FUNC_1 somehow. This is my problem
rfc.execute();

Is there any way how to solve this? I know that I can solve this like this, but this is not the flexible way that i want:


if (whichRFC == 1) {
  Z_Func_1_input rfc = new Z_Func_input();
}
.
.
.
rfc.execute();

Any ideas?

Best regards,

Peter

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Peter

For your task it'd be better to use native JCO API instead of the static WebDynpro RFC models. With JCO 2.0 or JCo 3.0 you can dynamically invoke any BAPI you want.

BR, Siarhei

Former Member
0 Kudos

Hi,

thanks for your answer. Do you know where I can find some documentation or examples how to use JCO 3.0?

Best regards,

Peter

siarhei_pisarenka3
Active Contributor
Former Member
0 Kudos

Thanks for your help.

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear Peter,

There are how many RFC models are you going to make? In my opinion it would be too tedious and redundant as you have to create diifferent models fo each RFC.

Instead of this you may create a single RFC and in that you can call your required RFC depending on the user selection.

It will simplify your application as well as your task.

Hope it helps!!

Warm Regards

Upendra Agrawal

Former Member
0 Kudos

Hi,

ok, this is a good idea. I have to talk it over with the ABAP developer.

But I wonder if there is a way to call a RFC Function dynamic. In PHP I would have done it in this way:

$dynObj = "TestObj";

eval("\$myobj = new {$dynObj}();");

I s there a way in Webdynpro the achieve this?

Best regards,

Peter