Extracting Multiple Table Data Dynamically..Table is an Input parameter

Hi All
Can any one update the Program/design of extracting multiple table data as a list or to an excel sheet
For eg:- Mutliple Tables are entered in selection screen and upon executing the output should be to an excel sheet sequenctially according to the table names entered in the selection screen
Awaiting for your update
Edited by: shivakumar bandari on May 29, 2009 9:35 PM

HI Naimes
Thanks for youe reply
your second step says to select data from 'table' here tables are dynamic in nature I mean they are an input parameters..how can I write select on a table..
I can get the table existence from DD02L table and pass the retrieved tables to FM Get_Component_List to get the fields existing for the particular table,
But I cannot pass the dynamic table value to select query to retrieve the data..Please update me if you have anything on retrieving data from dynamically inputted value
Can I do this
Select * from <dyntable>
Any suggestions will be appreciated
thank you

Similar Messages

  • How to Populate Internal table data to Table Control in a Report Program

    Dear All,
           How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
    Thanks in Advance,
    Joseph Reddy

    If you want to use a table control, you will need to create a screen.
    In your report....
    perform get_data.  " Get all your data here
    call screen 100. " Now present to the user.
    Double click on the "100" in your call screen statement.  This will forward navigate you to the screen.  If you have not created it yet, it will ask you if you want to create it, say yes.  Go into screen painter or layout of the screen.  Use the table control wizard to help you along the process.  It will write the code for you.  Since it is an output only table control, it will be really easy with not a lot of code. 
    A better way to present the data to the user would be to give it in a ALV grid.  If you want to go that way, it is a lot easier.  Here is a sample of the ALV function module.  You don't even have to create a screen.
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          maktx type makt-maktx,
          end of imara.
    * Selection Screen
    selection-screen begin of block b1 with frame title text-001 .
    select-options: s_matnr for imara-matnr .
    selection-screen end of block b1.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      select  mara~matnr makt~maktx
                into corresponding fields of table imara
                  from mara
                   inner join makt
                     on mara~matnr = makt~matnr
                        where mara~matnr in s_matnr
                          and makt~spras = sy-langu.
    form write_report.
      perform build_field_catalog.
      call function 'REUSE_ALV_GRID_DISPLAY'
                it_fieldcat = fieldcat
                t_outtab    = imara.
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      fc_tmp-col_pos    = 2.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.
    Rich Heilman

  • How to compare table data and table field

    Hi buddy,
        I have some question about how to compare table data and table field.
       1. I know there is one method:   CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS  , it use in unit test to compare the table data(A and B) , you can loop table A into structure A1, then use this mehtod it can compare whether table B contain structure A1.  but when I try to use this in main program it will dump.
                                                                                                        LINE    = A1
                                                                                                        TABLE = B ).
           Is there any method or FM can be used to compare the table data ?
        2. I also want to compare two table field , try to find out the different. How to realize this.
    Thank you for your sincerely answer.

    Hi Zongjie,
    What`s the difference, if you using loop A into wa_A, read table B into wa_B with all field, then compare with wa_A and wa_B.
    The question 2, seems no standard FM available here.
    Loop A into wa_A.
       Loop B into wa_B.
           if wa_A-field1 eq wa_B-field1.
            if wa_A-field2 eq wa_B-field2. 

  • Left table data Right table multiple returns

    Hello all and thank you for taking the time to help.
    I have a left table and right table I am querying from 2 remote hosts. The information in the left table is unique and has everything I need except for 2 fields; the information in the right table can have multiple rows for the same identifier. I am trying to get the latest rows information on the right. This is a snapshot of the tables:
    Employee Table
      Emp_num       Emp_Name   Emp_Store     Emp_Category     Emp_Location
      W561789        Chris           R79                Sales     98-778-77
      W571779        Charles           R81                Sales     87-988-98
      W561874        Sam           R79                Management     76-977-97
    W561875        Tod           R79                Sales     98-778-77
    Customers Table
      Emp_num    Wait_Time  Shipment_Status      Shipment_Date
      W561789     1
      W561789                          Shipped               2/28/2011
      W561789                          On_Order             2/27/2011
      W561875                          On_Order             2/27/2011What I am trying to pull is specific information from the Employee table, and only the most recent matching record from the Customer table. My query looks something like this (it doesn't work, or it takes a really long time to run)
        [email protected]_A_LINK  D,
                             ROW_NUMBER() OVER(PARTITION BY EMP_NUM ORDER BY SHIPMENT_DATE) rownumber
                 FROM [email protected]_B_LINK) M
    AND rownumber=1
    AND D.EMP_CATEGORY IN ( 'Sales',
    AND D.EMP_LOCATION IN ( '98-778-77', '87-988-98')thanks

    Just to close the loop on this question, I figured it out. I had to move the ROW_NUMBER() alias outside the scope of the WHERE clause. The query looks like this:
        [email protected]_A_LINK  D,
                                ROW_NUMBER() OVER(PARTITION BY EMP_NUM ORDER BY SHIPMENT_DATE) AS rownumber
                               [email protected]_B_LINK
            WHERE rownumber=1) M
          AND rownumber=1
          AND D.EMP_STORE='R79'
          AND D.EMP_CATEGORY IN ( 'Sales',
          AND D.EMP_LOCATION IN ( '98-778-77', '87-988-98')

  • WD4A Dynamic ALV Table with dynamic tables

    Hi all,
    first I want give you the information what I try to do.
    I have an another WD4A application for administrative use in which I can assign certain tablefields to a certain user. You can say it's something like a customizing application.
    In the next application (with my issues) I will display the tables for the user, but these tables are not the complete table.
    I have a node in my context of the component controller which is bound to my ALV. I add during the runtime attributes to my node.
    * .... coding ....declaration
    * get the node
      lr_node = wd_context->get_child_node( 'M_TABLE' ).
      lr_node_info ?= lr_node->get_node_info( ).
    * remove the attributes, if exists
      lr_node_info->remove_dynamic_attributes( ).
    * .... coding ....
    *   add attributes
        LOOP AT l_t_m_table INTO l_s_m_table.
          CLEAR ls_attribute.
    *     name of the attribute
          MOVE l_s_m_table-NAME TO ls_attribute-NAME.
    *     DDIC type of the attribute
          MOVE l_s_m_table-TYPE_NAME TO ls_attribute-TYPE_NAME.
    *     If the DDIC has a gen namespace like /B135/ replace the / with _
          REPLACE ALL OCCURRENCES OF '/' IN ls_attribute-NAME WITH '_'.
    *     add the attribute
          lr_node_info->add_attribute( EXPORTING
                                         attribute_info = ls_attribute ).
    This coding works fine I get the columns in my ALV. Then I tried to fill my ALV table with data from a database table.
    I created dynamicly an internal table with the following coding:
    *   Create dynamic table
            IT_FIELDCATALOG = l_t_FLDCAT
            EP_TABLE = l_t_NEW_M_TABLE.
    *   assign the table
        ASSIGN l_t_NEW_M_TABLE->* TO <M_TABLE>.
    *   structure of table
        ASSIGN l_s_NEW_M_TABLE->* TO <l_s_m_table>.
    * get data from database
    With this coding I get the data from the database and only the required fields that means I have e.g. an itab with columns1, columns3, columns4 from the database.
    I also added e.g. these columns  (columns1, columns3, columns4 from the database) to the node as attribute. Now it should be possible to bind the table to the structure with this coding:
    lr_comp_usage_m = wd_this->wd_cpuse_usage_alv_M_table( ).
    *   create component if not active
        IF lr_comp_usage_m->has_active_component( ) IS INITIAL.
          lr_comp_usage_m->create_component( ).
    * set data if node exists
          l_ref_interfacecontroller = wd_this->wd_cpifc_usage_alv_M_table( ).
          l_ref_interfacecontroller->set_data( lr_node ).
    *   bind table
        lr_node->bind_table( <M_TABLE> ).
    Now, I get an error, which is caused by the table binding.
    In ST22 I get:
    Short text
        Line types of an internal table and a work area not compatible.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "CL_WDR_CONTEXT_NODE_VAL=======CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        The statement
           "INSERT wa INTO TABLE itab"
        requires the lines of the internal table "TABLE" and the
        work area " wa" to be compatible. Compatibility means
        equivalence in the context of ABAP/4 type checking.
        In this case, the condition is not satisfied because the internal table
        "TABLE" has the line type "u" and the length 28, but the work area " wa"
        has the type "C" and the length 2.
        (If the work area " wa" is the header line of the internal
        table "TABLE", the above inconsistency can arise if an internal
        table t with the line type T1 is passed to a subroutine (FORM or
        FUNCTION) as an actual parameter and the corresponding formal
        parameter p is declared in the subroutine by "TABLES p STRUCTURE T2".
        If then T1 and T2 are incompatible, the header line p
        has the type T2 (specifed by STRUCTURE), but the internal
        table p has the line type T1 (passed from the actual parameter)).
    Source Code Extract
    Line  SourceCde
        1 method if_wd_context_node~get_static_attributes_table .
        3   field-symbols:
        4     <element> like line of me->collection,
        5     <static_attributes> type data,
        6     <table> type index table.
        8 * check whether elements are supllied or not
        9   if me->elements_supplied = abap_false.
       10     me->supply_elements( ).
       11   endif.
       13   clear table.
       15   if me->table_ref is not initial.
       16     assign me->table_ref->* to <table>.
       17     table = <table>.
       18   else.
       19     loop at me->collection assigning <element> from from to to.
       20       assign <element>->static_attributes->* to <static_attributes>.
    error in line 21       insert <static_attributes> into table table.
       22     endloop.
       23   endif.
       25 endmethod.
    Any suggestions? Is it allowed to use bind_table() with a field symbol?
    Another strange thing is that if I try the same with static itab and attributes during runtime it works, but only if the fields of the itab has the same name as the attributes, which means that I can not use itabs with fieldnames like /BI0/S_CUSTOMER and if I can not use them it's difficult to read data from database with SELECT * FROM ... INTO CORRESPONDING FIELDS OF TABLE itab.
    Thanks in advance for your suggestions!
    Best Regards,

    Hi Francois,
    I solve it with the RTTI and the method    
    lr_node_info = lr_node_info->add_new_child_node(
                          name = 'Dynamic_TABLE'
                          IS_MANDATORY = ABAP_false
                          IS_MULTIPLE = ABAP_true
                          STATIC_ELEMENT_RTTI = lr_struct_descr
                          IS_STATIC = ABAP_false
    I don't know why it doesn't work with adding attributes and binding the table after adding the attributes.
    Anyway thanks for your help.
    Best Regards,

  • Create table with dynamic table name.

    I'm trying to create a table
    select x.*,  convert(nvarchar(20), getdate(), 101) AS LoadDate
    into table1_20140512
    from (
           select c1,c2,c3 from table2_20140512
           WHERE(LoadDate = (select MAX(LoadDate) FROM table2_20140512   )
           union all
        select c1,c2,c3 from table3_20140512
          WHERE(LoadDate = (select MAX(LoadDate) FROM table3_20140512  )
    ) X
    I want to make table name dynamic, like 'table1'+toady's date
    I declared three variables, but they didn't work as I expected  
    These are my variables
    DECLARE @table1 nvarchar(500)
    DECLARE @table2 nvarchar(500)
    DECLARE @table3 nvarchar(500)
    SET @table1='H1_' +(CONVERT(VARCHAR(8),GETDATE(),112))
    SET @table2='H2_' +(CONVERT(VARCHAR(8),GETDATE(),112))
    SET @table2='H3_' +(CONVERT(VARCHAR(8),GETDATE(),112))

    Try the following:
    DECLARE @SQL nvarchar(2000);
    DECLARE @table1 nvarchar(500) ='H1_' +(CONVERT(VARCHAR(8),GETDATE(),112));
    DECLARE @table2 nvarchar(500) ='H2_' +(CONVERT(VARCHAR(8),GETDATE(),112));
    DECLARE @table3 nvarchar(500) ='H3_' +(CONVERT(VARCHAR(8),GETDATE(),112));
    PRINT @table1+' '[email protected]+' '[email protected];
    --H1_20140512 H2_20140512 H3_20140512
    SET @SQL = 'select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate
    into '+QUOTENAME(@table1)+'
    from (
    select c1,c2,c3 from table2_20140512
    WHERE(LoadDate = (select MAX(LoadDate) FROM '+QUOTENAME(@table2)+' ))
    union all
    select c1,c2,c3 from table3_20140512
    WHERE(LoadDate = (select MAX(LoadDate) FROM '+QUOTENAME(@table3)+' ))
    ) X '
    PRINT @SQL; -- debugging
    /* select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate
    into [H1_20140512]
    from (
    select c1,c2,c3 from table2_20140512
    WHERE(LoadDate = (select MAX(LoadDate) FROM [H2_20140512] ))
    union all
    select c1,c2,c3 from table3_20140512
    WHERE(LoadDate = (select MAX(LoadDate) FROM [H3_20140512] ))
    ) X
    EXEC sp_executeSQL @SQL;
    Dynamic SQL examples:
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Declaring field from the internally declared table into dynamic table

    Hi Gurus,
    I need your help on one of my requirements.
    Due to dynamic nature of ALV report, I have used a dynamic internal table to pass it to function module.
    In dynamic tables, I am trying to have one column form the internal table which is being calculated by substracting 2 fields( i,e. diff = wa_stk-labst - wa_stk-omeng). Is it possible to include that field (diff) which is coming from the internally declared table(i_out) into the dynamic table decleration. Please assist.
    Thanks in Advance

    Suppose your dynamic table is of type table.
    When you pass the data from internal table I_OUT to your dynamic table it will get the same structure as of your internally declared table IT_OUT which is calculated by subtracting 2 fields.
    What you can do is create one more field in I_OUT which holds the value of the subtracted amount then pass the table IT_OUT to your dynamic table.

  • Pass Structured table into dynamic table parameter in public method

    Ladies and Gentlemen,
    I have a requiremet to pass (1 at a time) any number of tables into a reuseable method in a custom class.  The Method code is as follows:
    * Importing VALUE( IV_PATHNAME )  TYPE PATHEXTERN File Destination
    * Importing VALUE( IT_FILE_RECORD ) TYPE REF TO DATA  Table with Output
    * Importing VALUE( IV_DELIMITER )     TYPE STRING     File Delimiter
    * Exporting VALUE( EV_RECORD_CNT )  TYPE STRING Record Count
            ls_line_cnt(6) type n,
            lt_data_struc  type zty_ddic_struc_T,
            ls_string      type string.
      field-SYMBOLS: <fs_string> type any.
    * Open Dataset for outputting file details
      Open dataset iv_pathname for output in text mode encoding default.
      Assign ls_string to <fs_string> CASTING TYPE (iv_record_structure).
      loop at it_file_record into <fs_string>.
        transfer <fs_string> to iv_pathname.
        Add 1 to ls_line_cnt.
        clear <fs_string>.
      ev_record_cnt = ls_line_cnt.
    where IV_PATHNAME = output destination & filename
                IT_FILE_REC     = data table
                IV_RECORD_STRUCTURE = is ddic structure definition for the data table
                IV_DELIMITER = file delimiter, in this case, let's say it's C (for CSV)
         and EV_RECORD_CNT is a count of numbe of records processed.
    Lets say, for example, I wish to load data from table SFLIGHT into the method when program A is executed.  Then another time I wish to excute Program B which is passing in data of table  SFLCONN2.  I hope that by using the "type ref to data" defintion, I can pass the table contents through. Is this true?
    Secondly, I'm getting a syntax error saying that "IT_FILE_RECORD" is not defined as a table (and therefore can't be looped at), and therefore can't be read.  How can I access the data in this table in preparation for output.
    Any assistance or thoughts would be greatly appreciated.

    Hi Stephen ,
    Graham already gve part of the solution.
    If you declare
    it does not make sense to declare to pass by VALUE because you will not change this refernce in the method. Calling this method, you must pass a refefernce.
      lr_ref type ref to data.
    get reference of <your itab here> into lr_ref.
    In the method, it goes as graham explained.
    Anyway, I would declare the table parameter as
    The your code could work, but you will have troube with any non-character fields in the tables.

  • New page in smart form when displaying internal table data in table

    Hi ,
    My requirement in smartform is like
    I'm using the tables to display the internal table data in main window .
    based on SORTF field in the internal table ,when SORTF field value changes all the related to that SORTF value should be displayind in the new page.
    Please anybody tell me that , how to do this?

    Hi Navi,
        Try this Logic.
    1) Go to Smartform,
    2) Declare a flag variable w_flag type c
    3)Go to Main Window
       a) Go to table
       b) Create one more Table Line
       c) Create a CODE Line in that.
           write inside CODE  as Below:-
                 CLEAR: w_flag.
                 ON CHANGE OF w_final-sortf.
                   w_flag  = 'X'.
       d) Create one COMMAND Under CODE line created above.
           click on check Box "Go to New Page"  ( Page1 or Page2 or give as reqd ).
           click on conditions tabe of COMMAND
           write: w_flag = 'X'.
    Hope this will work
    Reward Points if Useful

  • How to change the image dynamically depend upon the input parameter

    Hi All
    I have one report running depend upon the Organization specific, I have 15 operating unit and 15 different logo for each operating unit.
    How to change the Logo dynamically depend upon the input passed by the user.
    If I have three or four logo i can add in my layout using if else statement and its works fine but i have more that 10 logos so its no possible to keep these in My RTF Template.
    Is it possible to change the logo according to the input without keeping this in Template.
    I have seen this link but its not working fine

    I have not completed fully,so sorry i cant able to share the files, could you please give me some tips and steps to do.
    Without having the logo in RTF if it possible to bring the logo depends on the user input (Ie Operating unit).

  • How to get Dynamic table data  in table

    Actually i want to generate a table by a query . now i m able to get the data in java class but i don't know that how to present that data in a table form in UIX page.

    HI using this methods u can create dynamic internal tables,
          EP_TABLE        = GFINAL.
    Please let me know once the requirement clearly , is the fm or Method importing parameter is internal table , corresponding to that
    internal table you need to fetch data from data base.
    In general , field symbols holds some memory in memory area , I think just like pointers in C language , this holds address only , there we dynamically assign some structure .
    Let me know once if u not cleared ,

  • Get multiple selection data of Table into an internal table

    Hi Guys,
    I have a Table in my view layout and selected 'SelectionMode' as 'Multi' in the table properties.How to get the selected data into an internal table when rows selected on the table output.For example,I have a 10 rows in the table and selected only 5 rows,need to get these 5 rows into an internal table?

    Here is some sample code. Please try this and let me know if you are still getting any errors.
    DATA lo_nd_table_node TYPE REF TO if_wd_context_node.
      DATA lo_el_table_node TYPE REF TO if_wd_context_element.
      DATA ls_table_node TYPE wd_this->element_table_node.
      DATA lt_table_node TYPE wd_this->elements_table_node.
      DATA lt_table TYPE wdr_context_element_set.
      lo_nd_table_node = wd_context->get_child_node( name = wd_this->wdctx_table_node ).
      lt_table = lo_nd_table_node->get_selected_elements( including_lead_selection = abap_true ).
      LOOP AT lt_table INTO lo_el_table_node.
            static_attributes = ls_table_node ).
        APPEND ls_table_node TO lt_table_node.
        CLEAR ls_table_node.
    lt_table_node contains the selected rows.

  • Dynamic Data: Dynamic Table

    Hey guys,
    probab;y a simple solutino, but after trying a few
    extensions, they either don't work, or I get an error saying can't
    apply as it would require changing code from a template.
    so how does one alternate the row colors of a dyanamic table
    without doing it by hand?
    thanks, Mark

    > probab;y a simple solutino, but after trying a few
    extensions, they either
    > don't work, or I get an error saying can't apply as it
    would require
    > changing
    > code from a template.
    > so how does one alternate the row colors of a dyanamic
    table without doing
    > it
    > by hand?
    Don't know about your template problems since I don't use
    them, but here
    is the snippet for alternating table row colors:
    <!--- Paste this function in a component or .cfm page
    <cffunction name="AlternateColor" access="public"
    <!--- Arguments --->
    <cfargument name="color1" type="string">
    <cfargument name="color2" type="string">
    <cfargument name="row" type="numeric">
    <!--- Alternate Colors --->
    <cfif arguments.row MOD 2>
    <cfset thiscolor = arguments.color1>
    <cfset thiscolor = arguments.color2>
    <!--- Return The Color --->
    <cfreturn thiscolor>
    <!--- Inside a loop (query, cfoutput, or otherwise) paste
    this code.
    Change colors and row identifier to suit needs --->
    <cfset color = AlternateColor(color1="##FFFFFF",

  • Update internal table data from table control

    Hi GURUS,
    I need help regarding one of my requirement.
    I need to display data from the internal table on the screen and when the user selects a record/multiple records from screen and clicks on approve button i need to update one of the field from N to Y in the corresponding Ztable. Once the record is updated from Ztable , that should no longer be visible for the user on the screen.
    I am using table control wizard to display data. I am able to update the Ztable, but that record is not refreshing from the user screen. Any suggestions would be approved.
    Also please let me know if table control is the best way to do this/ alv grid control??

       REFRESH CONTROL Control-Name FROM SCREEN '0100'  -> use this command to refresh the table control
    to know more, read into
    if helpful, reward
    Sathish. R

  • WAD : 2 Queries in 2 tables : How to get only one input parameter ? :-(

    In my WAD Report, I've several tables ( each include a query result ). Those query have one variable ( which is a range of month ).
    How can I link the range of month to all my queries ?
    ( for the moment, the parameters(variables) screen display as much month variable as query )

    u should use the same variable across all your queries.In the WAD there is a propoerty "display same variable once". Check that.
    hope it helps,

Maybe you are looking for

  • My camera won't open correctly when wanting to take a photo in a text after upgrading my hardware....

    TThe camera isn't opening correctly when I want to take a picture in a text message.

  • Unsupported value: "inline-block"

    Creating a form using labels inline-block value is not supported in Netscape,IE,IE for MAC,Safari,and Opera. Attached is the CCS rules anyones know of a fix @charset "UTF-8"; /* CSS Document */ #titlebar { height: 558px; width: 144px; float: left; ba

  • Editing profile info - website field

    Hello, wondering if anyone can help:  years ago when I set up my skype profile I added also a link to my blog in the 'website' field.  Now I'd like to remove it but surprise ! that field is no longer visible/available when I open the 'edit profile' s

  • Freezes Up, HELPPPP

    I need help, while im playin City of Heros, like a lil while of playin the game my comp freezes the screen turns gray and then i have to restart. Ive checked my voltages and temps when coolnquiet core cell, and it all seems fine and i checked my vc t

  • Trying to do an 'if' function need help

    I have four values that I want to input into a field. What I am trying to make happen is when you type in a letter, that text field will then highlight or fill to a certain color. Can anyone help me? And I want to have four values in it. The values w