<?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: Generate Dynamic Structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169279#M1517039</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create it many ways.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If you have the structure name..&lt;/P&gt;&lt;P&gt;  create data l_dref type standard table of (v_table).&lt;/P&gt;&lt;P&gt;  assign l_dref-&amp;gt;*   to &amp;lt;i_master&amp;gt;. " Internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data l_dwa  like line of &amp;lt;i_master&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign l_dwa-&amp;gt;*    to &amp;lt;wa_master&amp;gt;. " Work area&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If you don't have particular structure name. Fields properties are known&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate fields catalog&lt;/P&gt;&lt;P&gt;  data: l_wa_fcat    type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_wa_fcat-fieldname = p_field.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-datatype  = 'CHAR'.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-inttype   = 'C'.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-intlen    = p_len.&lt;/P&gt;&lt;P&gt;  append l_wa_fcat to i_fcat.&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_fcat&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;      ep_table        = dy_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign dy_table-&amp;gt;* to &amp;lt;i_itab&amp;gt;.   " Interanal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data dy_line like line of &amp;lt;i_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;wa_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If any think you don't know unless run time (like length, type etc) Then use RTTS method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_gs_comp-type ?= cl_abap_typedescr=&amp;gt;describe_by_data( v_mode ). " here v_mode is a variable and I want to add same field in the structure&lt;/P&gt;&lt;P&gt;  l_gs_comp-name  = l_field. " Structure Field name&lt;/P&gt;&lt;P&gt;  append l_gs_comp to l_gt_components.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create instances of dynamic structure and dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  l_go_sdescr_new  = cl_abap_structdescr=&amp;gt;create( l_gt_components ). " ref Stucture&lt;/P&gt;&lt;P&gt;  l_go_tdescr      = cl_abap_tabledescr=&amp;gt;create( l_go_sdescr_new ).       " Ref Itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create data refence followed by table creation&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data l_gdo_handle type handle l_go_tdescr.&lt;/P&gt;&lt;P&gt;  assign l_gdo_handle-&amp;gt;* to &amp;lt;i_deep&amp;gt;.     " Itab&lt;/P&gt;&lt;P&gt;  create data dy_deep like line of &amp;lt;i_deep&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_deep-&amp;gt;* to &amp;lt;wa_deep&amp;gt;.   " WA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subhankar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 29 Aug 2010 19:04:01 GMT</pubDate>
    <dc:creator>Subhankar</dc:creator>
    <dc:date>2010-08-29T19:04:01Z</dc:date>
    <item>
      <title>Generate Dynamic Structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169277#M1517037</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;     Can anyone tell me how to generate a reference to the structure dynamically without using statement &lt;/P&gt;&lt;P&gt;      1) GENERATE SUB-ROUTINE POOL and &lt;/P&gt;&lt;P&gt;      2) passing the referebce to field-symbol&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      My structure fields are present in an internal table(with some other fields as well)&lt;/P&gt;&lt;P&gt;       Eg: Internal table contains Field1,field2......upto Field 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      But i need the reference to the structure only for Field1,Field /5/6/7 only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       How to do this??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Madan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Aug 2010 18:31:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169277#M1517037</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-29T18:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Dynamic Structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169278#M1517038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you elaborate your requirement ? You want to create the structure based on the fields of the previous internal table ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Aug 2010 18:53:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169278#M1517038</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-08-29T18:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Dynamic Structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169279#M1517039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create it many ways.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If you have the structure name..&lt;/P&gt;&lt;P&gt;  create data l_dref type standard table of (v_table).&lt;/P&gt;&lt;P&gt;  assign l_dref-&amp;gt;*   to &amp;lt;i_master&amp;gt;. " Internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data l_dwa  like line of &amp;lt;i_master&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign l_dwa-&amp;gt;*    to &amp;lt;wa_master&amp;gt;. " Work area&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If you don't have particular structure name. Fields properties are known&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate fields catalog&lt;/P&gt;&lt;P&gt;  data: l_wa_fcat    type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_wa_fcat-fieldname = p_field.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-datatype  = 'CHAR'.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-inttype   = 'C'.&lt;/P&gt;&lt;P&gt;  l_wa_fcat-intlen    = p_len.&lt;/P&gt;&lt;P&gt;  append l_wa_fcat to i_fcat.&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_fcat&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;      ep_table        = dy_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign dy_table-&amp;gt;* to &amp;lt;i_itab&amp;gt;.   " Interanal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data dy_line like line of &amp;lt;i_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;wa_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If any think you don't know unless run time (like length, type etc) Then use RTTS method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_gs_comp-type ?= cl_abap_typedescr=&amp;gt;describe_by_data( v_mode ). " here v_mode is a variable and I want to add same field in the structure&lt;/P&gt;&lt;P&gt;  l_gs_comp-name  = l_field. " Structure Field name&lt;/P&gt;&lt;P&gt;  append l_gs_comp to l_gt_components.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create instances of dynamic structure and dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  l_go_sdescr_new  = cl_abap_structdescr=&amp;gt;create( l_gt_components ). " ref Stucture&lt;/P&gt;&lt;P&gt;  l_go_tdescr      = cl_abap_tabledescr=&amp;gt;create( l_go_sdescr_new ).       " Ref Itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create data refence followed by table creation&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data l_gdo_handle type handle l_go_tdescr.&lt;/P&gt;&lt;P&gt;  assign l_gdo_handle-&amp;gt;* to &amp;lt;i_deep&amp;gt;.     " Itab&lt;/P&gt;&lt;P&gt;  create data dy_deep like line of &amp;lt;i_deep&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_deep-&amp;gt;* to &amp;lt;wa_deep&amp;gt;.   " WA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subhankar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Aug 2010 19:04:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/generate-dynamic-structure/m-p/7169279#M1517039</guid>
      <dc:creator>Subhankar</dc:creator>
      <dc:date>2010-08-29T19:04:01Z</dc:date>
    </item>
  </channel>
</rss>

