Select from a dynamically chosen table

Hi everyone,
I'm willing to retrieve information stored in a given column of a given table, both generated dynamically. Thus, I have a string S1 with the table name and a string S2 with a column name of this table.
My aim would be to do something like that :
+select single * into corresponding fields of X
from (S1)
where Y = 'SomeValue'.+
X being like a line of the table (S1)
Y being the column name stored in S2.
But for this, I need to fine a correct way to define X and Y from S1 and S2, which I failed to do until now. My first idea was to use field-symbols but it didn't help me. It might be quite easy or maybe impossible, I don't even know as my knowledge in ABAP is far from being excellent, but any reply would be welcome.
Best regards,
François

Hi,
if you only want to select only the given column(s)
(here 'BUTXT') use the 2nd alternative:
REPORT  YMI_SG_NACHWEIS_A NO STANDARD PAGE HEADING.
FIELD-SYMBOLS:
<t001>, <fs>.
DATA:
lr_t001 TYPE REF TO data.
CONSTANTS:
s1(30) VALUE 'T001',
s2(30) VALUE 'BUKRS',
s3(30) VALUE 'BUTXT'.
DATA:
lt_where(72) OCCURS 0 WITH HEADER LINE,
lt_field(72) OCCURS 0 WITH HEADER LINE.
append s3 to lt_field.
CREATE DATA lr_t001 TYPE (s1).
ASSIGN lr_t001->* TO <t001>.
ASSIGN (s1) TO <fs>.
CONCATENATE s2 '=' '3000' INTO lt_where SEPARATED BY space.
APPEND lt_where.
SELECT *
INTO <t001>
FROM (s1)
WHERE (lt_where).
  ASSIGN COMPONENT s3 OF STRUCTURE <t001> TO <fs>.
  WRITE: / s3, ': ', <fs>.
ENDSELECT.
*2nd alternative
skip 2.
write:/'2nd'.
uline.
select (lt_field) into corresponding fields of <t001>
FROM (s1)
WHERE (lt_where).
  ASSIGN COMPONENT s3 OF STRUCTURE <t001> TO <fs>.
  WRITE: / s3, ': ', <fs>.
ENDSELECT.
grx
Andreas

