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

object created dynamically. how to call a method or interface from it

Former Member
0 Likes
2,406

Hi Experts,

I've just created an abap proxy dynamically

FIELD-SYMBOLS <ref> TYPE any.

CREATE DATA dref TYPE REF TO

(ld_class).

ASSIGN dref->* TO <ref>.

CREATE OBJECT <ref>

TYPE

(ld_class)

EXPORTING

logical_port_name =logicalport.

This runs OK

But I can't call an Interface of the object proxy that belongs to ld_class

ld_prot ?= <ref>->if_proxy_basis~get_protocol( if_wsprotocol=>sequence ).

because the object <ref> is type any, it doesen't runs

This work' s fine

MOVE <ref> ?TO proxy1.

ld_prot ?= proxy->if_proxy_basis~get_protocol( if_wsprotocol=>sequence )

if proxy is explicity declarated like class proxy

But I don't want do it. I want do it dynamically to avoid write data declaration explicity

I think this is a problem for every data that must be declarated by the form TYPE REF TO

What must I do ?

thanks in advance.

3 REPLIES 3
Read only

Kiran_Valluru
Active Contributor
0 Likes
1,229

Hi.,

Check this help Document : [Dynamic Method Call in ABAP Objects|http://help.sap.com/abapdocu_70/en/ABENNEWS-46-OBJECTS-DYNAMIC.htm]

aslo [Dynamic method call|;

hope this helps u.,

Thanks & Regards

Kiran

Read only

0 Likes
1,229

thanks

Read only

matt
Active Contributor
0 Likes
1,229

Get the name of the method into a string - l_method, say. Then use: CALL METHOD <ref>->(l_method) EXPORTING... I'm not sure you need to use a field symbol though - consider this:

DATA: lr_proxy TYPE REF TO OBJECT, "Maybe CL_PROXY_BASIS instead of OBJECT???
      l_method TYPE string.

CREATE OBJECT lr_proxy TYPE (ld_class).
CALL METHOD lr_proxy->(l_method) EXPORTING.

(Thread moved to ABAP Object forum)