Skip to Content
author's profile photo Former Member
Former Member

Read table, table name in variable

Hi all,

I am try trying to do the following.

Select statement to get the table name --> store in tname (variable).

Now, I have to do a select to read the data in this table (table name is in tname variable) based on some conditions

How do I do this?

1st step

Select ME_TECH from RSAC into tname

where NAME = 'PLANT'

and DATEFROM <= ldate

and DATETO >= ldate.

2nd step??

..........................................?

Thanks,

Anirudh.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 08:38 PM

    Use Field Symbols

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 08:40 PM

    Hi,

    Select * from (Tname) into corresponding fields of table ITAB1.

    Note: the braces are close, there is no space between the brackets and the word.

    Regards,

    Subramanian

    Edited by: Subramanian PL on Jul 22, 2008 1:41 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 08:41 PM

    Hi,

    Please search in SDN with the keyword..Dynamic internal table..I am sure you will get lot of posts on this..which discuss about populating the data from a table name which is dynamic..

    Thanks

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 22, 2008 at 08:50 PM
    report ztest.
    
    parameters: p_table type dd02l-tabname.
    
    field-symbols: <fs> type standard table." of (p_table).
    
    
    select * from (p_table)
    into table <fs>
    up to 20 rows.

    There is another way using CL_ALV_TABLE_CREATE, for this you have to pass the fieldcatalog.

    it return the internal table reference. using that you can proceed.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 03:28 AM

    Hi,

    When u want to fetch the data in a variable use select single stmt.

    select single ME_TECH from <tablename>

    into <variable name>

    where <conditions>

    Sharin.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.