Writting a select when you don't know the structure?????
Ok... if you've opened my thread... thanks.
Now. I've got to the point where i can select from a variable like
select *
from (table_name_variable)
into it_internal_table
where blah blah blah
How can I do this so the structure of table_name_variable (this table) can change? I'm basicly selecting off a table trying to put each record into one big string.
it_internal_table was declared like
data: begin of it_internal_table occurs 0,
record(2048),
endof.......
but this is not working.... any ideas!!!!????
Hi,
Table Name should be in CAPS. Else please post the actual code.
Best Wishes
Jawahar
What do you mean by "it is not working?" Syntax error, run time error, or results are not what you are expecting?
_________________
Sudhi Karkada
Hmmmm....
I don't think field symbols will work here because you have to have a structure to assign one to. If you are planning to allow vthis thing to read only a few tables that could be an option - you declare each of the tables and then have a case statement to do the assignment followed by:
Select *
From <field_symbol>.....
If you're trying to read any table the user throws at it then that approach won't work.
Another thing to have a look at is the function module TABLE_ENTRIES_GET_VIA_RFC because this function module does exactly what you are trying to accomplish.....
R
I knew I could find what I was looking for on SapFans ...
But I have one question :
How can I download the data of the selected table, still dynamicaly in CHAR format ? For example, when I select BSEG, many fields are in CURR. I want to translate them in CHAR. Any idea (function, code, ...)?
_________________
Have a nice day!
Benoît
Use field symbols to move each component of the structure to a character variable which you then append to a longer character variable until you've build up your record which you then output.
Search the forum for CSV under my name. You'll find code there doing exactly what you want.
R
Yeah, I figured it out.
you need a data statement like data: tablename type tablename (whatever the tablename is) so the structure of tablename is available.
Also a field symbol like field-symbols: <table> type any.
now, my problem was I'm doing a select on a table to get the table name I want to select from later. I fill up (tablename_variable) from some SAP function module.
so... I do a assign (tablename_variable) to <table>
now i do the select * from (tablename_variable) into <table> --- the structures match! which is what was giving me a hard time before.
and of course you can now do a aasign component to pick data fields from <table>... into yet another field symbol but now you can work with it in ABAP.
I'm so happy!
Sounds like cheating and not real dynamic coding to me. What if you have a new table? You're going to have to change the code??!
If you're going to put a TABLES statement in for every possible table, then why don't you just eliminate the INTO clause?
Crouser