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

Dynamic data object creation

former_member186648
Active Contributor
0 Likes
757

How can i create data object dynamically:

//mr_ow is gloabl data object

data: mr_ow type ref to data.

//mr_ow is created dynamically as a return parameter from method call, based on different cases, hence, it type varies.

call method xyz

     return mr_ow.

data: lr_ob type ref to data.

i want to create lr_ob of type mr_ow, how can i achieve this?

create lr_ob....?

Thanks, pradeep.

4 REPLIES 4
Read only

Former Member
0 Likes
589
Read only

Former Member
0 Likes
589

Hi Pradeep,

Please try this-

CREATE OBJECT  lr_ob TYPE (mr_ow).

Thanks,

Jayshree.

Read only

former_member219762
Contributor
0 Likes
589

Hi Pradeep,

                Get type of mr_ow by method get_ref_to_data of CL_ABAP_REFDESCR and use that refrence(r)


CREATE DATA lr_ob TYPE HANDLE r.


or

define field symbol <fs> type any.

assign  mr_ow->* to <fs> casting.

descr_ref1 TYPE REF TO cl_abap_typedescr

descr_ref1 = cl_abap_typedescr=>describe_by_data( <fs> ).

CREATE DATA lr_ob TYPE HANDLE descr_ref1


Regards,

Sreenivas.

Read only

Former Member
0 Likes
589

Can you refer this document where the concept of data object creation and accessing it using field symbols is clearly explained.

http://scn.sap.com/docs/DOC-42525