cancel
Showing results for 
Search instead for 
Did you mean: 

Call method dynamically PARAMETER-TABLE

oliver_am
Active Participant
0 Kudos

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-POOLSabap.

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.

 

 

oliver_am
Active Participant
0 Kudos
Ok, creating an instance of lv_class I can activate the code.

Accepted Solutions (0)

Answers (1)

Answers (1)

sajid-khan
Explorer

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