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

Edit mask for table name

Former Member
0 Likes
1,896

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......

1 ACCEPTED SOLUTION
Read only

kiran_k8
Active Contributor
0 Likes
1,603

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......

12 REPLIES 12
Read only

kiran_k8
Active Contributor
0 Likes
1,604

Shiva,

May be we have to use Dynamic Select Query.Check the related threads in SDN

K.Kiran.

Read only

Former Member
0 Likes
1,603

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

Read only

Former Member
0 Likes
1,603

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

Read only

former_member222860
Active Contributor
0 Likes
1,603

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).

Read only

viquar_iqbal
Active Contributor
0 Likes
1,603

Hi

check this thread

Read only

Former Member
0 Likes
1,603

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

Read only

Former Member
0 Likes
1,603

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

Read only

Former Member
0 Likes
1,603

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

Read only

Former Member
0 Likes
1,603

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

Read only

Former Member
0 Likes
1,603

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)??

Read only

0 Likes
1,603

Hey,

For this u've to create dynamic itab.

Search with the keyword Create Dynamic Internal Table

thanks\

Mahesh

Read only

0 Likes
1,603

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