Dynamic Alv for Dynamic Internal Table

Hi All,
I am new for abap dynpro.
How can i create a dynamic alv table in abap dynpro withoud ddic structure??
My requirement is as follows:
I have a table having some field e.g MATNR WERKS NETWR.
I want to pivot data werks and to display in webdynpro alv.
Thnx:
N. N. Tiwari

You can use the RTTI to build up a dynamic structure in memory:
Something like this - where both the data and its structure and meta data all come from an external source (which happens to be MDM in this case):
****ALV
      data:
         rootnode_info type ref to if_wd_context_node_info,
         dyn_node type ref to if_wd_context_node,
         dyn_node_info type ref to if_wd_context_node_info,
         tabname_node type ref to if_wd_context_node,
         current_tablename type string,
         tablename type string,
         struct_type type ref to cl_abap_structdescr,
          table_type  type ref to cl_abap_tabledescr,
          comp_tab    type cl_abap_structdescr=>component_table,
          comp        like line of comp_tab,
          my_table    type ref to data,
          my_row      type ref to data.
      field-symbols: <table> type table,
                     <row> type data,
                     <f>   type any,
                     <wa_string>     type string,
                     <wa_date_time>  type mdm_cdt_date_time,
                     <wa_integer>    type mdm_gdt_integervalue.
      rootnode_info = wd_context->get_node_info( ).
* create subnode_info
      try.
          rootnode_info->remove_child_node( 'MDM_DATA' ).
        catch cx_wd_context.
      endtry.
      field-symbols <wa_detail> like line of field_details.
      field-symbols <wa_result> like line of result_set.
      field-symbols <wa_pair>   type mdm_name_value_pair.
      read table result_set assigning <wa_result> index 1.
      loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
        if strlen( <wa_detail>-field_code ) > 30.
          comp-name = <wa_detail>-field_code+0(30).
        else.
          comp-name = <wa_detail>-field_code.
        endif.
        if <wa_result> is assigned.
          read table <wa_result>-name_value_pairs assigning <wa_pair>
                        with key code = <wa_detail>-field_code.
          if sy-subrc = 0.
            case <wa_pair>-type.
              when `MDM_CDT_DATE_TIME`.
                comp-type ?= cl_abap_datadescr=>describe_by_name( 'TZNTSTMPL' ).
              when `MDM_GDT_INTEGERVALUE`.
                if <wa_detail>-field_lookup_table is not initial.
                  comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
                else.
                  comp-type ?= cl_abap_datadescr=>describe_by_name( 'INT4' ).
                endif.
              when others.
                comp-type ?= cl_abap_datadescr=>describe_by_name( <wa_pair>-type ).
            endcase.
          else.
            comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
          endif.
        else.
          comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
        endif.
        append comp to comp_tab.
      endloop.
      struct_type = cl_abap_structdescr=>create( comp_tab ).
      dyn_node_info = rootnode_info->add_new_child_node(
         name                   = 'MDM_DATA'
         is_mandatory           = abap_false
         is_mandatory_selection = abap_false
         static_element_rtti    = struct_type
         is_multiple            = abap_true
         is_static              = abap_false ).
*  get instance of new node
      dyn_node = wd_context->get_child_node( name = 'MDM_DATA' ).
****Process Table Data
      data content_string type string.
      data l_tabix type sytabix.
      table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
      create data my_table type handle table_type.
      assign my_table->* to <table>.
      loop at result_set assigning <wa_result>.
        create data my_row type handle struct_type.
        assign my_row->* to <row>.
        loop at field_details assigning <wa_detail>.
          l_tabix = sy-tabix.
          read table <wa_result>-name_value_pairs assigning <wa_pair>
                                  with key code = <wa_detail>-field_code.
*        loop at <wa_result>-name_value_pairs assigning <wa_pair>.
          if sy-subrc = 0 and <wa_pair>-value is not initial.
            assign component l_tabix of structure <row> to <f>.
*            READ TABLE field_details ASSIGNING <wa_detail> INDEX sy-tabix.
            case <wa_pair>-type.
              when 'STRING'.
                assign <wa_pair>-value->* to <wa_string>.
                if <wa_string> is assigned.
*                DATA: int TYPE i VALUE 258.
*                DATA: buffer TYPE xstring,
*                      text_buffer TYPE string,
*                      conv TYPE REF TO cl_abap_conv_out_ce.
*                conv = cl_abap_conv_out_ce=>create(
*                         encoding = 'UTF-8'
*                         endian = 'L' ).
*                CALL METHOD conv->write( data = <wa_string> ).
*                buffer = conv->get_buffer( ).
*                DATA: convin  TYPE REF TO cl_abap_conv_in_ce.
*                CALL METHOD cl_abap_conv_in_ce=>create
*                  EXPORTING
*                    input = buffer
*                  RECEIVING
*                    conv  = convin.
*                CALL METHOD convin->read
*                  IMPORTING
*                    data = text_buffer.
*                MOVE text_buffer TO <f>.
                  move <wa_string> to <f>.
                endif.
              when 'MDM_CDT_DATE_TIME'.
                assign <wa_pair>-value->* to <wa_date_time>.
                if <wa_date_time> is assigned.
                  move <wa_date_time>-content to <f>.
                endif.
              when 'MDM_GDT_INTEGERVALUE'.
                assign <wa_pair>-value->* to <wa_integer>.
                if <wa_integer> is assigned.
                  if <wa_detail>-field_lookup_table is not initial.
                    content_string = wd_assist->perform_value_lookup(
                        i_lookup_table = <wa_detail>-field_lookup_table
                        i_lookup_key   = <wa_integer> ).
                    move content_string to <f>.
                  else.
                    move <wa_integer> to <f>.
                  endif.
                endif.
            endcase.
          endif.
        endloop.
        append <row> to <table>.
      endloop.
      dyn_node->bind_table( <table> ).
