2 weeks ago - last edited 2 weeks ago
Hello,
I'm in an old SAP version. SAP_ABA 701.
I'm trying to call a method dynamically using a PARAMETERS table.
I'can activate my test report with the following code:
*-----------------------------------------------------------------------------------
REPORT ztest.
TYPE-POOLS: abap.
DATA:
lv_class TYPE string,
lv_method TYPE string,
lt_param TYPE abap_parmbind_tab.
CALL METHOD (lv_class)=>(lv_method)
PARAMETER-TABLE
lt_param.
*-----------------------------------------------------------------------------------
But cannot activate my code changing the => by ->.
The method of my class is not a class-method, its an instance method.
I have the following message activating the code:
The syntax for a method specification is "objref->method" or "class=>method". "class=>method". "class=>method". "class=>method".
Program ZTEST
After "(LV_CLASS)", there must be a space or equivalent character (":",
",", "."). .
Any idea how to do it?
Thanks in advance.
Hi,
Since the method that you're trying to call is not static, you need an object/instance of the class before you can access the method using -> operator:
data class_name type string value 'MyClass'.
data method_name type string value 'MyMethod'.
data obj type ref to object.
create data obj type (class_name).
call method obj->(method_name).
Regards
Sajid Khan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.