2012 Mar 22 3:09 PM
Hi all experts,
I got a problem with dynamical calling subroutines. I have a huge list of subroutines to call. Each of them has own defined paramter interface.
Such like this.
FORM subroutine
USING var1 TYPE typ1
CHANGING var2 TYPE typ2
...
varN TYPE typN
We dont know the data types of paramters and the number of CHANGING PARAMETER is variate too.
I have tried to use the "generate subroutine pool" to call them dynamically but the number of subroutine pools I want to create is heavily exceed the limit of 36 times.
Is there any other intelligent way to implement it.
Thanks and with best Regards,
Jun
2012 Mar 23 8:22 AM
is it possible to build a paramter table like dynamically calling the class method or function module?
2012 Mar 23 9:45 AM
Hi,
is there anything preventing you from using class methods?
You could rebuild your subroutines as methods of a (local) class.
Or else although this might seem a bit bulky but still way better then generate subroutine pool
you could build a wrapper method for each of your subroutines, thus beeing able to use parameter tables on the caller site and then addressing each subroutine with the correct supply of parameters.
Regards
Jörg
2012 Mar 23 9:18 AM
You have look at the technique of calling a subroutine from a sap script. I think the same applies here.
Why not encapsulating each of the 36 calls in different LUW's . Will this work ?
2012 Mar 23 9:34 AM
if the number of parameters is not always the same then you have to pass an internal table as parameter, and inside the table you have your parameters
for this purpose you could use a structure like DYNPREAD for your internal table
now if you want to be able to pass any type of parameter to your routine then you set a parameter with type TYPE REF TO DATA. Before you call the routine you do a GET REFERENCE OF on your parameter and you pass the reference. Then in the routine you are able to get the type of the parameter (do an ASSIGN then a DESCRIBE) and react accordingly
2012 Mar 23 1:28 PM
hi François Henrotte,
Thanks for your reply. The problem is I cant do any modifications in the routines which I called.
Regards,
Jun
2012 Mar 23 11:26 AM
hi Jun Long,
You can define data type as generic type and take the paramater into a internal table and pass the value by creating method.Let me know if you want more clarification.
Regards,
Ankita
2012 Mar 23 1:34 PM
Hi Ankita,
please give more clarification.
Do you mean I should create a class method as Interface to receicve the parameters in internal table of generic types. Then I call the subroutine within my class method?
Thanks and Regards,
Jun
2012 Mar 23 11:27 AM
Hi Jun,
The best approach in such case is to use Class and method in place of subroutene, where you can make the parameters optional.
If it is required to use only subroutene, then you declare parameters with type ANY and pass different structures at different call.
Hope this helps.
Cheers,
Samir