* Connect to the component Usage of the ALV
      data: l_ref_cmp_usage type ref to if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
      if l_ref_cmp_usage->has_active_component( ) is initial.
        l_ref_cmp_usage->create_component( ).
      endif.
* Through the interface controller of the ALV Component set the DATA node dynamically
      data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
      l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
      l_ref_interfacecontroller->set_data(
        r_node_data = dyn_node  ).
      data alv_model type ref to cl_salv_wd_config_table.
      alv_model = l_ref_interfacecontroller->get_model( ).
      data columns type salv_wd_t_column_ref.
      field-symbols <wa_column> like line of columns.
      columns = alv_model->if_salv_wd_column_settings~get_columns( ).
      data column_id type string.
      data header type ref to cl_salv_wd_column_header.
      data l_text type string.
      loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
        if strlen( <wa_detail>-field_code ) > 30.
          column_id = <wa_detail>-field_code+0(30).
        else.
          column_id = <wa_detail>-field_code.
        endif.
        translate column_id to upper case.
        read table columns assigning <wa_column> with table key id = column_id.
        if sy-subrc = 0.
          header = <wa_column>-r_column->get_header( ).
          header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none ).
*      if <wa_detail>-field_lookup_table is initial.
          header->set_text( <wa_detail>-field_name1 ).
*      else.
*        l_text = wd_assist->read_table_desc_for_lookup( <wa_detail>-field_lookup_table ).
*        header->set_text( l_text ).
*      endif.
        endif.
      endloop.
    catch cx_root into o_except.
      data: l_current_controller type ref to if_wd_controller,
            l_message_manager    type ref to if_wd_message_manager.
      l_current_controller ?= wd_this->wd_get_api( ).
      l_message_manager = l_current_controller->get_message_manager( ).
      l_message_manager->report_exception(
          message_object           = o_except ).
  endtry.

