<?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: Dynamically create a type in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097701#M1508023</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jan 2014 10:50:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-01-14T10:50:30Z</dc:date>
    <item>
      <title>Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097691#M1508013</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;is it possible to create dynamically a type ? I take a look on class CL_ABAP_TYPEDESCR but i can't create a new type, so is there a solution ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jul 2010 13:39:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097691#M1508013</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-01T13:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097692#M1508014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you mean by dynamic type ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:wf_ref TYPE REF TO data,&lt;/P&gt;&lt;P&gt;        wf_line TYPE REF TO data.&lt;/P&gt;&lt;P&gt;field-symbols:&amp;lt;fs_tab&amp;gt; TYPE STANDARD TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA wf_ref TYPE TABLE OF (wf_tab). "Dynamic Itab&lt;/P&gt;&lt;P&gt;ASSIGN wf_ref-&amp;gt;* TO &amp;lt;fs_tab&amp;gt;.&lt;/P&gt;&lt;P&gt;CREATE DATA wf_line LIKE LINE OF &amp;lt;fs_tab&amp;gt;.  "Dynamic Work area&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jul 2010 14:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097692#M1508014</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-07-01T14:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097693#M1508015</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;I think, Dynamic type means the one we declare using TYPES has to be dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create the fieldcatelog and call the method cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING
*     I_STYLE_TABLE             =
      it_fieldcatalog           = i_fieldcat_dyn
    IMPORTING
      ep_table                  = &amp;lt;fs_table&amp;gt;
*     E_STYLE_FNAME             =
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2
            .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here in internal table i_fieldcat_dyn define the fields dynamically based on the requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jul 2010 16:03:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097693#M1508015</guid>
      <dc:creator>vinod_vemuru2</dc:creator>
      <dc:date>2010-07-01T16:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097694#M1508016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinod,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i got it, just some more additions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: new_table TYPE REF TO data. &lt;/P&gt;&lt;P&gt;DATA: new_line  TYPE REF TO data. &lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE ANY TABLE, &lt;/P&gt;&lt;P&gt;               &amp;lt;fs_line&amp;gt;  TYPE ANY, &lt;/P&gt;&lt;P&gt;&lt;/P&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           = i_fieldcat_dyn&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                  = new_table&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;      OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN newtable-&amp;gt;* TO &amp;lt;fs_table&amp;gt;. &lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;fs_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jul 2010 16:09:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097694#M1508016</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-07-01T16:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097695#M1508017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With all due respect to all, I think he means to create dynamic data types by means of RTTS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;@ ToraTora&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"example table
DATA: BEGIN OF it OCCURS 3,
        pernr TYPE persno,
        kostl TYPE kostl,
        endda TYPE endda,
      END OF it.

"data references
DATA: r_type_struct TYPE REF TO cl_abap_structdescr,
      r_type_table  TYPE REF TO cl_abap_tabledescr,
      r_data_tab    TYPE REF TO data,
      r_data_str    TYPE REF TO data.

" 1. ------------- filling example table IT
it-pernr = '12345678'.
it-kostl = '0112345678'.
it-endda = sy-datum.
APPEND it.

it-pernr = '45678909'.
it-kostl = '3452345678'.
it-endda = sy-datum - 1.
APPEND it.

" 2. ------------ components structure type
gs_comp-name = 'PERNR'.
gs_comp-type ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'PERSNO' ).
APPEND gs_comp TO gt_comp.

gs_comp-name = 'KOSTL'.
gs_comp-type ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'KOSTL' ).
APPEND gs_comp TO gt_comp.

gs_comp-name = 'BEGDA'.
gs_comp-type ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'BEGDA' ).
APPEND gs_comp TO gt_comp.

" 3. ------------- create structure type
TRY.
    r_type_struct = cl_abap_structdescr=&amp;gt;create(
                              p_components = gt_comp ).
  CATCH cx_sy_struct_creation .
ENDTRY.

" 4. ------------- create table type
TRY.
    r_type_table = cl_abap_tabledescr=&amp;gt;create( r_type_struct ).

  CATCH cx_sy_table_creation .
