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

get table dynamic

Former Member
0 Likes
773

Hi all,

i have to wrote a generator for a Pattern here. But i got a small problem.

I have to got a table and the big problem is i don't know whick TYPE i got

the code looks like this


SELECT *
FROM (im_table)
INTO TABLE ????.

But how to define the ????. I allready tried


DATA test TYPE ANY TABLE.

and


DATA test TYPE TABLE.
FIELD-SYMBOLS <table> TYPE ANY.

ASSIGN test TO <table>
.....
INTO TABLE <table>.

But no luck this time. Maybe some of you get a hint for me.

greetings

P.S Sorry for my bad english.

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
753

Where do you put this dynamic select? Method? Function module?

8 REPLIES 8
Read only

rainer_hbenthal
Active Contributor
0 Likes
754

Where do you put this dynamic select? Method? Function module?

Read only

0 Likes
753

This is a method.

The (im_table) is a Parameter from the Type CHAR where the table is set.

greetings

Read only

0 Likes
753

Try this:



DATA:
  ptr_it_table type any table.

field-symbols:
  <fstable> type any table.

create data ptr_it_table type table of (im_table).
assign ptr_it_table ->* to <fstable>.

select *
from (im_table)
into table <fstable>.
 

this should work.

Read only

0 Likes
753

The Answere before work. Your last answer didnt work ... I Got a error message like this:


You cannot use generic types for fields. The table Types ANY and INDEX are generic.

But thanks a lot ...

greetings

Read only

0 Likes
753

Hello Moritz

Perhaps it is possible to add the following option to the DATA definition:

DATA:
  ptr_it_table type any table
                   WITH DEFAULT KEY.

Regards

Uwe

Read only

0 Likes
753

Thanks a lot it works now

Now i can work on thank you thousand times

greetings

Read only

0 Likes
753

Sorry, it must be like this:

instead:

DATA:

ptr_it_table type any table.

it must be

DATA:

ptr_it_table type ref to data

Read only

uwe_schieferstein
Active Contributor
0 Likes
753

Hello Moritz

Add the following lines of coding:

DATA:
  lo_data     TYPE REF TO data.

FIELD-SYMBOLS:
  <lt_itab>          TYPE table,
  <ls_record>      TYPE any.


  CREATE DATA lo_data TYPE (im_table).
  ASSIGN lo_data->* TO <lt_itab>.

SELECT *
FROM (im_table)
INTO TABLE <lt_itab>.

  LOOP AT <lt_itab> ASSIGNING <ls_record>.

  ENDLOOP.

Regards

Uwe