<?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: Dynamic Field type declaration in a structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038221#M1610530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: dref type ref data.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_str&amp;gt; type WOG0XXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CREATE DATA dref TYPE WOG0XXX.&lt;/P&gt;&lt;P&gt;  ASSIGN dref-&amp;gt;* TO &amp;lt;fs_str&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now &amp;lt;fs_str&amp;gt; can be used as WOG0XXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ssm on Jul 28, 2011 4:58 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lv_kunnr TYPE kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: kunnr TYPE REF TO data.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_kunnr&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;CREATE DATA kunnr TYPE kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_kunnr = '123'.&lt;/P&gt;&lt;P&gt;ASSIGN kunnr-&amp;gt;* TO &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;move lv_kunnr to &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;write: &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ssm on Jul 28, 2011 5:00 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jul 2011 11:27:17 GMT</pubDate>
    <dc:creator>Shahid</dc:creator>
    <dc:date>2011-07-28T11:27:17Z</dc:date>
    <item>
      <title>Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038219#M1610528</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;   How to declare the data element of a field dynamically in the structure i.e, how to define a field type dynamically in the structure?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Please find below example for better understanding of my query and share your ideas if we have a solution for such requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF ts_struc,&lt;/P&gt;&lt;P&gt;        fld1 TYPE matnr,&lt;/P&gt;&lt;P&gt;        fld2 TYPE maktx,&lt;/P&gt;&lt;P&gt;        fld3 TYPE mtart,&lt;/P&gt;&lt;P&gt;        fld4,&lt;/P&gt;&lt;P&gt;        fld5,&lt;/P&gt;&lt;P&gt;        fld6,        &lt;/P&gt;&lt;P&gt;       END OF ts_struc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: it_struc TYPE STANDARD TABLE OF ts_struc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_cc RADIOBUTTON GROUP rg1,&lt;/P&gt;&lt;P&gt;            p_us RADIOBUTTON GROUP rg1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if p_cc eq 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fld4, fld5, fld6 should be of type WOG0XXX.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif p_us eq 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fld4, fld5, fld6 should be of type WKG0XXX.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 11:19:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038219#M1610528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T11:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038220#M1610529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If we know the type of fields to be declared( i mean if we are not fetching them dynamically in the prog), we can create the two different structures ty_struct1 and ty_struct2 and then use them in the conditions for the declaration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if p_cc eq 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*fld4, fld5, fld6 should be of type WOG0XXX. &lt;/P&gt;&lt;P&gt;itab1 type table of ty_struct1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif p_us eq 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*fld4, fld5, fld6 should be of type WKG0XXX.&lt;/P&gt;&lt;P&gt;itab1 type table of ty_struct2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 11:27:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038220#M1610529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T11:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038221#M1610530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: dref type ref data.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_str&amp;gt; type WOG0XXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CREATE DATA dref TYPE WOG0XXX.&lt;/P&gt;&lt;P&gt;  ASSIGN dref-&amp;gt;* TO &amp;lt;fs_str&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now &amp;lt;fs_str&amp;gt; can be used as WOG0XXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ssm on Jul 28, 2011 4:58 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lv_kunnr TYPE kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: kunnr TYPE REF TO data.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_kunnr&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;CREATE DATA kunnr TYPE kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_kunnr = '123'.&lt;/P&gt;&lt;P&gt;ASSIGN kunnr-&amp;gt;* TO &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;move lv_kunnr to &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;write: &amp;lt;fs_kunnr&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ssm on Jul 28, 2011 5:00 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 11:27:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038221#M1610530</guid>
      <dc:creator>Shahid</dc:creator>
      <dc:date>2011-07-28T11:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038222#M1610531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deepak,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        Thanks for your response. The logic you suggested does not work since system throws a syntax error "itab1 is already declared" as we are trying to declare it again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 11:46:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038222#M1610531</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T11:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038223#M1610532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Shano,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You got to use the RTTC methods to generate the dynamic structure. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the COMPONENT_TABLE the rows for the fields fld1-fld3 will be static. And based on the condition mentioned, the type of the columns fld4-fld6 will either be WOG0XXX or WKG0XXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many threads available on the usage of RTTC methods. Search the forums, google it out &amp;amp; get back to us in case you have any problems using them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 12:04:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038223#M1610532</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-07-28T12:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038224#M1610533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shano,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;welcome in the world of field symbols:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:
  lr_itab type ref to table.
 field-symbols:
   &amp;lt;itab1&amp;gt; type table.
if p_cc eq 'X'.
  create data lr_itab type table of ty_struct1.
*fld4, fld5, fld6 should be of type WOG0XXX
elseif p_us eq 'X'.
  create data lr_itab type table of ty_struct2.
*fld4, fld5, fld6 should be of type WKG0XXX.
endif.
ASSIGN lr_itab-&amp;gt;* to &amp;lt;itab1&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now use &amp;lt;itab1&amp;gt; representing the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 12:49:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038224#M1610533</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-07-28T12:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038225#M1610534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          Thanks for the response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:  lr_itab type ref to table.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I am getting the error "You cannot declare a generic type after "REF TO". ".&lt;/P&gt;&lt;P&gt;Not  sure how to get rid of this error since I am new to ABAP OO. Can you please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 13:02:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038225#M1610534</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T13:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038226#M1610535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;TYPE REF TO data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See my above example&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 13:04:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038226#M1610535</guid>
      <dc:creator>Shahid</dc:creator>
      <dc:date>2011-07-28T13:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038227#M1610536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ssm and Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      Thanks for your quick response and your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 13:15:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038227#M1610536</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T13:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038228#M1610537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;shame on me, should know better. Thanks ssm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 08:19:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038228#M1610537</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-07-29T08:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field type declaration in a structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038229#M1610538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clemens, You know lot better and that helps us All.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 08:33:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-type-declaration-in-a-structure/m-p/8038229#M1610538</guid>
      <dc:creator>Shahid</dc:creator>
      <dc:date>2011-07-29T08:33:46Z</dc:date>
    </item>
  </channel>
</rss>

