<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: can i create dynamic table according database table ?? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356448#M520696</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;go to se24 and give the class name cl_alv_table_create check the methods parameter there. or you can call the method using pattern(ctrl+F6) also choose abap object radio button and give class name cl_alv_table_create and method name create_dynamic_table and it will give you all the parameters. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i believe you have to create field catalogby using reuse_alv_fieldcatalog_merge) first and then only you can create the dynamic int tbale for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;shiba dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2007 03:13:11 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-01T03:13:11Z</dc:date>
    <item>
      <title>can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356446#M520694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could i use database table for cl_alv_table_create=&amp;gt;create_dynamic_table to create table ? i mean, import a database table name to the method and create a internal table. now i only know parameters use fieldcatalog like this.&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;it_fieldcatalog = it_fieldcat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;more,  i doule click the method cl_alv_table_create=&amp;gt;create_dynamic_table  but just got a code part, how can i find the parameters definition of this method ? and why it's different from other method which i can browse the parameters by double clicking the method name in code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 03:06:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356446#M520694</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T03:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356447#M520695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one long way  to build field catalog using  REUSE_ALV_FIELDCATALOG_MERGE by passing the structure and build the fieldcatalog, not sure if there is any easy way...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;goto se24 and give the class name&lt;/P&gt;&lt;P&gt;and search for that method,&lt;/P&gt;&lt;P&gt;put the cursor on method name and click on parameters button&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 03:10:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356447#M520695</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T03:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356448#M520696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;go to se24 and give the class name cl_alv_table_create check the methods parameter there. or you can call the method using pattern(ctrl+F6) also choose abap object radio button and give class name cl_alv_table_create and method name create_dynamic_table and it will give you all the parameters. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i believe you have to create field catalogby using reuse_alv_fieldcatalog_merge) first and then only you can create the dynamic int tbale for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;shiba dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 03:13:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356448#M520696</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T03:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356449#M520697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table &lt;/P&gt;&lt;P&gt;       EXPORTING &lt;/P&gt;&lt;P&gt;        it_fieldcatalog = it_fieldcat &lt;/P&gt;&lt;P&gt;       IMPORTING &lt;/P&gt;&lt;P&gt;        ep_table        = new_table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;go through this link&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-basis-abap.com/sapab037.htm" target="test_blank"&gt;http://www.sap-basis-abap.com/sapab037.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 03:22:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356449#M520697</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T03:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356450#M520698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; Place ur cursor on class name not on method, if u double click there, it will take to that class with list of methods. As usual place ur cursor on CREATE_DYNAMIC_TABLE, then go for parameters tab which will list out all the parameters of that interface.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; U can use the FM : LVC_FIELDCATALOG_MERGE to create a field catalogue with the structure of ur DB table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_BUFFER_ACTIVE              =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    I_STRUCTURE_NAME          = 'ZOCM'  &amp;lt;b&amp;gt;"UR DB table&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-SatyaPriya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 03:24:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356450#M520698</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T03:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356451#M520699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are already on SAP release 6.40 (or higher) you can use the &amp;lt;b&amp;gt;TYPE HANDLE &amp;lt;/b&amp;gt;statement to create any internal table you like.&lt;/P&gt;&lt;P&gt;The simplified version of de-referencing a data reference to a table type field symbol is already available since 6.20 (perhaps on 4.6c, too).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_RTTI_CREATE_STRUCTURES
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_rtti_create_structures.


TYPE-POOLS: abap.


DATA:
  celltab          TYPE lvc_t_styl.

DATA:
  go_table         TYPE REF TO cl_salv_table,
  go_sdescr        TYPE REF TO cl_abap_structdescr,
  go_tdescr        TYPE REF TO cl_abap_tabledescr,
  gdo_data         TYPE REF TO data,
  gdo_handle       TYPE REF TO data,
  gs_comp          TYPE abap_componentdescr,
  gt_components    TYPE abap_component_tab.
*
*    name       TYPE string,
*    type       TYPE REF TO cl_abap_datadescr,
*    as_include TYPE abap_bool,
*    suffix     TYPE string,

FIELD-SYMBOLS:
  &amp;lt;gd_fld&amp;gt;      TYPE ANY,
  &amp;lt;gs_struc&amp;gt;    TYPE ANY,
  &amp;lt;gt_itab&amp;gt;     TYPE table.


PARAMETER:
  p_tabnam      TYPE tabname  DEFAULT 'KNB1'.

START-OF-SELECTION.