Similar Messages

  • Logic for retreiving the values from a dynamic internal table

    Hi all,
    I have an issue with the logic to fetch data from a dynamic internal table into fields. let me give you guys an example the sy-tfill = 9 (subject to vary). I need to populate the fields.
    Regards,
    Sukumar

    Hi,
    this is for printing out the info in a dynamic table,
    it will work likewise to insert data.
    PARAMETERS:
      p_tabnam TYPE tabname DEFAULT 'DB_TABLE_NAME'.
    DATA:
      lv_dref TYPE REF TO data,
      ls_dd03l LIKE dd03l,
      lt_fieldname TYPE TABLE OF fieldname,
      ls_fieldname TYPE fieldname.
    FIELD-SYMBOLS:
      <fs> TYPE STANDARD TABLE,
      <wa_comp> TYPE fieldname,
      <wa_data> TYPE ANY,
      <wa_field> TYPE ANY.
    REFRESH lt_fieldname.
    SELECT * FROM dd03l INTO ls_dd03l
                       WHERE as4local = 'A'
                         AND as4vers  = '0000'
                         AND tabname  = p_tabnam
                       ORDER BY position.
      ls_fieldname = ls_dd03l-fieldname.
      APPEND ls_fieldname TO lt_fieldname.
    ENDSELECT.
    IF NOT ( lt_fieldname[] IS INITIAL ).
      CREATE DATA lv_dref TYPE TABLE OF (p_tabnam).
      ASSIGN lv_dref->* TO <fs>.
      SELECT * FROM (p_tabnam) INTO TABLE <fs>.
      WRITE:
        / 'CONTENTS OF TABLE', p_tabnam.
      LOOP AT <fs> ASSIGNING <wa_data>.
        SKIP.
        WRITE:
          / 'LINE', sy-tabix.
        ULINE.
        LOOP AT lt_fieldname ASSIGNING <wa_comp>.
          ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa_data> TO <wa_field>.
          WRITE:
            / <wa_comp>, <wa_field>.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    grtz
    Koen

  • Deleting selected record in Dynamic Internal table

    Hi Friends,
    I want to delete selected row from a dynamic internal table. The selected entry should be deleted from Adobe and as well as Webdynpro abap.
    Kindly help me how to solve this problem.
    Thanks in advance.
    Regards,
    Phani.

    Hi Matthias,
    Thanks a lot for responding.
    In my adobe i kept a check box to delete the record. It should delete the selected ones. But right now, its deleting one by one.
    I have coded following script for delete button:
    IT_TIME_SHEET --> is my internal table
    G_ROW_STATUS is the field to track the action performed.
    var tlength = xfa.resolveNodes("IT_TIME_SHEET.DATA[*]").length;
    for ( var i=0; i<tlength; i++
    if(xfa.resolveNode("IT_TIME_SHEET.DATA["i"].FLAG").rawValue ==
    1 )
    IT_TIME_SHEET.DATA.instanceManager.removeInstance(i);
    G_ROW_STATUS.rawValue = "DELETE";
    In the Webdynpro abap following code I wrote:
        row_count = 1.
        FIELD-SYMBOLS <wa> TYPE zshr_time_sheet_time.
        LOOP AT it_time_sheet ASSIGNING <wa>.
          <wa>-srl_no = row_count.
          row_count = row_count + 1.
        ENDLOOP.
        last_row = <wa>-srl_no.
          DELETE it_time_sheet WHERE srl_no EQ last_row.
    Suppose if two records checkboxes are selected I can loop at the internal table IT_TIME_SHEET in webdynpro and delete where checkbox is selected.
    But problem is once user deletes records, adobe is deleting only one record and if i delete two records from webdynpro it looks like something wrong for the user.
    Please help me how to solve this problem.
    Regards,
    Phani.

  • How to transfer data from a dynamic internal table

    Hi All
    I want to transfer data from a dynamic internal table<dyn_table>
    to a non dynamic internal table itab which should have the same structure as <dyn_table>.
    How can this be done?
    Regards,
    Harshit Rungta

    As stated earlier this can be done only through field symbols...
    You cannot create an non dynamic internal table with ANY structure...using DATA statement
    If the strucutre is defined well and good...you can create an non-dynamic internal table...
    If you do not know the structure then the internal table has to be dynamic...and to be generated using field symbols
    DATA: lv_ref TYPE REF TO data.
    FIELD-SYMBOLS: <fs_dyn_table> TYPE STANDARD TABLE.
    * You create a dynamic internal table...
    CREATE DATA lv_ref LIKE (your_dynamic_internal_table).
    ASSIGN lv_ref->* TO <fs_dyn_table>.
    Now...do the transfer.
    <fs_dyn_table> = "your_dynamic_internal_Table
    Hope it helps!

  • Creating and selecting from a dynamic table

    Hi,
    Iam trying to create a table dynamically and selecting from it in same plsql block, but am getting "table doesnot exist" error. however if i just create a table dynamically and then do a select on it seperately it works..
    below is sample code for the same,
    working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    end;
    select count(*) from emp_bglr ...works and return me 0 rows
    Line: -----
    but when i include select in plsql block ..it throws "Table does not exists" error...(iam running below plsql block after dropping the created table)
    not working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    --COMMIT;
    END;
    Select count(*) into l_cnt from emp_bglr;
    dbms_output.put_line('cnt is '||l_cnt);
    end;
    Line: -----

    Becuase your code is first checked for syntax/object existance during compilation and throws an error saying the table does not exist.
    Try this:
    SQL> ed
    Wrote file afiedt.buf
      1   DECLARE
      2   loc VARCHAR2(20):='bglr';
      3   l_cnt pls_integer;
      4   BEGIN
      5   -- create an employee information table
      6   EXECUTE IMMEDIATE 'CREATE TABLE emp_bglr(
      7   empno NUMBER(4) NOT NULL,
      8   ename VARCHAR2(10),
      9   job VARCHAR2(9),
    10   sal NUMBER(7,2),
    11   deptno NUMBER(2)
    12   )';
    14  Select count(*) into l_cnt from all_objects where object_name = 'EMP_BGLR';
    15  dbms_output.put_line('tab cnt is '||l_cnt);
    16  IF (l_cnt = 1) THEN
    17  l_cnt := 0;
    18  EXECUTE IMMEDIATE 'SELECT count(*) from apps.emp_bglr' into l_cnt;
    19  dbms_output.put_line('data cnt is '||l_cnt);
    20  END IF;
    21* end;
    SQL> /
    tab cnt is 1
    data cnt is 0
    PL/SQL procedure successfully completed.
    SQL> Edited by: AP on Aug 5, 2010 5:51 AM
    Edited by: AP on Aug 5, 2010 5:52 AM

  • How to control the number of rows selected from a sybase database table?

    Hi, JDBC guru,
    I'm working on project using Sybase 11.9.x database.We need to process a record in a table,first select it from the table,then do some computing,finally write it to a dbf file, if the above steps succeed,remove the original row in the table.Quite evidently, all these operation should be put into one transaction. But how can I select just a number of rows from the sybase database table?
    Any hints?
    Thank you in advance.
    Regards,
    Jusitne

    Statement stmt...
    stmt.setMaxRows(20);

  • Select from multiple entries in table cell.

    Hi All,
    I'm having issues when trying to do a simple select from an access database:
    <CFQUERY NAME="GetAllByMonth" DATASOURCE="dsn">
    SELECT * FROM table WHERE  strMonth = '#url.strMonth#' AND strDisplay = Yes
    order by strOrder_id
    </CFQUERY>
    Table cells in rows contain coma separated values:
    January, February, March, April, May, June, October, November, December
    Unfortunately the query returns no values. I've tried changing the "=" with "like", "contains" but with no results.
    Difficult to know what to search for so any help gratefully recieved.
    Ta
    Trevor

    Here is an absolutely crazy "hack" that I once used when dealing with a database like that.  It had hundreds of thousands of rows with comma separated values that for various legacy could not be changed.
    So one day I did this ...  SELECT DISTINCT column_from_purgatory FROM table_from_hell.
    Much to my surprise, there were less than a hundred DISTINCT values in that column.  (They were, fortunately, reasonably-sized VARCHARs.)
    So I built a table of those values, then created a separate table into which I could put each of the comma-separated parts, and then wrote a small (Perl) script to populate the two.  For example, a row containing "January, March, April" would be linked to three rows containing one month-name each.
    Now, as long as I had a way to be sure that this pair of lookup-tables was always complete (which was slightly problematic), I had something that I could actually JOIN to.  It wasn't pretty ... in fact, it was butt-ugly ... but it saved a tremendous amount of processing time for this application.

  • Selecting from a view when tables are in more than one schema problem

    I give up where am I missing it. Why is the ORA-01031 error being generated on the view u1.bv1. In testing even if I give object access to u3 I still get the same errors:
    SQL>
    SQL> drop user u1 cascade;
    drop user u1 cascade
    ERROR at line 1:
    ORA-01918: user 'U1' does not exist
    SQL> drop user u2 cascade;
    drop user u2 cascade
    ERROR at line 1:
    ORA-01918: user 'U2' does not exist
    SQL> drop user u3 cascade;
    drop user u3 cascade
    ERROR at line 1:
    ORA-01918: user 'U3' does not exist
    SQL> drop role aRole;
    drop role aRole
    ERROR at line 1:
    ORA-01919: role 'AROLE' does not exist
    SQL>
    SQL>
    SQL> select user from dual;
    USER
    SYS
    1 row selected.
    SQL>
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Solaris: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    5 rows selected.
    SQL>
    SQL> create user u1 identified by u1 default tablespace users
    2 quota unlimited on users;
    User created.
    SQL>
    SQL> create user u2 identified by u2 default tablespace users
    2 quota unlimited on users;
    User created.
    SQL>
    SQL> create role aRole;
    Role created.
    SQL>
    SQL> create user u3 identified by u3 default tablespace users;
    User created.
    SQL>
    SQL> grant aRole to u3;
    Grant succeeded.
    SQL>
    SQL> alter user u3 default role all;
    User altered.
    SQL>
    SQL> grant create session to u3;
    Grant succeeded.
    SQL>
    SQL> create table u1.t1(c1 number);
    Table created.
    SQL>
    SQL> create table u2.t1(c1 number);
    Table created.
    SQL>
    SQL> grant select on u2.t1 to u1;
    Grant succeeded.
    SQL>
    SQL> create or replace view u1.bv1 as
    2 select u1.t1.c1 as c1 ,u2.t1.c1 as c2
    3 from u1.t1, u2.t1 where u1.t1.c1 = u2.t1.c1;
    View created.
    SQL>
    SQL> grant select on u1.bv1 to aRole;
    Grant succeeded.
    SQL>
    SQL> create or replace view u1.gv1 as select * from u1.t1;
    View created.
    SQL>
    SQL> grant select on u1.gv1 to aRole;
    Grant succeeded.
    SQL>
    SQL> connect u3/u3
    Connected.
    SQL>
    SQL> select * from u1.bv1;
    select * from u1.bv1
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL>
    SQL> select * from u1.gv1;
    no rows selected
    SQL>
    SQL> spool off

    User u1 cannot do a grant on a view to other user if the view uses tables from other schemas unless you do a "with grant option" grant.
    You need to do the following to make it work:
    SQL> grant select on u2.t1 to u1 with grant option;
    Grant succeeded.
    SQL>

  • DB Trigger: select from and into current table

    I'm running 8.0.5 and facing a table looking like MYTAB(RECID,RECLABEL,..., PARENTRECID, PARENTRECLABEL) where:
    . RECID = current record UID (say: employee number)
    . RECLABEL = current record label (say: employee name)
    . PARENTRECID = RECID of another record in table MYTAB (say: employee ID of the manager of the current employee)
    . PARENTRECLABEL = must be made to hold automatically the contents of RECLABEL in the parent record (say: the name of the manager of the current employee)
    I know an easy way to get this info would be to use a view like CREATE VIEW MYVIEW AS SELECT A.RECID, A.RECLABEL, A.PARENTRECID, B.RECLABEL "PARENTRECLABEL" FROM MYTAB A, MYTAB B WHERE A.PARENTRECID=B.RECID but for various reasons I would really love to denormalize that info into column PARENTRECLABEL using a database trigger.
    Obviously, table MYTAB itself cannot be selected from during the execution of the dB trigger: mutating table error !
    I tried:
    . to select from a view defined as "SELECT * FROM MYTAB" as suggested in another thread, but this trick didn't seem to be sufficient to lure Oracle (it still says I'm trying to select from a mutating table !)
    . to use a package within which a PL/SQL table variable is filled with the list of affected RECID on a FOR EACH ROW basis, and to issue updates in a after statement (thus: not AFTER EACH ROW) AFTER UPDATE trigger - but it's too late already and those updates are apparently not taken into account by the database.
    Any other suggestions?
    Thx - Didier

    Here's the code, if the formatting in unpreserved please do let me I'll mail the same.
    The Package
    CREATE OR REPLACE PACKAGE save_table_package
    AS
    TYPE saved_test2_type
    IS TABLE OF test2%ROWTYPE
    INDEX BY BINARY_INTEGER;
    saved_test2 saved_test2_type;
    saved_test2_num NUMBER:= 1;
    PROCEDURE save_test2_row(i_id NUMBER
    ,i_ename VARCHAR2
    ,i_mgr_id NUMBER
    ,i_mgr_ename VARCHAR2
    PROCEDURE clear_rows;
    END save_table_package;
    show err
    CREATE OR REPLACE PACKAGE BODY save_table_package AS
    PROCEDURE save_test2_row(i_id NUMBER
    ,i_ename VARCHAR2
    ,i_mgr_id NUMBER
    ,i_mgr_ename VARCHAR2
    IS
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Enter pkg.save_test2_row:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    save_table_package.saved_test2(saved_test2_num).id := i_id;
    save_table_package.saved_test2(saved_test2_num).ename := i_ename;
    save_table_package.saved_test2(saved_test2_num).mgr_id := i_mgr_id;
    save_table_package.saved_test2(saved_test2_num).mgr_ename := i_mgr_ename;
    DBMS_OUTPUT.PUT_LINE('Saved Details Of Row ###:' &#0124; &#0124;
    TO_CHAR(save_table_package.saved_test2_num,'099999') &#0124; &#0124;'('&#0124; &#0124;
    TO_CHAR(save_table_package.saved_test2(saved_test2_num).id,'099') &#0124; &#0124;','&#0124; &#0124;
    save_table_package.saved_test2(saved_test2_num).ename &#0124; &#0124;','&#0124; &#0124;
    save_table_package.saved_test2(saved_test2_num).mgr_id &#0124; &#0124;','&#0124; &#0124;
    save_table_package.saved_test2(saved_test2_num).mgr_ename &#0124; &#0124;')'
    save_table_package.saved_test2_num := save_table_package.saved_test2_num + 1;
    DBMS_OUTPUT.PUT_LINE('Leave pkg.save_test2_row:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    END save_test2_row;
    PROCEDURE clear_rows IS
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Enter pkg.clear_rows :'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    save_table_package.saved_test2_num := 1;
    DBMS_OUTPUT.PUT_LINE(' Leave pkg.clear_rows :'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    END clear_rows;
    END save_table_package;
    show err
    The Triggers
    CREATE OR REPLACE TRIGGER trig_bfr_iup_test2_fer
    BEFORE INSERT OR UPDATE OF mgr_id ON test2 FOR EACH ROW
    DECLARE
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Enter before insupd:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    save_table_package.save_test2_row(:new.id
    ,:new.ename
    ,:new.mgr_id
    ,:new.mgr_ename);
    DBMS_OUTPUT.PUT_LINE('Leave before insupd:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    END;
    show err
    CREATE OR REPLACE TRIGGER trig_aft_iup_test2_stm
    AFTER INSERT OR UPDATE OF mgr_id ON test2
    DECLARE
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Enter after insupd:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    FOR i IN 1 .. save_table_package.saved_test2_num - 1
    LOOP
    UPDATE test2 eme
    SET mgr_ename = (SELECT mgr.ename
    FROM test2 mgr
    WHERE mgr.id = eme.mgr_id)
    WHERE eme.id = save_table_package.saved_test2(i).id
    DBMS_OUTPUT.PUT_LINE('MGR_ENAME Set Row#:'&#0124; &#0124;TO_CHAR(i,'099999'));
    END LOOP;
    save_table_package.clear_rows;
    DBMS_OUTPUT.PUT_LINE('Leave after insupd:'&#0124; &#0124;TO_CHAR(save_table_package.saved_test2_num,'099999'));
    END;
    show err
    null

  • Select from database dynamically

    Hello colleague,
    i am trying to read a database whose name is dynamically identified. There are several fields but i am interested in one. I want all the entries for that field in the table. The field "trace_fct_id" is type SYSUUID_x(16). I want it to be populated in the CHAR32 field ie GUID.
      LOOP AT lt_tabname INTO ls_tablename.
        CREATE DATA dref TYPE STANDARD TABLE OF (ls_tablename-name).
        ASSIGN dref->* TO <itab>.
        SELECT DISTINCT trace_fct_id FROM (ls_tablename-name) INTO CORRESPONDING FIELDS OF TABLE <itab>.
        MOVE <itab> TO et_func_ids.
      ENDLOOP.
    I get all the entries from the table but i just want to return the ID, and the move does not copy it in the internal table as the column name is different.
    Could you please help?
    Thanks in advance.
    Best Regards,
    Piyush

    Check if this helps:
    DATA: dref TYPE REF TO data,
          lt_tabname TYPE STANDARD TABLE OF tabname,
          ls_tablename TYPE tabname,
          et_func_ids TYPE STANDARD TABLE OF sysuuid_x,
          es_func_ids TYPE sysuuid_x.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <wa> TYPE ANY ,
                   <val> TYPE ANY.
    DATA: v_err TYPE string,
          lcx_root TYPE REF TO cx_root.
    LOOP AT lt_tabname INTO ls_tablename.
      CREATE DATA dref TYPE STANDARD TABLE OF (ls_tablename).
      ASSIGN dref->* TO <itab>.
      TRY .
          SELECT DISTINCT trace_fct_id FROM (ls_tablename)
          INTO CORRESPONDING FIELDS OF TABLE <itab>.
          CHECK sy-subrc = 0.
          LOOP AT <itab> ASSIGNING <wa>.
            ASSIGN COMPONENT 'TRACE_FCT_ID' OF STRUCTURE <wa> TO <val>.
            CHECK sy-subrc = 0.
            es_func_ids = <val>.
            APPEND es_func_ids TO et_func_ids.
            CLEAR et_func_ids.
          ENDLOOP.
        CATCH cx_sy_open_sql_error INTO lcx_root."Catch block for SQL errors
          v_err = lcx_root->get_text( ).
          WRITE: / v_err.
      ENDTRY.
      REFRESH <itab>.
    ENDLOOP.
    BR,
    Suhas

  • Returning a selection from a list or table

    I'm looking for a nice way to present the selcted value of a JList or a JTable to the rest of the program. So far the only thing I know to do is make the selection a static variable of the class implementing the ListSelectionListener interface. For instance, in the code below, I would make the variable rowNum a static variable, accessible from outside. But OO says to make it a method like public int getSelection(){return rowNum}i've had difficulty extracting the selection and making it available where it is really needed, in the business logic of the program. Any comments would be appreciated.class TablePanel extends JPanel
      ConnectionHandler ch;
      static TheTableModel tm;
      ListSelectionHandler selector;
      TablePanel(ConnectionHandler ch)
        this.ch = ch;
        tm = new TheTableModel();
        JTable jt = new JTable(tm);
        //selection mechanics
        jt.setPreferredScrollableViewportSize(new Dimension(900,200));
        ListSelectionModel rowSM = jt.getSelectionModel();
        selector = new ListSelectionHandler();
        rowSM.addListSelectionListener(selector);
        jt.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //set column widths
        TableColumn column = null;
        for (int i = 0; i<9;i++)
          column = jt.getColumnModel().getColumn(i);
          if(i==0) column.setPreferredWidth(40);
          column.setPreferredWidth(100);
        //display
        JScrollPane jsp = new JScrollPane(jt);
        add(jsp);
    class ListSelectionHandler implements ListSelectionListener
      public void valueChanged(ListSelectionEvent e)
        ListSelectionModel lsm = (ListSelectionModel)e.getSource();
        if(lsm.isSelectionEmpty()) return;
        int rowNum = lsm.getMinSelectionIndex();
        if(!e.getValueIsAdjusting())
          System.out.println(rowNum +" =rowNum");
    }

    You could make it a method like
    public int getSelection() {
       return table.getSelectedRow();
    }That would work fine provided 'table' is kept as an instance variable. As far as I can see, there's no need for a static variable here. If you wanted to return different information, you could do it the same way (eg, returning the selected value, instead of the row, etc.)

  • To color selected cells in dynamically created table in ALV.

    Hi,
           The requirement is to display a table (whose columns are dynamic) using ALV n to color few cells of the table based on some condition.
    For creating the table dynamically i have used the method cl_alv_table_create=>create_dynamic_table.
    Now for coloring the cells i tried to use the field EMPHASIZE .
    But when I try this method the whole column is getting colored.
    So any suggestions on how to color only particular cells.

    Hi,
    Try this one...
    DATA: gs_layout TYPE slis_layout_alv, "Define layout
    gt_color TYPE lvc_t_scol WITH HEADER LINE. "Define Internal Table for Cell Colouring
    Use below Sample Code after building a Field Catalog:
    gs_layout-coltab_fieldname = 'COLINFO'.
    " 'it' is the final internal table which contain positive & negative value of Field 'MENGE'
    LOOP AT it.
    REFRESH gt_color.
    CLEAR gt_color.
    IF it-menge GE 0.
    CLEAR gt_color.
    gt_color-fname = 'MENGE'.
    gt_color-color-col = cl_gui_resources=>list_col_positive.
    gt_color-color-int = 0.
    APPEND gt_color.
    ELSEIF it-menge LE 0.
    CLEAR gt_color.
    gt_color-fname = 'MENGE'.
    gt_color-color-col = cl_gui_resources=>list_col_negative.
    gt_color-color-int = 0.
    APPEND gt_color.
    ENDIF.
    it-colinfo[] = gt_color[].
    MODIFY it.
    ENDLOOP.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = g_repid
    is_layout = gs_layout
    it_fieldcat = ct_fieldcat
    i_save = 'A'
    TABLES
    t_outtab = it
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    Hope this solves your problem.
    Regards,
    Tarun

  • Need urgent help on dynamic internal table.

    Hi experts,
    I got an editable dynamic internal table. When the value in 1 of the editable field has been changed, I will fire the the DATA_CHANGED event. In this event, I can get the row ID where the changes occur, but the problem is, how can I select back the data from the dynamic internal table using the row ID since index is not permitted to be used? I need to get the rest of the records form the ROW and then perform a database update accordingly. How can I select from the dynamic internal table given the row ID? THanks in advance.

    Hi
    I suppose it depends on the kind of internal table assigned to fieldsymbol, this sample works fine:
    FIELD-SYMBOLS: <FS> TYPE TABLE,
                   <WA> TYPE ANY.
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD,
          END   OF ITAB.
    DO 10 TIMES.
      ITAB-FIELD = 'a'.
      APPEND ITAB.
    ENDDO.
    ASSIGN ITAB[] TO <FS>.
    READ TABLE <FS> ASSIGNING <WA> INDEX 1.
    WRITE <WA>.
    It can't use the index with internal table of kind HASHED.
    Max

  • Populate Final internal table from Dynamic internal table

    Hello,
    I have ti display data in ALV grid whose structure is fixed. I am dynamically selecting data iin an internal table.
    Now from this dynamic internal table, i need to populate my final internal table whose structurte is fixed.
    Please help.
    Rgds,
    Himanshu

    Hello Himanshu,
    When you say dynamic internal table there are two things one is the actual structure and other one is field table that holds information for all the fields used to create dynamic internal table.
    No if you want to move data from dynamic table to fixed internal table then you can try as follows:
    1.
    field-symbols <field_name> TYPE C.
    field-symbols <field_value> TYPE C.
    Now you either use
    LOOP AT fields_itab.
    ASSIGN fields_itab-fieldname to <field_name>.
    ASSIGN COMPONENT <field_name> OF STRUCTURE <structure_name> TO <field_value>
    Now you move value from <field_value> to required field in fixed internal table.
    i.e.
    itab-fieldname = <field_value>.
    Other way to do this:
    If you fields order is constant then you can also use index in assign component statement.
    do <no_of_fields> times.
        ASSIGN COMPONENT sy-index OF STRUCTURE <structure_name> TO <field_value>.
    rest is same as first method.
    Hope this help!
    I have given sudo code and you need to work on it little.
    Thanks,
    Augustin.

  • Unable To Select From SQL Server table with more than 42 columns

    I have set up a link between a Microsoft SQL Server 2003 database and an Oracle 9i database using Heterogeneous Services (HSODBC). It's working well with most of the schema I'm selecting from except for 3 tables. I don't know why. The common denominator between all the tables is that they all have at least 42 columns each, two have 42 columns, one has 56, and the other one, 66. Two of the tables are empty, one has almost 100k records, one has has 170k records. So I don't think the size of the table matters.
    Is there a limitation on the number of table columns you can select from through a dblink? Even the following statement errors out:
    select 1
    from "Table_With_42_Cols"@sqlserver_db
    The error message I get is:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message [Generic Connectivity Using ODBC]
    ORA-02063: preceding 2 lines from sqlserver_db
    Any assistance would be greatly appreciated. Thanks!

    Not a very efficient and space friendly design to do name-value pairs like that.
    Other methods to consider is splitting those 1500 parameters up into groupings of similar parameters, and then have a table per group.
    Another option would be to use "vertical table partitioning" (as oppose to the more standard horizontal partitionining provided by the Oracle partition option) - this can be achieved (kind of) in Oracle using clusters.
    Sooner or later this name-value design is going to bite you hard. It has 1500 rows where there should be only 1 row. It is not scalable.. and as you're discovering, it is unnatural to use. I would rather change that table and design sooner than later.

Maybe you are looking for

  • Aaa ldap problem on UCS Manager

    Hi all, i'm working on UCS Manager Suite and i would like configure Authentication method using LDAP protocol ( AD : Windows 2008 R2 Standard Edition). I follow this configuration guide: http://www.cisco.com/en/US/docs/unified_computing/ucs/sw/sample

  • Update sql 2012 database from access 2003

    Hi, all, I have a new sql server 2012 and has already created a database same as the one from access 2003.  Can someone give me a details or links how to update sql server 2012 through SSIS package? I know I could use import wizard but it is a custom

  • I am unable to turn off repeat on my iPhone 4.

    For some reason, I am unable to turn off repeat on my iphone 4. When I click on the album artwork, it does not give me the option to stop repeat. It doesn't even give me the scrubber. Any ideas on how to fix this?

  • Why can't I restore my iPhone 4 with error 28?

    My iPhone 4 wouldn't turn on for 3 days, so eventually I plugged it into iTunes - it said the phone was in recovery and that I needed to restore it. After doing this, it gave me the eror code 28 and I have tried everything to restore it?!

  • H.264 looks horrible at higher bitrate than iTunes videos

    I export my videos as .mp4 with H.264 at 2000 kbits/s. I was looking at some videos from the iTunes store and they have a lower bitrate but have significantly higher quality. My videos are full of artifacts, especially if there is any movement. Is th