2013 Feb 16 7:29 AM
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
2013 Feb 16 10:19 AM
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
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
2013 Feb 16 9:35 AM
As per my knowledge you can't do that because you create data object with data statement and we can create it form variable.
2013 Feb 16 9:41 AM
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.
2013 Feb 16 10:13 AM
2013 Feb 16 10:19 AM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |