Variable table name in the select statment ?

data: h_itab like hier_out occurs 0 with header line,
      table_name(30) type C.
here i declare h_itab as the variable for the table name
itab_name = input_name
input_name is imported
select * from table_name
       into table h_itab
       where OBJVERS = 'A'.
it does not allow me to use table_name in the select statement i get the error 'table_name is not defined i the abap dictionary as a table, projection view or database view'.
Any suggestions are highly appreciated.
Thanks in advance,
BWer

Hi,
You must enclose the name of the table in braces to let the compiler know that the value will be supplied at run time.
For example -
tables mara.
data table_name(30) type c.
table_name = 'MARA'.
SELECT *
  FROM (table_name)
endselect.
Regards,
Anand Mandalika.

Similar Messages

  • How can i pass a variable instead of a table name in the Select statement.

    Dear all
    how can i pass a variable instead of a table name in a select statement ?
    Example :-
    Begin
    P_get_procedure_tname (aap_name,otable_name);--It will take an application name and will return a table name
    Select col1 into ocol1
    from  ---- here i want to pass the variable OTABLE_NAME
    End;How can i pass this ?

    Hi,
    You can use dynamic sql.
    EXECUTE IMMEDIATE 'SELECT COL1 INTO ' || OCOL1 || ' FROM " || OTABLE_NAME;
    {code}
    cheers
    VT                                                                                                                                                                                                                                                                                                   

  • How to use a table name in the select statement using a variable?

    Hi Everybody,
                       I got a internal table which has a field or a variable that gets me some tables names. Now I need to retrieve the data from all these tables in that field dynamically at runtime. So could you suggest me a way out to use the select query which uses this variable as a table ?
    Regards,
    Mallik.

    Hi all,
    Actually i need some more clarification. How to use the same select statement, if i've to use the tabname in the where clause too?
    for ex : select * from (tab_name) where....?
    Can we do inner join on such select statements? If so how?
    Thanks & Regards,
    Mallik.

  • * table name in the select statements

    Hi,
      I have come across a select Statement as below.
    Select * into *nast from nast where <conditions>.. End select.
    what does this *nast represents and when is it used. why do we need to call a Table  with *<Table Name>
    Kind Regards,
    Usha

    hi,
    select statement will always points to a database table so we have to give database table name and it gets data from that table. for storing that data we have to use internal tables must have same structure of database table.
    so select statement has the following form as........
    select * from [dbtable] into table [internal table]
    endselect.
    in sap select will act as a loop so that we hav to use end sleect. select has different varities in sap. for some types no need of end select.
    for ex:
    select single *
    select * ..................... into table [internal table name].....
    if helpful reward some points.
    with regards,
    suresh.

  • Create Dynamic table name in the select statement.

    I use oracle reports 6i to make myrep.rdf , this report created using certain select query Q1, I created a formula column in this report,
    in the formula column  I write pl/sql block statements to select the data from certain table depends on the output of a column in Q1,
    I want to make the pl/sql block dynamically enough to change the user which I select the data from depends on the connected user
    Ex: if I connected with user = 'KAM14'
    the pl/sql block will be
    select x into v_value from kam13.bil_file where .....;
    and if  I connected with user = 'KAM13'
    the pl/sql block will be
    select x into v_value from kam12.bil_file where .....;
    and so on
    how can I do this in the pl/sql block ...
    Thanks in Advance.

    I am not sure I understood properly, but I think you should create bil_file table under a different user and create synonyms  under KAM1x users.
    Regards

  • How user variable table names in select statement

    Dear all,
    I have three table gp1,gp2,g3. i want user variable table in sql query
    for example at oracle forms have a list table showing table names gp1,gp2,gp3
    at form i want user this query
    select gpno from :table where gpno=120;
    how i can specify table name Dynamicly in select query
    Thanks

    Forms_DDL is a one-way street: You can only pass DDL commands TO the database; you cannot get data back using Forms_DDL.
    Exec_SQL is the Forms package that enables dynamic sql within a form. But to retrieve data, you have to make a Exec_SQL call for every column in every row. So it is not a good thing to use, either.
    The ref cursor method should work. You could also retrieve the data into a record group using populate_group_with_query -- it also enables dynamic data retrieval.
    But if you already know you have three distinct tables and you know their names, I would keep it simple and just write three sql select statements.

  • How to find table name for the fields from Standard Extractor in CRM system

    How to find table name of fields from the standard extractor in CRM system ?
    e.g. We use LBWE TCode in R/3 system to find table name for the field from Extractor VCSCL(e.g.).
    Likewise is there any way to find table name for the fields from Standard extractor like 0CRM_LEAD_I.

    Hi ,
    Please find the link below for understanding BW CRM analysis.
    http://help.sap.com/bp_biv135/html/bw.htm
    activate the CRM DSs by scenario:
    1) Activate the application component hierarchy (tcode RSA9). Changes made to the application component hierarchy in the CRM system can be transferred to the BW using the "Edit Application Component Hierarchy" (SBIW - Postprocessing of DataSources).
    SAP Note 434886 must be implemented in CRM 3.0 before the application component hierarchy is activated.
    2) Activate the Business Content DataSources (tcode RSA5).
    Select/enter the application component and choose Execute (F8).
    To compare the shipped and active versions, choose the 'Select Delta' pushbutton. If there is no active version of the DataSource, it is selected automatically.
    To activate the shipped version, choose the 'Transfer DataSources' pushbutton.
    3) Management of the versions of the BW-Adapter metadata (tcode BWA5). All DataSources are displayed that are managed by the BW Adapter.
    As in transaction RSA5 (Service API Metadata Activation), the 'Select Delta' function can be used to select the inactive DataSources or compare shipped and active versions.
    You can also go directly to the screen for maintaining DataSources that are managed by the BW Adapter.
    The 'Compare Version' function makes a detailed comparison of the shipped and active versions.
    All BW-Adapter metadata is considered when versions are compared:
    Header information (Table SMOXHEAD)
    Mapping information (Table SMOXRELP)
    Global selection conditions (Table SMOXGSEL)
    Attribute key fields (Table SMOXAFLD)
    Hope this helps.
    Regards,
    csm reddy

  • Using column value is it possible to find the table name in the database?

    Hi all,
    using column value is it possible to find the table name in the database?
    guys i need the table value
    Note:
    oracle-9i
    for example:
    i don't know NIC(column value) in which table in the database.
    Thank you,
    with regards,
    JP.
    Edited by: Guest on Feb 27, 2012 5:42 AM

    Hi,
    As far as I understand what you are asking for I would suggest 4 data dictionaries that will help you to know the table name from the column names
    1. USER_TAB_COLS
    2. ALL_TAB_COLS
    3. DBA_TAB_COLS
    4. COLS
    These can give you detail information about the columns and respective tables at user, schema, dba level. Further information on the table can be found by querying ALL_OBJECTS table giving table_name as Object_name, or you can join the data dictionaries too.
    To know about various data dictionaries avalible in Oracle please query select * from cat;
    Let us know if you need further assistance.
    Twinkle

  • Can anyone tell me the field name, table name for the following scenario?

    Hi All,
    Can anyone tell me the field name and the respective table name for the following scenario's?
    1. A report to list all the materials to which Invoice is done and delivery is pending.
    2. A report for Order tracking.
    3. A report, which gives PO(Purchase Order),  Pricing details.
    4. A report, which calculates the MATERIAL COST. It will select all the material issued for the entered service order number from  stock.
    Thanks & Regards,
    P.Gowrishanker
    Edited by: Gowrishanker pari on Jun 1, 2008 8:58 AM

    I believe that OmniVision Technologies has the contract for the 3gs.

  • Using distinct and orderby in the select statment

    Hi All,
    Can anyone tell me what is the purpose of using distinct and orderby in the select statment.

    Hi,
    Using the distinct function with more than one column yields some substantial results. SQL will return the rows with distinct or unique combinations of those columns. Assume this same employee table has another column including the salary of each employee. With the use of the distinct function we can pull a list of unique job titles - salaries.
    SQL Code:
    SELECT DISTINCT job_titles, salary FROM employees;
    SQL has returned all the rows with unique combinations of job titles and salaries. Any duplicate combinations of job titles and salaries will be ignored. For example if we had two CEOs in the table making the same salary each year, only one row would be returned but if we had two CEOs with different salaries, both rows would be returned.
    Order by
    The SQL ORDER BY clause comes in handy when you want to sort your SQL result sets by some column(s). For example if you want to select all the persons from the already familiar Customers table and order the result by date of birth, you will use the following statement:
    SELECT * FROM Customers
    ORDER BY DOB
    As you can see the rows are sorted in ascending order by the DOB column, but what if you want to sort them in descending order? To do that you will have to add the DESC SQL keyword after your SQL ORDER BY clause:
    SELECT * FROM Customers
    ORDER BY DOB DESC
    If you don't specify how to order your rows, alphabetically or reverse, than the result set is ordered alphabetically, hence the following to SQL expressions produce the same result:
    SELECT * FROM Customers
    ORDER BY DOB
    SELECT * FROM Customers
    ORDER BY DOB ASC
    You can sort your result set by more than one column by specifying those columns in the SQL ORDER BY list. The following SQL expression will order by DOB and LastName:
    SELECT * FROM Customers
    ORDER BY DOB, LastName
    if its useful reward points

  • About table control in the selection screen

    i want to create a table control in the selection screen of my report.i can create the table control using SE51.but how to program with the table control in the report.for example i should fetch the data for the personnel nos entered in the table control of the selection screen.how to do this.can any of u provide sample code for this.
    thanks.

    Hi vadivel,
    Create internal table and create table control using same internal table
    e.g.
    data : begin of it,
           end of it.
    start-of-selection.
    call screen 100.
    If you create table control using wizard then code automatically come here.
    Now, Put one push button in same screen where table control is available. let's say push button Display report.
    Now, use export <IT> to memory id <ID> and submit report <report name> and return. now, define same internal table in this submitted report and use import <IT> from memory id <ID>. Now, table control data is available in internal table, use that data and make code as per your requirement. If you dont want to use push button then use menu bar and at user-command event.
    Hope this help
    Regards,
    Parag

  • Need the the underlying table names which the Material Plan Detail Search p

    Our supply planning users would like to obtain the demand and supply plan for a bunch of given parts by running a query against some tables. The data they need via a PS Query output in Excel format is the same data that is provided by the Material Plan Detail page in PeopleSoft Supply Planning (Menu Path: Supply Planning >>>Solve Plan>>>> Material >>>>>>Material Plan Detail). The main underlying table behind this page is PS_PL_MRP_DTL.
    The problem is that this table contains data for only one Part Number (INV_ITEM_ID). The data is populated when Item ID is selected on the Material Plan Detail Search page.
    What are the underlying table names which the Material Plan Detail Search page brings together to present the information for the selected part number on the target page (The Material Plan Detail page)?
    If you could tell us the underlying table names (which the Material Plan Detail Search page brings together) we can write a query to present the data to the users for multiple part numbers at a time and not just one part number at a time.
    Any help would be greatly appreciated.
    We are on FSCM 8.9 Bundle 13
    Thanks in advance.

    The ERD's for FSCM 8.9 are available from following link
    PeopleSoft Enterprise Financial Management 8.9 Entity Relationship Diagrams [ID 979359.1]
    https://support.oracle.com/epmos/faces/DocContentDisplay?id=979359.1
    Hope it contains the info you are looking for.
    Hakan

  • Creating a form with variable table name(s)

    Hi,
    I am building a form that will allow user(s) switch to other user
    (s) dynamically. I have been able able to do this by creating a
    non-database table and use record group to read from the base
    table of each user.(All the tables in question have the same
    structure).
    Record group is a read only, and I want to be able to do data
    maninpulation with this form.
    The questions are
    (1) It possible to do data manipulation with record group and if
    it is, how?
    (2) Is it possible to build a form with a variable table name?
    if possible, how?
    Somebody pls help.
    Thanks,
    Olutunde.
    null

    Olutunde Babarinsa (guest) wrote:
    : Hi,
    : I am building a form that will allow user(s) switch to other
    user
    : (s) dynamically. I have been able able to do this by creating a
    : non-database table and use record group to read from the base
    : table of each user.(All the tables in question have the same
    : structure).
    : Record group is a read only, and I want to be able to do data
    : maninpulation with this form.
    : The questions are
    : (1) It possible to do data manipulation with record group and
    if
    : it is, how?
    : (2) Is it possible to build a form with a variable table name?
    : if possible, how?
    : Somebody pls help.
    : Thanks,
    : Olutunde.
    Hi,
    you can create and manipulate record groups at runtime(see Forms
    Reference 'Create_Group' and 'Add_Group_Row') don't use
    Create_Group_from_Query. For your purpose it's better to build a
    cursor loop on your Query and add your datas after
    manipulating with 'Add_Group_Row' to your Record Group.
    It's possible to SET_BLOCK_PROPERTY(QUERY_DATA_SOURCE_NAME) but
    it's not possible to change the item property 'Column Name'.
    Therefor I would suggest to build a non database block and
    populate these block by a programm unit, which works with a
    pl/sql cursor loop and the 'create record' to populate these
    block.
    null

  • Checking the select statment

    hi,
    the select statment is
    SELECT SINGLE * FROM edidc WHERE docnum = l_docnum AND direct = '1' AND status = '3' AND mestyp = 'OILSHL'.
    there is an entry in the table edidc for the mentioned conditions.
    but it is returning sy-subrc = 4.
    please check what  is the wrong in the statement and provide me the solution for that.
    it is very urgent......
    thanks in advance....

    <b>please  use the below  program for getting it</b>  ....
    REPORT ZTES_12 .
    TABLES  : edidc .
    SELECT-OPTIONS  :  l_docnum  FOR edidc-docnum .
    DATA :   ITAB   TYPE  TABLE OF  edidc ,
             ITAB_WA   LIKE  edidc .
    SELECT  * FROM edidc INTO TABLE ITAB  WHERE docnum  IN l_docnum AND
    direct = '1'
    AND status = '29' AND mestyp = 'MATQM'.
    LOOP AT  ITAB  INTO  ITAB_WA .
    WRITE / : ITAB_WA-docnum .
    ENDLOOP.
    reward  points if it is usefull .....
    Girish

  • Bex Query: Too many table names in the query The maximum allowable is 256

    Hi Experts,
    I need your help, Im working on a Query using a multiprovider of 2 datastores, I need to work with cells to assign specific acconts values to specific rows and columns, so I was creating a Structure with elements from a Hierarchy, but I get this error when I'm half way of the structure:
    "Too many table names in the query. The maximum allowable is 256.Incorrect syntax near ')'.Incorrect syntax near 'O1'."
    Any idea what is happening? is ti possible to fix it? do I need to ask for a modification of my Infoproviders? Some one told me is possible to combine 2 querys, is it true?
    Thanks a lot for your time and pacience.

    Hi,
    The maximum allowable limit is 256 holds true. It is the max no. of characteristics and key figures that can be used in the column side. While creating a structure, you create key figures (restricted or calculated) and formulas etc.. The objects that you use to create these should not be more than 256.
    http://help.sap.com/saphelp_nw70/helpdata/EN/4d/e2bebb41da1d42917100471b364efa/frameset.htm
    Not sure if combination of 2 query's is possible.  You can use RRI. Or have a woorkbook with 2 queries.
    Hope it helps.

Maybe you are looking for

  • How do I add different sites to search engines

    How do I add other search engines or sites to my drop down list? When I visit a site nothing comes up in the drop down menu to 'add it' like the instructions say and you can't manage it to add. I want to add Dogpile and at the Dogpile site it says 'a

  • Multiple Thumb Slider with Multiple Track Colors

    Hi All, Does any one implemented a Multiple Thumb Slider component with Multiple Track Colors. Please find the screen shot of the component below which I am talking about. Any ideas or any link or sample source of code given would be highly appreciat

  • CS6 will not read/open Sony a6000 raw files

    Have just purchased a Sony a6000 and I shoot in raw. When I came to retrieve the files from Bridge in CS6 it will not open them. The software shows up to date and if I try to open directly in CS6 nothing shows up. My Nikon downloads fine in raw. Plea

  • Type= Glyph Ordering (Illustrator CS5)

    I guess I will just be showing my age if I reference one of Bob Newhart's best routines. In the one where he is the publishing house executive handling an inquiry from some guy on the line named Noah Webster, the conversation ends with the suggestion

  • Title as a Dr in XD01

    Dear Gurus Sub: How can I add Title in Customer i.e IN Mr. and Ms. place I need to add Dr. also as a Prefix even I serched in SPRO " Set Up Prefix " in Ctrl + F but it is not showing path can any body help me on this Regards Sudha