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

How to pass variable value as a table name in select statement???

Former Member
0 Likes
3,635

How to pass variable value as a table name in select statement???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,730

You can use like this

SELECT * FROM (V_TABLE_NAME) INTO I_TABLE.

Regards

Kathirvel

You can use like this

SELECT * FROM (V_TABLE_NAME) INTO I_TABLE.

Regards

Kathirvel

7 REPLIES 7
Read only

Former Member
0 Likes
1,731

You can use like this

SELECT * FROM (V_TABLE_NAME) INTO I_TABLE.

Regards

Kathirvel

Read only

Former Member
0 Likes
1,730

Hi

PARAMENTER: P_TAB(30).

DATA: WA(1000).

SELECT * FROM (P_TAB) INTO WA.

ENDSELECT.

Now I'm not using 4.7, so I'm not sure if the stataments are right, but u can create a table:

DATA: MY_TABLE TYPE REF TO DATA.

FIELD-SYMBOLS: <MY_TABLE> TYPE TABLE.

FIELD-SYMBOLS: <MY_WA> TYPE ANY.

CREATE MY_TABLE TYPE TABLE OF (P_TAB).

ASSIGN MY_TABLE->* TO <MY_TABLE>.

SELECT * FROM (P_TAB) INTO TABLE <MY_TABLE>.

LOOP AT <MY_TABLE> ASSIGNING <MY_WA>.

ENDLOOP.

Max

Read only

Former Member
0 Likes
1,730

variable is V1 which have table name...

select * from (V1) into itab...

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,730

Hi,

Try this :

SELECT * FROM P_VAR INTO WORKAREA.

Rgds,

sands

Read only

anversha_s
Active Contributor
0 Likes
1,730

hi,

select * from (v_table_name) into table.

rgds

anver

Read only

Former Member
0 Likes
1,730

just like this.

DATA: zauth LIKE dd02l-tabname.


zauth = 'ZTABAUTH'.  "pass the table name 

     select single statu
      into sl_update
      from (zauth)
      where tabname = tabname
      and bname   = sy-uname.

regards,

VIjay

SAMPLE CODE ..

data: val like dd02l-tabname.

DATA : V_WERKS(4) TYPE C.

val = 'MARC'.

select single WERKS

into V_WERKS

from (VAL)

where MATNR = '000000000090004563' .

CHECK SY-SUBRC EQ 0.

WRITE:/ V_WERKS.

Message was edited by:

vijay k

Read only

Former Member
0 Likes
1,730

Hullo,

use the '(' and ')' to pass your variable:

Like:

SELECT * FROM (table_name).

Hope this helps.