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

Dynamic Call Function/Class Method

Former Member
0 Likes
2,591

Hi,

I have a requirement for which I need your help.

I want to Call a Method dynamically inside a program. how to do it?

My another quary is that how to call more than one class method dynamicaly in the program, one at a time, based on certain conditions.

All the requirements mentioned above feels awakward to me, but are they feasible. Eagerly waiting for a reply.

Regards,

Pulokesh

3 REPLIES 3
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
977

Hello,

Dynamic tokens are supported by ABAP & i think the req. mentioned by you are feasible.

Please refer to this [link|;jsessionid=(J2EE3414700)ID0610766550DB12900366814130486807End?rid=/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae&overridelayout=true] for dynamic calling of FMs & Methods.

As to how you want to implement, thats another topic altogether

Cheers,

Suhas

Read only

Timo_John1
Active Participant
0 Likes
977

Hello,

you can call a Method like this where the name of the method is concatenated.

CONCATENATE 'SC_' me->gf_scenario '_SAVE' INTO lf_method.
  CALL METHOD me->(lf_method).

Than I can imagine to loop over a tabele with all the Method Call to be executes un there:


Loop at gt_meth_calls into ls_meth_call.
   ls_meth_call-object_instance->(ls_meth_call-meth_name).
endloop.

The table should be structured such that the first component contains a reference to the instance and the second component will be the Method name to run.

Read only

Former Member
0 Likes
977

Thanks Timo and Suhas for your contributions.

I am using your solutions in a different way.

I have myself figured out how to populate data to the parameter table which will be containing data and reference of the I/P and E/P components of the calling dynamic method.

TRY.

CALL METHOD

(%p_class)=>(%p_method)

PARAMETER-TABLE

gi_par_tab.

CATCH .........

ENDTRY.

Table vseomepara and field symbol usage logic will help how to populate data in the parameter table.

Regards,

Pulokesh