* Create dynamically structure
  CREATE DATA gdo_data TYPE (p_tabnam).
  ASSIGN gdo_data-&amp;gt;* TO &amp;lt;gs_struc&amp;gt;.
  CHECK ( &amp;lt;gs_struc&amp;gt; IS ASSIGNED ).


* Simulate dynamic addition of columns to ALV list
  DO 10 TIMES.
    ASSIGN COMPONENT syst-index OF STRUCTURE &amp;lt;gs_struc&amp;gt; TO &amp;lt;gd_fld&amp;gt;.

    CLEAR: gs_comp.
    gs_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_data( &amp;lt;gd_fld&amp;gt; ).
    gs_comp-name  = gs_comp-type-&amp;gt;get_relative_name( ).
    APPEND gs_comp TO gt_components.

    go_sdescr  = cl_abap_structdescr=&amp;gt;create( gt_components ).
    go_tdescr  = cl_abap_tabledescr=&amp;gt;create( go_sdescr ).
    "   Create data refence followed by table creation
    CREATE DATA gdo_handle TYPE HANDLE go_tdescr.
    ASSIGN gdo_handle-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.

*   Dynamic select
    SELECT        * FROM  (p_tabnam)
      INTO CORRESPONDING FIELDS OF TABLE &amp;lt;gt_itab&amp;gt;
           WHERE  bukrs  = '2000'.

    TRY.
        CALL METHOD cl_salv_table=&amp;gt;factory
          IMPORTING
            r_salv_table = go_table
          CHANGING
            t_table      = &amp;lt;gt_itab&amp;gt;.
        go_table-&amp;gt;display( ).
      CATCH cx_salv_msg .
    ENDTRY.

  ENDDO.


  " Add table type as field to structure
  CLEAR: gs_comp.
  gs_comp-type ?= cl_abap_typedescr=&amp;gt;describe_by_data( celltab ).
  gs_comp-name  = 'CELLTAB'.
  APPEND gs_comp TO gt_components.

  go_sdescr  = cl_abap_structdescr=&amp;gt;create( gt_components ).
  go_tdescr  = cl_abap_tabledescr=&amp;gt;create( go_sdescr ).
  CREATE DATA gdo_handle TYPE HANDLE go_tdescr.
  ASSIGN gdo_handle-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.

*   Dynamic select
  SELECT        * FROM  (p_tabnam)
    INTO CORRESPONDING FIELDS OF TABLE &amp;lt;gt_itab&amp;gt;
         WHERE  bukrs  = '2000'.



  " Simplified version of table creation:
  CLEAR: gdo_data.
  UNASSIGN &amp;lt;gt_itab&amp;gt;.

  CREATE DATA gdo_data TYPE (p_tabnam).
  ASSIGN gdo_data-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.


END-OF-SELECTION.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 04:12:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356451#M520699</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-06-01T04:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356452#M520700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Jagarlamudi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you very much !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i use your method, but now i has another problem.&lt;/P&gt;&lt;P&gt;the data type in cl_alv_table_create=&amp;gt;create_dynamic_table is  lvc_t_fcat but the type in REUSE_ALV_FIELDCATALOG_MERGE is slis_t_fieldcat_alv, how to convert from slis_t_fieldcat_alv to lvc_t_fcat ?&lt;/P&gt;&lt;P&gt; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 05:12:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356452#M520700</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T05:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356453#M520701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use LVC_FIELDCATALOG_MERGE fn module it will take that lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;other wise you have to&lt;/P&gt;&lt;P&gt;loop at ifieldcat into wfieldcat.&lt;/P&gt;&lt;P&gt;wlvc_fieldcat = wfieldcat-&amp;lt;fieldname &amp;gt;.&lt;/P&gt;&lt;P&gt;for each and every field &amp;lt;because in some cases you cant use move-corresponding&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and append thewlvc_fcatto  ilvc_t_fcat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;shiba dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 05:19:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356453#M520701</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T05:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356454#M520702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u can create the dynamic internal table without using class too..and if u want to create field catalog also then create it using field catalog merge function.&lt;/P&gt;&lt;P&gt;Program to create dynamic internal table -  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZGILL_FS                                                    *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZGILL_FS     line-size 250
                     line-count 65 .


*************Creating Dynamic internal table*************

parameter p_table type tabname.

field-symbols &amp;lt;tab&amp;gt; type table.
field-symbols &amp;lt;tab1&amp;gt; type any.


types: begin of itab,
      t_name type tabname,
      t_ref type ref to data,
      end of itab.

data itab1 type table of itab with non-unique key t_name.

