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

ABAP Objects Questions

former_member445996
Participant
0 Likes
572

Hello Everyone,

I hope someone could answer the following questions:

Please look at the below ABAP code

data: zVar(30) type c value 'ZTEST_CLASS',

methodName(30) type c value 'Test_Method'.

Question # 1: Can I define the objVar as below or is there anyother way to accomplish this?

data: objVar TYPE REF TO zVar. (Please note that zVar is the variable that contains the name of the

class)

Question # 2: Can I create the object objVar from the above question as below?

CREATE OBJECT objVar.

Question # 3: Can I call the method of objVar as below

CALL METHOD objVar->Test_Method (please note that test method is a variable that contains the name

of the actual method)

Thanks in advance.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
540

All these Can be done using Dynamic programming.

check this

REPORT  ZTEST_CLASS.


data: zVar(30) type c value 'ZCL_TEST1',  "<--class name
methodName(30) type c value 'TEST'.   "<----Method name

data: obj type ref to object.

create object obj TYPE (zvar) .

call method obj->(methodname).

break-point.

2 REPLIES 2
Read only

Former Member
0 Likes
541

All these Can be done using Dynamic programming.

check this

REPORT  ZTEST_CLASS.


data: zVar(30) type c value 'ZCL_TEST1',  "<--class name
methodName(30) type c value 'TEST'.   "<----Method name

data: obj type ref to object.

create object obj TYPE (zvar) .

call method obj->(methodname).

break-point.

Read only

0 Likes
540

Thanks Vijay. I appreciate your help.