‎2009 Oct 26 12:21 PM
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
‎2009 Oct 26 12:26 PM
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
‎2009 Oct 28 10:52 AM
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.
‎2009 Oct 28 11:17 AM
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