ENDTRY.

" 5. -------------- create table based on RTTS types
CREATE DATA: r_data_tab TYPE HANDLE r_type_table,
             r_data_str TYPE HANDLE r_type_struct.

FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE INDEX TABLE,
               &amp;lt;fs_wa&amp;gt;    TYPE ANY.

ASSIGN: r_data_tab-&amp;gt;* TO &amp;lt;fs_table&amp;gt;,
        r_data_str-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can also create any component you want without knowledge about data element it is refering to (without using methods &lt;EM&gt;describe_by_name&lt;/EM&gt; or &lt;EM&gt;describe_by_data&lt;/EM&gt; ).&lt;/P&gt;&lt;P&gt;So the 2nd step could be replaced with&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
gs_comp-name = 'PERNR'.
gs_comp-type ?= cl_abap_datadescr=&amp;gt;get_n( 8 ).   "PERNR if of type N(8)
APPEND gs_comp TO gt_comp.

gs_comp-name = 'KOSTL'.
gs_comp-type ?= cl_abap_elemdescr=&amp;gt;get_c( 10 ).  "C(10)
APPEND gs_comp TO gt_comp.

gs_comp-name = 'BEGDA'.
gs_comp-type ?= cl_abap_elemdescr=&amp;gt;get_d( ).   "D
APPEND gs_comp TO gt_comp.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jul 2010 17:06:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097695#M1508017</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-07-01T17:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097696#M1508018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; With all due respect to all, I think he means to create dynamic data types by means of RTTS. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And i think creating dynamic program components using RTTS is much easier to understand / maintain than the cl_alv_table_create=&amp;gt;create_dynamic_table . In the latter you donot have an insight how the field catalog is converted into a dynamic table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the RTTS method, the entire process can be broken down into individual steps &amp;amp; easily understood (as you have already mentioned in your post)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any comments are welcome. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: BTW Marcin very good example. 10 p*ints from me &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jul 2010 02:22:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097696#M1508018</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-07-02T02:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097697#M1508019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;big thanks to Marcin, he understand well my need, I did everything I wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And i agree with Suhas it's more easier and flexibe to understand RTTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jul 2010 07:24:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097697#M1508019</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-02T07:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097698#M1508020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any comments are welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I will dare to add mine then. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW: thanks for kind words, as usual you make my day:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RTTS also allow to create individual data types, complex structures (including nested ones) and even reference types. This cannot be achieved in any way by means of &lt;EM&gt;create_dynamic_table&lt;/EM&gt; . The fieldcatalog this method uses however allows to type components not only refering to DDIC ones.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow I think the main difference in using both techniques is that first serves the purpose of creating only &lt;EM&gt;types&lt;/EM&gt; , which we can later use to create real data objects. The latter, in contrary allows only to create data objects, more specifically a table. Of course deriving the work area from it is feasible later (as shown by Keshav). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So depending on context we can use one technique as a replacement for the other. Personally it gives me a great joy to work with RTTS as I am able to "sculpt" every single data element.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jul 2010 13:23:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097698#M1508020</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-07-02T13:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097699#M1508021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Marcin,&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;     can you please please share another (complete) example ?  on creating a dynamic type. I will really appreciate your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My requirement is that i have developed a complex code using the normal internal tables and defined normal structures in it. After completion of the code my requirement changed as to make all the structures dynamic and so internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I created a dynamic internal table by passing CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table. By using this method i can get a field symbol as my internal table ( my old code is in normal internal tables.. i cannot change the entire code now to fieldsymbols).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will use your approach of creating dynamic types and use  my same old internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 09:54:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097699#M1508021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-11T09:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097700#M1508022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Everything is possible in sap ABAP, you can create dynamic internal table, structure, data element, field, table and class so firstly tell me which thing you want to create..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Nammi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 09:04:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097700#M1508022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-21T09:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create a type</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097701#M1508023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 10:50:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-a-type/m-p/7097701#M1508023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-14T10:50:30Z</dc:date>
    </item>
  </channel>
</rss>