perform fetch_data using p_table.
perform print_table using p_table.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fetch_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_P_TABLE  text
*----------------------------------------------------------------------*
FORM fetch_data  USING P_TABLE1 type tabname.

data itab2 type itab.
itab2-t_name = p_table1.

create data itab2-t_ref type table of (itab2-t_name) .

assign itab2-t_ref-&amp;gt;* to &amp;lt;tab&amp;gt;.

append itab2 to itab1.

select * from (p_table1) up to 25 rows into corresponding fields of table &amp;lt;tab&amp;gt;.

ENDFORM.                    " fetch_data
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  print_table
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_P_TABLE  text
*----------------------------------------------------------------------*
FORM print_table  USING P_TABLE1 type tabname.

DATA t_ref1 TYPE REF TO data.
DATA itab2 TYPE itab.

FIELD-SYMBOLS &amp;lt;field&amp;gt; TYPE ANY.

READ TABLE itab1 INTO itab2 WITH KEY t_name = p_table1.

ASSIGN itab2-t_ref-&amp;gt;* TO &amp;lt;tab&amp;gt;.

CREATE DATA t_ref1 LIKE LINE OF &amp;lt;tab&amp;gt;.

ASSIGN t_ref1-&amp;gt;* TO &amp;lt;tab1&amp;gt;.

DO.
*READ TABLE &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;tab1&amp;gt; INDEX 1.
READ TABLE &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;tab1&amp;gt; INDEX SY-INDEX.
*WRITE:/ p_table1.
NEW-LINE.
IF sy-subrc &amp;lt;&amp;gt; 0.
EXIT.
ENDIF.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;tab1&amp;gt; TO &amp;lt;field&amp;gt;.
IF sy-subrc &amp;lt;&amp;gt; 0.
EXIT.
ENDIF.
WRITE: &amp;lt;field&amp;gt;,'    '.
ENDDO.
ENDDO.
ENDFORM.                    " print_table
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 05:20:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356454#M520702</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T05:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: can i create dynamic table according database table ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356455#M520703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on previous code example on dynamic ALV :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get table T002 (or any other) as first structure and add any internal field (FIELD1 TYPE WERKS_D) in the ouput (FIELD1 should be populated also.  Not done here) :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zus_sdn_rtti_create_structure3.

TYPE-POOLS: abap.

DATA:
  go_table         TYPE REF TO cl_salv_table,
  go_sdescr        TYPE REF TO cl_abap_structdescr,
  go_tdescr        TYPE REF TO cl_abap_tabledescr,
  gdo_handle       TYPE REF TO data,
  gt_components    TYPE abap_component_tab.

FIELD-SYMBOLS:
  &amp;lt;gt_itab&amp;gt;     TYPE table.

PARAMETER:
  p_tabnam      TYPE tabname  DEFAULT 'T002'.

START-OF-SELECTION.
* get the table (structure) definition
  go_sdescr ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_tabnam ).
* add each field (+ description) in component table
  gt_components = go_sdescr-&amp;gt;get_components( ).

* / add new field
  DATA field1 TYPE werks_d.
  DATA gs_comp TYPE abap_componentdescr.
  CLEAR gs_comp.
  gs_comp-type ?= cl_abap_typedescr=&amp;gt;describe_by_data( field1 ).
  gs_comp-name = 'FIELD1'.
  APPEND gs_comp TO gt_components.
* \-------------------

* Structure type creation
  go_sdescr  = cl_abap_structdescr=&amp;gt;create( gt_components ).
* Table type creation
  go_tdescr  = cl_abap_tabledescr=&amp;gt;create( go_sdescr ).
* Create data refence followed by table creation
  CREATE DATA gdo_handle TYPE HANDLE go_tdescr.
  ASSIGN gdo_handle-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.

*   Dynamic select
  SELECT        * FROM  (p_tabnam)
    UP TO 10 ROWS
    INTO CORRESPONDING FIELDS OF TABLE &amp;lt;gt_itab&amp;gt;.

  TRY.
      CALL METHOD cl_salv_table=&amp;gt;factory
        IMPORTING
          r_salv_table = go_table
        CHANGING
          t_table      = &amp;lt;gt_itab&amp;gt;.
      go_table-&amp;gt;display( ).
    CATCH cx_salv_msg .
  ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vincent Noiset on Aug 28, 2008 2:51 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:49:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-i-create-dynamic-table-according-database-table/m-p/2356455#M520703</guid>
      <dc:creator>former_member202734</dc:creator>
      <dc:date>2008-08-28T12:49:58Z</dc:date>
    </item>
  </channel>
</rss>

