<?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: How to define data types dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061173#M1176141</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;chk out the following link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdev.co.uk/sap-help/dynamic-structure.htm" target="test_blank"&gt;http://www.sapdev.co.uk/sap-help/dynamic-structure.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Jayapriya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jan 2009 15:37:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-20T15:37:05Z</dc:date>
    <item>
      <title>How to define data types dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061169#M1176137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need to define a data type at the runtime without referencing it to any structure or ddid objects whatsoever. &lt;/P&gt;&lt;P&gt;i.e. say I select a list of fields based on some condition and create an internal able whose structure is same as the list of fields that&lt;/P&gt;&lt;P&gt;I have selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did go through documentation on field symbols but I could not find anything on field symbols that achieved this without referencing a predefined structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say I get the following fields from some Z table based on a specific query,I need to construct a internal table based on this structure.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   mandt&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   carrid &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   connid&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 15:25:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061169#M1176137</guid>
      <dc:creator>Private_Member_17805</dc:creator>
      <dc:date>2009-01-20T15:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to define data types dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061170#M1176138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what about class CL_ALV_TABLE_CREATE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 15:30:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061170#M1176138</guid>
      <dc:creator>Sm1tje</dc:creator>
      <dc:date>2009-01-20T15:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to define data types dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061171#M1176139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I think you will need to have the table name as well as the field name when getting the DDIC information.  Just having the field name is not enough here.  So if you have an internal table with the field names, you may want to add the table name as well or add another field to your internal table, which contains the table name.  In the below example, I am adding fields dynamically to the GT_COMPONENTS tab, you will want to do this, instead you will loop at your internal table, and pass the names of the fields and the table/field name to the DESCRIBE_BY_NAME method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPE-POOLS:
  abap.

DATA:
  gr_structdescr    TYPE REF TO cl_abap_structdescr,
  gr_tabledescr     TYPE REF TO cl_abap_tabledescr,
  gr_datadescr      TYPE REF TO cl_abap_datadescr,
  gt_components     TYPE abap_component_tab,
  gw_component      TYPE LINE OF abap_component_tab,
  gr_wa             TYPE REF TO data,
  gr_tab            TYPE REF TO data.

FIELD-SYMBOLS: &amp;lt;fs_wa&amp;gt; TYPE ANY.
FIELD-SYMBOLS: &amp;lt;fs_tab&amp;gt; TYPE table.

START-OF-SELECTION.

* determine components of structure -&amp;gt; GT_COMPONENTS
  MOVE 'MANDT' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;DESCRIBE_BY_NAME( 'SPFLI-MANDT' ).
  INSERT gw_component INTO TABLE gt_components.

  MOVE 'CARRID' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;DESCRIBE_BY_NAME( 'SPFLI-CARRID' ).
  INSERT gw_component INTO TABLE gt_components.

  MOVE 'CONNID' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;DESCRIBE_BY_NAME( 'SPFLI-CONNID' ).
  INSERT gw_component INTO TABLE gt_components.

* get structure descriptor -&amp;gt; GR_STRUCTDESCR
  gr_structdescr ?= cl_abap_structdescr=&amp;gt;create( gt_components ).

* create work area of structure GR_STRUCTDESCR -&amp;gt; GR_WA
  CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
  ASSIGN gr_wa-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.


  gr_datadescr ?= gr_structdescr.
  gr_tabledescr ?= cl_abap_tabledescr=&amp;gt;create( gr_datadescr ).

* Create dynmaic internal table
  CREATE DATA gr_tab TYPE HANDLE gr_tabledescr.
  ASSIGN gr_tab-&amp;gt;* TO &amp;lt;fs_tab&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 15:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061171#M1176139</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2009-01-20T15:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to define data types dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061172#M1176140</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;data:i_data            type ref to data.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_data&amp;gt; type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign i_data to &amp;lt;fs_data&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*CREATING INTERNAL TABLE TO DISPLAY ALV DATA&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_fieldlist&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;      ep_table                  = &amp;lt;fs_data&amp;gt;&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 15:36:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061172#M1176140</guid>
      <dc:creator>dev_parbutteea</dc:creator>
      <dc:date>2009-01-20T15:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to define data types dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061173#M1176141</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;chk out the following link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdev.co.uk/sap-help/dynamic-structure.htm" target="test_blank"&gt;http://www.sapdev.co.uk/sap-help/dynamic-structure.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Jayapriya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 15:37:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-define-data-types-dynamically/m-p/5061173#M1176141</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-20T15:37:05Z</dc:date>
    </item>
  </channel>
</rss>