Similar Messages

  • Dynamic name for the physical table

    Hi Guys,
    How to setup dynamic names for the physical table? Where it is useful?*
    Pls help me out on this.
    thanks

    Check this similar post which might be of help dynamic physical table source schema
    Cheers,
    KK

  • Get data in editable ALV back to internal table without data_changed ev?

    Hi,
       I have an editable ALV using classes to whch I have users the option to edit directly on the screen or upload data from an excel. The event data_changed gets triggered when users edit the table on the screen.
    However when EXCEL is uploaded, I refresh the table display. So, I need a way to get the data from the ALV into a internal table to check which rows were update using the excel and save them into the db table.
    Prakash

    Hi!
    For more information, inspect programs suiting the mask "BCALVEDIT*" and the thread with header "How to make a row of ALV editable " (I know this is some more steps further from your demand but it may be useful) at URL " How to make a row of ALV editable " .
    If you want to study more BC412 "EnjoySAP Controls" may help you.
    *--Serdar

  • Dynamic fetch for dynamic sql query

    Hi All,
    I want to dynamically create a query and fetch it into a dynamic cursor record...The structure of the record should be the same as that of the query...
    Can you suggest any method to do that.
    eg
    OPEN <dynamic cur> FOR <dynamic stmt>;
    LOOP
    FETCH <dynamic cur> INTO <dynamic rec>;
    END LOOP;
    CLOSE <dynamic cur>;
    How do I declare the dynamic rec here?I would not know the columns in the query beforehand either.
    Thanks,
    Merz
    Edited by: merz on Sep 12, 2011 5:02 PM
    Edited by: merz on Sep 12, 2011 5:03 PM

    merz wrote:
    Hi All,
    I want to dynamically create a query and fetch it into a dynamic cursor record...The structure of the record should be the same as that of the query...
    Can you suggest any method to do that.And how are you expecting to write an application around a dynamic query and dynamic structure that you don't know?
    Saying that, as others have said, there is the DBMS_SQL package which can be used for certain valid reasons such as the following example....
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Problem with grid display in ALV for dynamic internal tables

    Hi,
    I am using dynamic internal tables in my program. To display it in grid format after populating it, I have used the following class and method. Here Im getting sy-subrc = 0 but, the grid is not getting displayed. Can some one pls help me with this.,
    DATA: W_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: w_tabname TYPE w_tabname.
    CREATE OBJECT W_GRID
    EXPORTING I_PARENT = CL_GUI_CONTAINER=>SCREEN0.
    CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
        I_STRUCTURE_NAME              = W_TABNAME
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
       IS_LAYOUT                     =
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       IR_SALV_ADAPTER               =
      CHANGING
        IT_OUTTAB                     = <FS_1>
        IT_FIELDCATALOG               = LT_FIELDCATALOG2
       IT_SORT                       =
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Here, <FS_1> is the field symbol of table type and it holds all my data. and LT_FIELDCATALOG2  is the structure of my fieldcatalog
    Thanks and Regards,
    Avinash

    Hi Avinash,
    Either use parameter
    I_STRUCTURE_NAME = W_TABNAME
    or
    IT_FIELDCATALOG = LT_FIELDCATALOG2
    Both are not required.
    At the end of ur program simply use a write statement like below. Your program will work.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Write /.      <----
    Thanks,
    Edited by: Sap Fan on Oct 6, 2009 7:17 AM

  • Dynamic creation of variables and alv grid output/internal table

    Dear Experts
    I am stuck in an inventory ageing report which is to be done year wise. the scenario is as follow.
    selection screen i enter the year 2011 or 2010 or 2009.
    the output should show me 2011-2007 or 2010-2007 or 2009-2007. the alv grid should always start from 2007 and end at the year that is entered in the selection screen.
    Now how can i create a dynamic variables to store the values of the corresponding yr and also how can i create a dynamic internal table to store these values.
    Thanks & Regards
    Zamir Parkar

    Hi Zamir,
    if you are new to ABAP you may leave old and buggy techniques behind.
    If you want to create the table dynamically, please do not use l_alv_table_create=>create_dynamic_table because it is limited and always triggers a possibly unwanted database commit.
    You better use RTTS dynamic runtime type services, i.e. check the example for [Creating Flat and Complex Internal Tables Dynamically using RTTI|http://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI].
    As done here, leave all outdated ALV technologies behind and start with CL_SALV_TABLE. It is following the object-oriented approach and does not need a field catalog.
    You will get used to field-symbols that can be compared to the data referenced by a pointer. For dynamic fields, you may build the field names dynamically, i.e.
    DATA:
          lo_structdescr         TYPE REF TO cl_abap_structdescr,
          lo_typedescr           TYPE REF TO cl_abap_typedescr,
          lo_tabledescr          TYPE REF TO cl_abap_tabledescr,
          lr_data                TYPE REF TO data,
          lt_comp_all            TYPE cl_abap_structdescr=>component_table,
          lv_index               TYPE numc2.
        FIELD-SYMBOLS:
          <any>                  TYPE ANY,
          <component>            TYPE LINE OF abap_component_tab,
           <table>                TYPE table.
        DO nnn TIMES.
          lv_index = sy-index.
          lo_typedescr   =  cl_abap_typedescr=>describe_by_name( <name of data element> ).
          APPEND INITIAL LINE TO lt_comp_all ASSIGNING <component>.
          <component>-type ?= lo_typedescr.
          CONCATENATE 'YEARVAL' lc_underscore lv_index INTO <component>-name.
          <component>-as_include  = abap_true.
          CONCATENATE lc_underscore lv_index INTO <component>-suffix.
        ENDDO.
    * create description object for structured type
        lo_structdescr = cl_abap_structdescr=>create( lt_comp_all ).
    *  create table description object for this
        lo_tabledescr = cl_abap_tabledescr=>create(
                        p_line_type  = lo_structdescr
                        p_table_kind = cl_abap_tabledescr=>tablekind_std
                        p_unique     = abap_false ).
    * create data object
        CREATE DATA lr_data TYPE HANDLE lo_tabledescr.
    ASSIGN lr_data->* to <table>.
    This is a fragment. Please adapt to your needs.
    Regards,
    Clemens

  • How to create New columns for the Internal Table Dynamically?

    HI Guys,
                          In my logic i have to create new columns depending on the logic which i am executing.
    My requirement is .I have to display o/p like this
    Material || Year || Period  ||  Mix ratio || Vendor ||Mix Ratio || Vendor || Mix Ratio Vendor || Mix ratio || Vendor || Mix ratio.............................from table's CKMLMV003 and CKMLMV001.Her i have to display the o/p in the above format and i have to display Vendor and Mix Ratio for 5 columns irrespective of data .If i have more than 5 columns for any record then i have to create a New columns dynamically for Vendor and Mix ratio.If anybody want my code i can Submit But plz tell with example how to do?
                    <b>The O/P must be finally shown in ALV Grid</b>
    Thanks,
    Gopi

    You must create the entire internal table dynamically, you can not add columns to a statically define internal table.  Here is an example of creating a dynamic internal table.
    Creation of internal table dynamically based on the Date Range entered
    Regards,
    Rich Heilman

  • How to create dynamic strcture for a interrnal table

    first i created one internal table . with five fields . suppose i want add two more fields in internal table.
    what is the code for the this . if any one konow

    REPORT  ZTEST05.
    PARAMETERS dbtab TYPE tabname DEFAULT 'SPFLI'.
    TYPE-POOLS rsds.
    DATA tadir_wa  TYPE tadir.
    DATA selid     TYPE  rsdynsel-selid.
    DATA field_tab TYPE TABLE OF rsdsfields.
    DATA table_tab TYPE TABLE OF rsdstabs.
    DATA table     LIKE LINE OF table_tab.
    DATA cond_tab  TYPE  rsds_twhere.
    DATA cond      LIKE LINE OF cond_tab.
    DATA dref      TYPE REF TO data.
    DATA alv       TYPE REF TO cl_salv_table.
    FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
    SELECT SINGLE *
           FROM tadir
           INTO tadir_wa
           WHERE pgmid = 'R3TR' AND
                 object = 'TABL' AND
                 obj_name = dbtab.
    IF sy-subrc <> 0.
      MESSAGE 'Database not found' TYPE 'I' DISPLAY LIKE 'E'.
      LEAVE PROGRAM.
    ENDIF.
    table-prim_tab = dbtab.
    APPEND table TO table_tab.
    CALL FUNCTION 'FREE_SELECTIONS_INIT'
      EXPORTING
        kind         = 'T'
      IMPORTING
        selection_id = selid
      TABLES
        tables_tab   = table_tab
      EXCEPTIONS
        OTHERS       = 4.
    IF sy-subrc <> 0.
      MESSAGE 'Error in initialization' TYPE 'I' DISPLAY LIKE 'E'.
      LEAVE PROGRAM.
    ENDIF.
    CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
      EXPORTING
        selection_id  = selid
        title         = 'Free Selection'
        as_window     = ' '
      IMPORTING
        where_clauses = cond_tab
      TABLES
        fields_tab    = field_tab
      EXCEPTIONS
        OTHERS        = 4.
    IF sy-subrc <> 0.
      MESSAGE 'No free selection created' TYPE 'I'.
      LEAVE PROGRAM.
    ENDIF.
    READ TABLE cond_tab WITH KEY tablename = dbtab INTO cond.
    IF sy-subrc <> 0.
      MESSAGE 'Error in condition' TYPE 'I' DISPLAY LIKE 'E'.
      LEAVE PROGRAM.
    ENDIF.
    CREATE DATA dref TYPE TABLE OF (dbtab).
    ASSIGN dref->* TO <table>.
    TRY.
        SELECT *
               FROM (dbtab)
               INTO TABLE <table>
               WHERE (cond-where_tab).
      CATCH cx_sy_dynamic_osql_error.
        MESSAGE 'Error in dynamic Open SQL' TYPE 'I' DISPLAY LIKE 'E'.
        LEAVE PROGRAM.
    ENDTRY.
    TRY.
        cl_salv_table=>factory(
          IMPORTING r_salv_table = alv
          CHANGING  t_table      = <table> ).
        alv->display( ).
      CATCH cx_salv_msg.
        MESSAGE 'Error in ALV display' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.

  • Dynamically inserting in an internal table with expansion & collapse.

    I have an Internal table wherein I have implemented Expansion and collapse. Now I want to sort this table dynamically everytime a new Child node is added to a Father Node. How do I sort it so that the Child nodes are inserted correctly under their corresponding Father Nodes?
    I tried using Indexing concept , e.g., insert <structure> into <itab> index lv_ind.
    lv_ind = sy-tabix + lines( itab ).
    For the First Father Node, the Child nodes are inserted in the correct position but when the Second Father Node is reached( say in position 12 ), then lv_ind gets a wrong value... The Child node should now be inserted in the 13th position but its inserted in lv_ind = sy-tabix + lines( itab ) = 12 + 12 = 24th position.
    Please let me know how to go about.
    Thanks and regards,
    Sukanya.

    Why can u sort the internal table once insertions are completed.
    SortITAB by Fathernode Childnode.

  • Dynamic field selection in internal table

    hello,
           I want to display the fields in the internal table dynamically.
    In myReport i am  giving plant as the input. On the basis of plant i want to dislpay work centres as the heading and for the particular plant i want to display the pieces for the confirmed operation of the particular work centre.
    workcentre1 workcentre2 workcenter3 ...........workcentren
       12               10             9               ............  4
    in my report i have to include these fields with my earlier fields
    Please help.

    hello,
           I want to display the fields in the internal table dynamically.
    In myReport i am  giving plant as the input. On the basis of plant i want to dislpay work centres as the heading and for the particular plant i want to display the pieces for the confirmed operation of the particular work centre.
    workcentre1 workcentre2 workcenter3 ...........workcentren
       12               10             9               ............  4
    in my report i have to include these fields with my earlier fields
    Please help.

  • Totals for the internal table field in alv

    Hi Gurus,
    I have an issue in displaying the totals in alv.
    I have an internal table with the three fields like below.
    scrap_code_001 like afru-xmnga, " Scrap Reason Qty.
    scrap_code_002 like afru-xmnga, " Scrap Reason Qty.
    scrap_code_003 like afru-xmnga, " Scrap Reason Qty.
    In the output table which i am passing to the fieldcatlog is having the three above fields with values 10,3,4 respectively.
    I am looping at the internal table
    loop at gt_grund.
    gv_tabix = sy-tabix.
    i_fieldcat-no_zero = gc_x.
    i_fieldcat-do_sum = gc_x.
    perform assign_alv_qty_format.
    if gt_grund-grund is initial.
    gt_grund = 'NONE'.
    gv_text = gt_grund.
    else.
    gv_text = gt_grund-grdtx.
    endif.
    gv_tabixn = gv_tabix.
    gv_scrap_code+11(03) = gv_tabixn.
    gv_fieldname = gv_scrap_code.
    translate gv_fieldname to upper case.
    perform bild_fieldcat using
    gv_fieldname 'GT_REPORT' 'AFRU' gv_text 'QUAN' '12' ' ' .
    endif.
    endloop.
    But in the output I am getting the totals but it displays totals for all the three columns as 17,17,17 (summing 10,3,4).
    How do I display total as 10,3,4 for each column separately.
    I appreciate you help and award points for the answer

    Hi,
    Please check if value fields i_fieldcat-ref_fieldname and i_fieldcat-ref_tabname regard to numc or curr type.
    EX: i_fieldcat-ref_fieldname = 'WRBTR'
           I_fieldcat-ref_tabname = 'BSEG'.
    Regards,
    Fernando

  • Help on ALV GRID display outputting format for 2 internal tables

    Hi,
        I have requirement in ALV GRID where I need to display the data from 2 internal tables. The first internal table has the content of Delivery due list data and second the internal table has the corresponding stock transfer data of the Delivery Due list. I have a checbox on my selection screen, when unchecked it should output the 1st internal table data, i.e for Delivery due list. When it is checked then it should output 1st Internal table data + 2nd internal table data of stock transfer. For example, 1 document delivery due list data and 2nd line for that document should show the stock transfer data. You can also check the transaction code VL10E for that will show a delivery due list...and for stock tranfer,you need to check with Purchase order in in the USer Role tabstrip. Pls suggest.
    Regards,
    Mira

    Hi,
    U can try out this code
    REPORT zzz_test NO STANDARD PAGE HEADING
                           MESSAGE-ID zz.
    The Data Declarations
    INCLUDE zzm_test_alv_data.
    The Selection Screen Definition
    INCLUDE zzm_test_alv_selscrn.
    The definition and implementation of the event reciever class
    INCLUDE zzm_test_alv_class.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM f1000_load_itabs.
    END-OF-SELECTION
    END-OF-SELECTION.
      IF NOT cb_disp IS INITIAL.
        CALL SCREEN 9001.
      ENDIF.
    Include for getting data
      INCLUDE zzm_test_alv_forms.
    Include for PAI and PBO of screen
      INCLUDE zzm_test_alv_screen.
      INCLUDE ZZM_TEST_ALV_DATA                                          *
    This include has all the data declaration defined
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    Table Declarations:
    TABLES: mara,
            makt.
    Internal Tables:
    The following structure type must be defined in the data dictionary
    DATA:  i_fieldcat  TYPE lvc_t_fcat,
           i_fieldcat1 TYPE lvc_t_fcat,
           i_output1   TYPE STANDARD TABLE OF mara,
           i_output2   TYPE STANDARD TABLE OF makt,
    Work Areas:
           w_output1   TYPE STANDARD TABLE OF mara,
           w_output2   TYPE STANDARD TABLE OF makt.
    Variable:
    DATA: lv_repid    LIKE sy-repid.
    lv_repid = sy-repid.
      INCLUDE ZZM_TEST_ALV_SELSCRN                                       *
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    SELECTION-SCREEN BEGIN OF BLOCK b_main WITH FRAME TITLE text-001.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS: cb_disp AS CHECKBOX.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN END OF BLOCK b_main.
      INCLUDE ZZM_TEST_ALV_CLASS                                         *
    This include has all the data declaration defined for ALV
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    INCLUDE <icon>.
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    DATA : o_alvgrid1 TYPE REF TO cl_gui_alv_grid ,
           o_alvgrid2 TYPE REF TO cl_gui_alv_grid ,
           cont_for_cognos1   TYPE scrfname VALUE 'BCALC_GRID_01_9100',
           cont_for_cognos2   TYPE scrfname VALUE 'BCALC_GRID_01_9200',
           custom_container1 TYPE REF TO cl_gui_custom_container,
           custom_container2 TYPE REF TO cl_gui_custom_container,
          Work Area
           w_layout TYPE lvc_s_layo ,
           w_variant TYPE disvariant.
          Constants
    CONSTANTS : c_lay(1) TYPE c VALUE 'A' .                  " All Layouts
    CONSTANTS: BEGIN OF c_main_tab,
               tab1 LIKE sy-ucomm VALUE 'MAIN_TAB_FC1',   "
               tab2 LIKE sy-ucomm VALUE 'MAIN_TAB_FC2',   "
               END OF c_main_tab.
      INCLUDE ZZM_TEST_ALV_FORMS                                         *
    This Include has the various forms used in the program
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    *&      Form  f9001_build_field_cat
          To Build Field Catalog
         -->P_I_FIELDCAT  text
         -->P_0021   text
    FORM f9001_build_field_cat TABLES   p_fieldcat STRUCTURE lvc_s_fcat
                          USING value(p_structure).
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name       = p_structure
           CHANGING
                ct_fieldcat            = p_fieldcat[]
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE i005 WITH 'Error in ALV field catalogue creation'.
                                                                " text-e05.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " f9001_build_field_cat
    *&      Form  f9000_objects_create
          For creating Custom Containers
    -->  p1        text
    <--  p2        text
    FORM f9000_objects_create.
      CREATE OBJECT custom_container1
          EXPORTING
              container_name = cont_for_cognos1
          EXCEPTIONS
              cntl_error = 1
              cntl_system_error = 2
              create_error = 3
              lifetime_error = 4
              lifetime_dynpro_dynpro_link = 5.
      CREATE OBJECT custom_container2
          EXPORTING
              container_name = cont_for_cognos2
          EXCEPTIONS
              cntl_error = 1
              cntl_system_error = 2
              create_error = 3
              lifetime_error = 4
              lifetime_dynpro_dynpro_link = 5.
      IF sy-subrc NE 0.
    add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = lv_repid
                  txt2  = sy-subrc
                  txt1  = 'The control could not be created'(510).
      ENDIF.
      CREATE OBJECT o_alvgrid1
           EXPORTING i_parent = custom_container1.
      CREATE OBJECT o_alvgrid2
           EXPORTING i_parent = custom_container2.
    ENDFORM.                    " f9000_objects_create
    *&      Form  f9003_layout
          To define the layout
         -->P_SY_TITLE  text
         -->P_0030   text
         -->P_0031   text
         -->P_0032   text
    FORM f9003_layout USING  value(ptitle)
                             value(pzebra)
                             value(pmode)
                             value(pwidth).
      w_layout-grid_title  = ptitle.
      w_layout-zebra       = pzebra.
      w_layout-sel_mode    = pmode.
      w_layout-cwidth_opt  = pwidth.
      w_variant-report     = sy-repid.
    ENDFORM.                    " f9003_layout
    *&      Form  f9006_error_handle
         To handle event
         -->P_PTEXT  text
    FORM f9006_error_handle USING value(ptext).
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e03 " Error Note
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    ENDFORM.                    " f9006_error_handle
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD custom_container1->free.
      CALL METHOD custom_container2->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = lv_repid
                  txt2  = sy-subrc
                  txt1  = 'Error in FLush'(500).
      ENDIF.
    ENDFORM.
    *&      Form  f1000_load_itabs
          Select from Database
    -->  p1        text
    <--  p2        text
    form f1000_load_itabs.
      SELECT * FROM mara
               INTO TABLE i_output1
               UP TO 50 rows.
      SELECT * FROM makt
               INTO TABLE i_output2
               UP TO 50 rows.
    endform.                    " f1000_load_itabs
      INCLUDE ZZM_TEST_ALV_SCREEN                                        *
    2/ Description / Include functions
    This include contains PBO and PAI events for the screen of report
    ZZZJJ_TEST_ALV
    3/ Responsibility
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    DATA FOR TABSTRIP 'MAIN_TAB'
    CONTROLS:  main_tab TYPE TABSTRIP.
    DATA:      BEGIN OF i_main_tab,
                 subscreen   LIKE sy-dynnr,
                 prog        LIKE sy-repid VALUE
                                  'ZZZ_TEST',
                 pressed_tab LIKE sy-ucomm VALUE c_main_tab-tab1,
               END OF i_main_tab.
    *&      Module  STATUS_9001  OUTPUT
          text
    MODULE status_9001 OUTPUT.
    IF custom_container1 IS INITIAL.
      SET PF-STATUS 'ZSTATUS'.
      SET TITLEBAR 'ZTITLE'.
      Creating Object
        PERFORM f9000_objects_create.
      Building the field catalog
        PERFORM f9001_build_field_cat TABLES i_fieldcat
                                USING 'MARA'.
        PERFORM f9001_build_field_cat TABLES i_fieldcat1
                                USING 'MAKT'.
      Modifying the field catalog
       PERFORM f9002_modify_field_cat TABLES i_fieldcat.
      For Layout
        PERFORM f9003_layout USING sy-title 'X' 'B' 'X'.
    ENDIF.
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&      Module  MAIN_TAB_ACTIVE_TAB_SET  OUTPUT
          Call method to display in the output grid
    MODULE main_tab_active_tab_set OUTPUT.
      main_tab-activetab = i_main_tab-pressed_tab.
      CASE i_main_tab-pressed_tab.
        WHEN c_main_tab-tab1.
      To display report
         i_main_tab-subscreen = '9100'.
          CALL METHOD o_alvgrid1->set_table_for_first_display
          EXPORTING
             is_variant                    = w_variant
             i_save                        = c_lay
             is_layout                     = w_layout
          CHANGING
             it_outtab                     = i_output1[]
             it_fieldcatalog               = i_fieldcat[]
          EXCEPTIONS
             invalid_parameter_combination = 1
             program_error                 = 2
             too_many_lines                = 3
             OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
        WHEN c_main_tab-tab2.
      To display report
          i_main_tab-subscreen = '9200'.
          CALL METHOD o_alvgrid2->set_table_for_first_display
          EXPORTING
             is_variant                    = w_variant
             i_save                        = c_lay
             is_layout                     = w_layout
          CHANGING
             it_outtab                     = i_output2[]
             it_fieldcatalog               = i_fieldcat1[]
          EXCEPTIONS
             invalid_parameter_combination = 1
             program_error                 = 2
             too_many_lines                = 3
             OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i005 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
    WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_SET OUTPUT
    *&      Module MAIN_TAB_ACTIVE_TAB_GET INPUT
          Check & Process the selected Tab
    MODULE main_tab_active_tab_get INPUT.
      CASE sy-ucomm.
        WHEN c_main_tab-tab1.
          i_main_tab-pressed_tab = c_main_tab-tab1.
        WHEN c_main_tab-tab2.
          i_main_tab-pressed_tab = c_main_tab-tab2.
        WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_GET INPUT
    *&      Module USER_COMMAND_9001 INPUT
          User Command
    MODULE user_command_9001 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          PERFORM exit_program.
          SET SCREEN '0'.
        WHEN 'EXIT' OR  'CANC'.
          PERFORM exit_program.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 “USER_COMMAND_9000 INPUT
    *&      Module MAIN_TAB_ACTIVE_TAB_SET INPUT
          Set sunscreen
    MODULE main_tab_active_tab_set INPUT.
      main_tab-activetab = i_main_tab-pressed_tab.
      CASE i_main_tab-pressed_tab.
        WHEN c_main_tab-tab1.
            i_main_tab-subscreen = '9100'.
        WHEN c_main_tab-tab2.
            i_main_tab-subscreen = '9200'.
        WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_SET INPUT
    Thanks & Regards,
    Judith.

  • Really urgent: reagrding alv format for like (internal tables)

    Hi,
    I making a report in which i am using the concept of 2 internal tables and i am usnig the concept of likes in a internal table .
    for instance,
    DATA : BEGIN OF ITAB OCCURS 0,
              ITEMID LIKE CHVW-MATNR,      
              WERKS LIKE CHVW-WERKS,   
              CHARG LIKE CHVW-CHARG,       
              SHKZG LIKE CHVW-SHKZG,       
              MENGE LIKE CHVW-MENGE,     
              MEINS LIKE CHVW-MEINS, 
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0,
               MATNR TYPE BSEG-MATNR,  
               LIFNR TYPE BSEG-LIFNR,       
               AUGDT TYPE BSEG-AUGDT,     
               WRBTR TYPE BSEG-WRBTR,      
             END OF IT_BSEG.
    and i am able to create ALV for 1 itab only as i had declared all fields in a 1 itab ,but now i have to declare 1 more itab and i  dont know how to perform ALV with 2 itabs..
    Plzz help me out as it is really urgent to me.
    Edited by: ric .s on Apr 22, 2008 11:45 AM
    Edited by: ric .s on Apr 23, 2008 7:21 AM
    Edited by: ric .s on Apr 23, 2008 7:55 AM

    Hi Ric,
    Yes, You can .
    Check the sample ALV  program which helps u in displaying output using ALV . Comments have been made everywhere .
    report  zvenkat_alv_2_grid_description.
    types:
          begin of t_mard,
           werks type mard-werks,
           lgort type mard-lgort,
           matnr type mard-matnr,
           insme type mard-insme,
           einme type mard-einme,
           speme type mard-speme,
          end of t_mard.
    data:
          w_mard type t_mard.
    data:
          i_mard type standard table of t_mard.
    " ALV Declarations
    "     ALV internal tables and Structures
    "     To refer ALV tables(slis tables) and structures.SLIS must be
    "     declared under TYPE-POOLS(see below).SLIS is a Type group which is
    "     defined in Dictionary.Internal tables and structures and constants
    "     are defined under type group.(Double click on SLIS).
    * Types Pools
    type-pools:
       slis.
    * Types
    types:
       t_fieldcat         type slis_fieldcat_alv,
       t_events           type slis_alv_event,
       t_layout           type slis_layout_alv.
    * Workareas
    data:
       w_fieldcat         type t_fieldcat,
       w_events           type t_events,
       w_layout           type t_layout.
    * Internal Tables
    data:
       i_fieldcat         type standard table of t_fieldcat,
       i_fieldcat1        type standard table of t_fieldcat,
       i_events           type standard table of t_events.
    *&      START-OF-SELECTION
    start-of-selection.
      perform get_data_from_database .
      "      END-OF-SELECTION
      "     Steps to create simple ALV program
      "      1. Pass an internal table with the set of output information
      "      2. Pass a field catalog as an internal table
      "      3. Pass a structure with general list layout details
    end-of-selection.
      perform build_fieldcatalog.
      perform build_events.
      perform build_layout.
      perform display_data.
      "      Form  build_fieldcatalog
      "     Fieldcatalog Internal table
      "    1. It contains descriptions of the list output fields
      "       (usually a subset of the internal output table fields).
      "    2. A field catalog is required for every ALV list output.
    form build_fieldcatalog .
      clear :
        w_fieldcat,
       i_fieldcat[].
      perform build_fcat using:
            "Field   Int.Table Column headings
            'WERKS' 'I_MARD' 'WERKS',
            'LGORT' 'I_MARD' 'LGORT',
            'MATNR' 'I_MARD' 'MATNR',
            'INSME' 'I_MARD' 'INSME',
            'EINME' 'I_MARD' 'EINME',
            'SPEME' 'I_MARD' 'SPEME'.
    endform.                    " build_fieldcatalog
    *&      Form  display_data
    form display_data .
      data :program like sy-repid value sy-repid.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
          i_callback_program = program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
          it_events          = i_events
        tables
          t_outtab           = i_mard.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " display_data
    *&      Form  get_data_from_database
    *       text
    form get_data_from_database .
      clear :i_mard,
             i_mard[].
      select werks lgort matnr insme einme speme
      from mard
      into corresponding fields of table i_mard
        up to 100 rows.
    endform.                    " get_data_from_database
    *&      Form  top_of_page
    *       text
    form top_of_page.
      data :
      i_header type slis_t_listheader,
      w_header like line of i_header.
      data:l_date1 type datum,
           l_date2 type datum.
      w_header-typ = 'S'.
      w_header-info = sy-title.
      append w_header to i_header.
      clear w_header.
      w_header-typ = 'H'.
      w_header-info = sy-repid.
      append w_header to i_header.
      clear w_header.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = i_header
          i_logo             = 'ENJOYSAP_LOGO'.
    endform.                    "top_of_page
    *&      Form  BUILD_FCAT
    form build_fcat  using  l_field l_tab l_text.
      w_fieldcat-fieldname = l_field.
      w_fieldcat-tabname   = l_tab.
      w_fieldcat-seltext_m = l_text.
      append w_fieldcat to i_fieldcat.
      clear w_fieldcat.
    endform.                    " BUILD_FCAT
    "      Form  build_events
    "     Events
    "    1. When we use ALV,certain events TOP-OF-PAGE ,END-OF-PAGE,
    "       AT LINE-SELECTION,AT USER-COMMANDs are not triggered.
    "    2. To perform those Functions ,we have to build Events table and
    "       pass this table through REUSE_ALV_LIST_DISPALY Function.
    form build_events .
      clear :
             w_events,i_events[].
      w_events-name = 'TOP_OF_PAGE'.
      w_events-form = 'TOP_OF_PAGE'.
      append w_events to i_events.
      clear w_events.
    endform.                    " build_events
    "&      Form  build_layout
    "     Layouts
    "  Use :We change the display of our list using layouts.
    "  ===
    "  Features
    "  ========
    "    The layouts that you can use vary according to the type of list:
    "   1-->In all lists, you can do the following:
    "       (a).Choose one of the std layouts supplied with the std system.
    "       (b).Change the current layout of the list .
    "   2-->In lists that use only the standard layouts in the std system
    "       you cannot save your changes to the current layout.When you
    "       choose the layouts, only the standard layouts will be proposed.
    "   3-->In some lists, you can also save the layouts that you have
    "       defined as our own layouts.
    "      User-defined layouts are generally saved for all users. They can
    "       then be used by all users. All users will be able to choose from
    "       the user-defined layouts as well as the standard layouts.
    "   4-->In some lists, you can also save user-specific layouts that you
    "       have defined . When you choose the current layout,only these
    "       layouts are available to you.
    "   5-->You can delete or transport layouts, or define them as initial
    "       layouts
    "   6-->STRUCTURE :SLIS_LAYOUT_ALV.
    form build_layout .
      clear:
            w_layout.
      w_layout-colwidth_optimize = 'X'.
    endform.                    " build_layout
    Regards,
    Venkat.O

  • Dynamic field access in internal tables

    Hi everyone.
    I woulkd like to know if there is any way to identify the fields of an internal table at runtime. I'm creating a method in a class, and i would like to accept any itab as a paramter and then access the fields of that itab. I currently have the itab passing no problem using field symbols, and i am able to loop at the data, but i am unsure how to get the field names.
    Any suggestions?
    Thanks!

    Hi,
    Check the code below:
    REPORT ZYKTEST3 .
    DATA: d_ref TYPE REF TO data,
    d_ref2 TYPE REF TO data,
    i_alv_cat TYPE TABLE OF lvc_s_fcat,
    ls_alv_cat LIKE LINE OF i_alv_cat.
    TYPES: tabname LIKE dcobjdef-name ,
    fieldname LIKE dcobjdef-name,
    desc LIKE dntab-fieldtext.
    PARAMETER: p_tablen TYPE tabname. -
    > Input table field
    DATA: BEGIN OF itab OCCURS 0.
    INCLUDE STRUCTURE dntab.
    DATA: END OF itab.
    FIELD-SYMBOLS : <f_fs> TYPE table,
    <f_fs1> TYPE table,
    <f_fs2> TYPE ANY,
    <f_fs3> TYPE ANY,
    <f_fs4> type any,
    <f_field> TYPE ANY.
    REFRESH itab.
    CALL FUNCTION 'NAMETAB_GET' -
    > Fetches the fields
    EXPORTING
    langu = sy-langu
    tabname = p_tablen
    TABLES
    nametab = itab
    EXCEPTIONS
    no_texts_found = 1.
    LOOP AT itab .
    ls_alv_cat-fieldname = itab-fieldname.
    ls_alv_cat-ref_table = p_tablen.
    ls_alv_cat-ref_field = itab-fieldname.
    ls_alv_cat-seltext = itab-fieldtext.
    ls_alv_cat-reptext = itab-fieldtext.
    APPEND ls_alv_cat TO i_alv_cat.
    ENDLOOP.
    internal table build
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = i_alv_cat
    IMPORTING
    ep_table = d_ref.
    ASSIGN d_ref->* TO <f_fs>. -
    > Dynamic table creation with fields of the table
    DATA: l_field TYPE fieldname,
    l_field1 type fieldname.
    SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <f_fs>.
    Fetching of the data from the table
    LOOP AT <f_fs> ASSIGNING <f_fs2>.
    Here u can check the validations and process
    ASSIGN COMPONENT 2 OF STRUCTURE <f_fs2> TO <f_fs3>.
    ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
    IF sy-subrc = 0.
    MOVE <f_fs3> TO l_field.
    MOVE <f_fs4> TO l_field1.
    WRITE:/1 l_field(20),
    22 l_field1(10).
    ENDIF.
    ENDLOOP.
    Regards
    Kannaiah

  • Dynamic Name for Yellow Interface Table

    Hi All,
    Can anybody guide me how to use dynamic name for Yellow Interface Target Table.
    Eg: T_SESSIONID.
    I tried
    1)Refreshing the SESSIONID in a Variable V1 and using T_#V1 directly
    2) Refreshing the T_#V1 in a Variable V2 and using #V2
    But its not creating properly.
    Please guide.

    You want to create dynamic target table name right?
    You can refresh a variable like #GET_SESSION
    #GET_SESSION= SELECT <%=odiRef.getSession("SESS_NAME")%> FROM DUAL
    My tmp table name like TMP_#GET_SESSION
    then in your package refresh #GET_SESSION variable and you can use it.
    I hope this can be helpful
    Thanks

Maybe you are looking for

  • Problem with Line Item display of G/L account

    Hi, I am struggling with a typical problem that I have two company codes in two different countries.  I have created a tax account with Open Item management and Line Item display in both the company codes. When I am trying to post vendor invoices, ta

  • Error While building the Sample Example

    Hi, I'm trying to run the first example in the following tutorial: http://docs.oracle.com/cd/E17904_01/web.1111/e13758/toc.htm Getting the following error: java.lang.NoClassDefFoundError: com/sun/xml/ws/model/RuntimeModeler at weblogic.wsee.util.Clas

  • Skype premium problems

    Hello. i just enrolled for the skype premium one month free trial. i was charged US$1 for the subscription and received a confirmation number. I have tried to make several calls with no success.

  • Unmarshaling problem in OSB File Transform

    Hi , i got a error " unmarshling binary to xml format " in osb filr operatioin . how to over come this problem.

  • Bindings Progmatically

    Is there a way to mess with a bound field (using bindings and an array controller) from your code? Currently I have an NSTableView getting its data and storing its data in a binding to an NSArrayController. This specific controller's entity is a subc