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

Creation of data objects at runtime

Former Member
0 Likes
592

Hi Experts,

                    I have a scenario where i need to create data objects based on a count.

That is ,

I have a local variable 'lv_count'. based on the value i need to create data objects. If lv_count = 2, I need 2 data objects and they shoud have 2 different names if possible.

Is there a way to do this.

Any help would be appreciated its URGENT..!!!! Pls

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
564

Hello,

You can perform a Do Loop and for each loop add the reference of the created data object to an internal table.

E.g >

     DATA :     lv_count TYPE i,

                    lv_obj TYPE REF TO data,

                    itab TYPE TABLE OF REF TO string.

     lv_count = 2.

     DO (lv_count) TIMES.

          CREATE DATA lv_obj TYPE string.

          APPEND lv_obj TO ITAB.

     ENDDO.

     You can access those data objects using index from the internal table ITAB.

Regards,

Ashish

Hi Experts,

                    I have a scenario where i need to create data objects based on a count.

That is ,

I have a local variable 'lv_count'. based on the value i need to create data objects. If lv_count = 2, I need 2 data objects and they shoud have 2 different names if possible.

Is there a way to do this.

Any help would be appreciated its URGENT..!!!! Pls

4 REPLIES 4
Read only

Former Member
0 Likes
564

As per my knowledge you can't do that because you create data object with data statement and we can create it form variable.

Read only

0 Likes
564

ok thanks. but can you suggest any other way?? actually my problem is I want to use those variables in a Read statement. where those variables will be the key fields. I have tables with different no. of keys.

Read only

0 Likes
564
Read only

Former Member
0 Likes
565

Hello,

You can perform a Do Loop and for each loop add the reference of the created data object to an internal table.

E.g >

     DATA :     lv_count TYPE i,

                    lv_obj TYPE REF TO data,

                    itab TYPE TABLE OF REF TO string.

     lv_count = 2.

     DO (lv_count) TIMES.

          CREATE DATA lv_obj TYPE string.

          APPEND lv_obj TO ITAB.

     ENDDO.

     You can access those data objects using index from the internal table ITAB.

Regards,

Ashish