2009 Feb 16 9:12 AM
Hi,
I have value '666'. There exists a table with name KOTG666 in the system.
Now, I should write a SELECT statement which should mean as follows:---
SELECT * FROM KOTG666 .
But, I can't write KOTG666 directly, bcos next time I may have value '999' and I have to retrieve data from KOTG999.
How can i do that? Is it possible with Edit-mask??
Thanks,
Shivaa......
2009 Feb 16 9:18 AM
Shiva,
May be we have to use Dynamic Select Query.Check the related threads in SDN
K.Kiran.
Hi,
I have value '666'. There exists a table with name KOTG666 in the system.
Now, I should write a SELECT statement which should mean as follows:---
SELECT * FROM KOTG666 .
But, I can't write KOTG666 directly, bcos next time I may have value '999' and I have to retrieve data from KOTG999.
How can i do that? Is it possible with Edit-mask??
Thanks,
Shivaa......
2009 Feb 16 9:18 AM
Shiva,
May be we have to use Dynamic Select Query.Check the related threads in SDN
K.Kiran.
2009 Feb 16 9:19 AM
hi
you can go like this
ITS A WORKING CODE
data: w_char type string value 'KOTG'.
parameters: p_char(10) .
concatenate w_char '-' p_char.
condense w_char no-gaps.
if <cond>
select fields
from (w_char)
into corresponding fields of table t_table.
else.
select fields
from (w_char)
into corresponding fields of table t_table.
endif.
regards
2009 Feb 16 9:20 AM
Try this way..
DATA tabname(10).
DATA: BEGIN OF wa,
id TYPE scustom-id,
name TYPE scustom-name,
END OF wa.
tabname = 'SCUSTOM'.
SELECT id name INTO CORRESPONDING FIELDS OF wa FROM (tabname).
WRITE: / wa-id, wa-name.
ENDSELECT
2009 Feb 16 9:20 AM
Hi,
Like this,
DATA: V_STR TYPE STRING VALUE 'KOTG'.
DATA: V_STR1 TYPE STRING.
PARAMETER: VAL(10) TYPE C. " ur input 999
CONCATENATE V_STR VAL INTO V_STR1.
CONDENSE V_STR.
SELECT * FROM (V_STR1).
2009 Feb 16 9:21 AM
2009 Feb 16 9:22 AM
Hi,
You can pass the table name through a variable.
select * from (table_name).
table_name is a variable containing the table name.
Regards,
Naga Sai Swapna
2009 Feb 16 9:23 AM
HI Shiva,
Just try following.
data: tab_name(10) type c.
concatenate 'KOTG' value into tab_name.
*value will be 666 or 999
select * from tab_name.
you also have to put dynamic where condition for this sql query.
press f1 on select you will be getting all help for dynamic where sql query.
Regards,
Pratik Vora
Edited by: Pratik Vora on Feb 16, 2009 2:53 PM
2009 Feb 16 9:26 AM
Hi Shiva, chk this...
data: str1 type string value 'KOTG',
str2 type string value '666'.
concatenate str1 str2 into str1 no-gaps.
select * from (str1) into.......
as the value 666 changes u can assign the new value to str2 before concatenating....
Regards,
Mdi.Deeba
2009 Feb 16 9:35 AM
Hi Shiva ,
I think you have to make use of dynamic open sql statement,
Kindly go through this link below:
http://www.susanto.id.au/papers/DynOpenSQL.asp
Hope it helps
Regrds
Mansi
2009 Feb 16 10:41 AM
Hi all, very thanks for ur answers......
But, I got struck up again.....
SELECT * FROM (TABNAME) INTO ????
Where can I store the values of the table (TABNAME) into?
I dont know the structure of the table beforehand, so I cant create a internal table.
I tried creating internal table as follows:--
data: it_t1 type table of <tabname>,
wa_t1 like line of it_t1.
But, its not accepting.
How can I store the values of table (TABNAME)??
2009 Feb 16 11:00 AM
Hey,
For this u've to create dynamic itab.
Search with the keyword Create Dynamic Internal Table
thanks\
Mahesh
2009 Feb 16 11:01 AM
Hi shiva,
Kindly try following.
field-symbols : <tabname> type any table.
Assign tabname to <tabname>
select * from (tabname) into <tabname>....
Kindly check if it works or not.
You can find help for dynamic table creation in below link.
http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
Regards,
Pratik Vora
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |