<?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 Creating table at runtime w/o knowing the structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761992#M1461829</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 have searched high and far to find a solution for my needs, but have not come across anything. Hopefully, the knowledge here is greater than my searching skills &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In an ABAP called during Dynamic Actions I have the need for storing data retrieved from the Call Stack via an ASSIGN command:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: gv_ps_ref TYPE char50 VALUE '(SAPFP50P)PS[]'.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;gt_ps_table&amp;gt; TYPE STANDARD TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN (gv_ps_ref) TO &amp;lt;gt_ps_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ASSIGN part works beautifully - in debugging I now have access to the data in the PS table. But I need to store the data locally, as PS gets refreshed by this, which then also refreshes my &amp;lt;GT_PS_TABLE&amp;gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM initialize_ps(sapfp50p).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing is, I need the data for later use, so I want to separate the link and create a local copy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code (most of it copied from other solutions here on SDN) works fine, but notice that the DESCRIBE_BY_DATA method is called with the GS_DATA structure. This means that the TYPE of the table that I want to create dynamically is known.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: BEGIN OF gt_data OCCURS 5,&lt;/P&gt;&lt;P&gt;        char   TYPE text5,&lt;/P&gt;&lt;P&gt;        numc   TYPE numc5,&lt;/P&gt;&lt;P&gt;        dec    TYPE pad_amt7s,&lt;/P&gt;&lt;P&gt;      END OF gt_data.&lt;/P&gt;&lt;P&gt;DATA: gs_data LIKE LINE OF gt_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: go_struct   TYPE REF TO cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      go_new_type TYPE REF TO cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      go_new_tab  TYPE REF TO cl_abap_tabledescr,&lt;/P&gt;&lt;P&gt;      gt_comp     TYPE cl_abap_structdescr=&amp;gt;component_table,&lt;/P&gt;&lt;P&gt;      go_data     TYPE REF TO data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_any&amp;gt; TYPE ANY TABLE.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;go_struct  ?= cl_abap_typedescr=&amp;gt;describe_by_data( gs_data ).    "see alternate reference below, i.e. my need&lt;/P&gt;&lt;P&gt;gt_comp     = go_struct-&amp;gt;get_components( ).&lt;/P&gt;&lt;P&gt;go_new_type = cl_abap_structdescr=&amp;gt;create( gt_comp ).&lt;/P&gt;&lt;P&gt;go_new_tab  = cl_abap_tabledescr=&amp;gt;create(&lt;/P&gt;&lt;P&gt;                     p_line_type  = go_new_type&lt;/P&gt;&lt;P&gt;                     p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std&lt;/P&gt;&lt;P&gt;                     p_unique     = abap_false ).&lt;/P&gt;&lt;P&gt;CREATE DATA go_data TYPE HANDLE go_new_tab.&lt;/P&gt;&lt;P&gt;ASSIGN go_data-&amp;gt;* TO &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_any&amp;gt; = gt_data[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As indicated, having only a reference to the PS table (&amp;lt;GT_PS_TABLE&amp;gt;) is not enough, I want to create a copy of PS locally, without knowing how it is declared in FP50PPSB (partly via a structure, partly via separate fields), as this will make my coding insensitive to any change in the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my visualization of what I want to do, or the likes - I believe you get the idea. But is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;go_struct ?= cl_abap_typedescr=&amp;gt;describe_by_data( &amp;lt;gt_ps_table&amp;gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax checker allows for this, but it dumps at runtime &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Apr 2010 08:25:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-04-08T08:25:00Z</dc:date>
    <item>
      <title>Creating table at runtime w/o knowing the structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761992#M1461829</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 have searched high and far to find a solution for my needs, but have not come across anything. Hopefully, the knowledge here is greater than my searching skills &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In an ABAP called during Dynamic Actions I have the need for storing data retrieved from the Call Stack via an ASSIGN command:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: gv_ps_ref TYPE char50 VALUE '(SAPFP50P)PS[]'.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;gt_ps_table&amp;gt; TYPE STANDARD TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN (gv_ps_ref) TO &amp;lt;gt_ps_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ASSIGN part works beautifully - in debugging I now have access to the data in the PS table. But I need to store the data locally, as PS gets refreshed by this, which then also refreshes my &amp;lt;GT_PS_TABLE&amp;gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM initialize_ps(sapfp50p).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing is, I need the data for later use, so I want to separate the link and create a local copy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code (most of it copied from other solutions here on SDN) works fine, but notice that the DESCRIBE_BY_DATA method is called with the GS_DATA structure. This means that the TYPE of the table that I want to create dynamically is known.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: BEGIN OF gt_data OCCURS 5,&lt;/P&gt;&lt;P&gt;        char   TYPE text5,&lt;/P&gt;&lt;P&gt;        numc   TYPE numc5,&lt;/P&gt;&lt;P&gt;        dec    TYPE pad_amt7s,&lt;/P&gt;&lt;P&gt;      END OF gt_data.&lt;/P&gt;&lt;P&gt;DATA: gs_data LIKE LINE OF gt_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: go_struct   TYPE REF TO cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      go_new_type TYPE REF TO cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      go_new_tab  TYPE REF TO cl_abap_tabledescr,&lt;/P&gt;&lt;P&gt;      gt_comp     TYPE cl_abap_structdescr=&amp;gt;component_table,&lt;/P&gt;&lt;P&gt;      go_data     TYPE REF TO data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_any&amp;gt; TYPE ANY TABLE.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;go_struct  ?= cl_abap_typedescr=&amp;gt;describe_by_data( gs_data ).    "see alternate reference below, i.e. my need&lt;/P&gt;&lt;P&gt;gt_comp     = go_struct-&amp;gt;get_components( ).&lt;/P&gt;&lt;P&gt;go_new_type = cl_abap_structdescr=&amp;gt;create( gt_comp ).&lt;/P&gt;&lt;P&gt;go_new_tab  = cl_abap_tabledescr=&amp;gt;create(&lt;/P&gt;&lt;P&gt;                     p_line_type  = go_new_type&lt;/P&gt;&lt;P&gt;                     p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std&lt;/P&gt;&lt;P&gt;                     p_unique     = abap_false ).&lt;/P&gt;&lt;P&gt;CREATE DATA go_data TYPE HANDLE go_new_tab.&lt;/P&gt;&lt;P&gt;ASSIGN go_data-&amp;gt;* TO &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_any&amp;gt; = gt_data[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As indicated, having only a reference to the PS table (&amp;lt;GT_PS_TABLE&amp;gt;) is not enough, I want to create a copy of PS locally, without knowing how it is declared in FP50PPSB (partly via a structure, partly via separate fields), as this will make my coding insensitive to any change in the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my visualization of what I want to do, or the likes - I believe you get the idea. But is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;go_struct ?= cl_abap_typedescr=&amp;gt;describe_by_data( &amp;lt;gt_ps_table&amp;gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax checker allows for this, but it dumps at runtime &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 08:25:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761992#M1461829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-08T08:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating table at runtime w/o knowing the structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761993#M1461830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;besides that your posting is allmost unreadable (try preview before posting), your basic idea is correct. You just overdid it a bit.&lt;/P&gt;&lt;P&gt;Just try something like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  data: a_descr TYPE REF TO CL_ABAP_TYPEDESCR.
  FIELD-SYMBOLS: &amp;lt;val&amp;gt; type any.
     a_descr = cl_abap_datadescr=&amp;gt;describe_by_data( p_data =  st_val ).
    CREATE DATA me-&amp;gt;d_ref type (a_descr-&amp;gt;ABSOLUTE_NAME).
    assign me-&amp;gt;d_ref-&amp;gt;* to &amp;lt;val&amp;gt;.
    &amp;lt;val&amp;gt; = st_val.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this should work fine with all types of data, structures or tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jörg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 14:40:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761993#M1461830</guid>
      <dc:creator>jrg_wulf</dc:creator>
      <dc:date>2010-04-08T14:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating table at runtime w/o knowing the structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761994#M1461831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jörg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help - it actually works &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the composition of my text - I must admit that I didn't check it, as it looked ok when typing. I will keep an eye on that next time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points have been awarded - thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 15:37:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-table-at-runtime-w-o-knowing-the-structure/m-p/6761994#M1461831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-08T15:37:15Z</dc:date>
    </item>
  </channel>
</rss>

