<?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: Duplicate internal table definition and add additional fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210842#M1982828</link>
    <description>&lt;P&gt;Hi Fred&lt;/P&gt;&lt;P&gt;you could create an internal table based on a field catalog (like ALV Grid)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING
      it_fieldcatalog = t_fldcat
    IMPORTING
      ep_table        = o_newtable.
  ASSIGN o_newtable-&amp;gt;* TO &amp;lt;t_dyntable&amp;gt;. 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Jan 2020 12:20:41 GMT</pubDate>
    <dc:creator>FredericGirod</dc:creator>
    <dc:date>2020-01-27T12:20:41Z</dc:date>
    <item>
      <title>Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210841#M1982827</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;What is the easiest way to dynamically define an internal table based on an existing internal table but add additional fields to the second table. This is to be done dynamically, not through a DATA statement.&lt;/P&gt;
  &lt;P&gt;types: begin of t_ds,&lt;BR /&gt; ds type DDOBJNAME,&lt;BR /&gt; struct type DDOBJNAME,&lt;BR /&gt; type(01) type c,&lt;BR /&gt; data type DDOBJNAME,&lt;BR /&gt; febko type febko, "DEEP STRUCTURE&lt;BR /&gt; febep type febep, "DEEP STRUCTURE&lt;BR /&gt; febre type t_febre,&lt;BR /&gt;end of t_ds .&lt;/P&gt;
  &lt;P&gt; types:&lt;BR /&gt; t_ds_tab type table of t_ds .&lt;/P&gt;
  &lt;P&gt;I want to dynamically define an internal table exactly like t_ds but with an additional field (deep):&lt;BR /&gt;bsid type bsid.&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;BR /&gt;Fred&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 12:03:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210841#M1982827</guid>
      <dc:creator>fcousin</dc:creator>
      <dc:date>2020-01-27T12:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210842#M1982828</link>
      <description>&lt;P&gt;Hi Fred&lt;/P&gt;&lt;P&gt;you could create an internal table based on a field catalog (like ALV Grid)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING
      it_fieldcatalog = t_fldcat
    IMPORTING
      ep_table        = o_newtable.
  ASSIGN o_newtable-&amp;gt;* TO &amp;lt;t_dyntable&amp;gt;. 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jan 2020 12:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210842#M1982828</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-01-27T12:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210843#M1982829</link>
      <description>&lt;P&gt;Thank you Frederic.&lt;/P&gt;&lt;P&gt;That is the road I am taking but was wondering if there was an easier way.&lt;BR /&gt;My original table is also a dynamically create table so I need to extract its definition in the field catalog and insert the new field.&lt;/P&gt;&lt;P&gt;Just cumbersome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Merci,&lt;BR /&gt;Fred&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 14:23:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210843#M1982829</guid>
      <dc:creator>fcousin</dc:creator>
      <dc:date>2020-01-27T14:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210844#M1982830</link>
      <description>&lt;P&gt;&lt;STRONG&gt;RTTS&lt;/STRONG&gt; can do this.&lt;/P&gt;&lt;P&gt;Example code (not clean and not handled exceptions!)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lo_structdescr_in  TYPE REF TO cl_abap_structdescr,
      lo_structdescr_out TYPE REF TO cl_abap_structdescr,
      lo_datadescr       TYPE REF TO cl_abap_datadescr,
      lt_components      TYPE cl_abap_structdescr=&amp;gt;component_table,
      lref_tab           TYPE REF TO data.

TYPES: BEGIN OF lty_test_s,
         t100        TYPE t100, "structure
         test_field1 TYPE string,
       END OF lty_test_s.

*--------------------------------------------------------------------*

"Get original components
lo_structdescr_in ?= cl_abap_structdescr=&amp;gt;describe_by_name( 'LTY_TEST_S' ).
lt_components = lo_structdescr_in-&amp;gt;get_components( ).

"Update components
lo_datadescr ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'BSID' ).
APPEND VALUE cl_abap_structdescr=&amp;gt;component( name = 'BSID'
                                             type = lo_datadescr ) TO lt_components.

"Create new dynamic structure and new table
lo_structdescr_out ?= cl_abap_structdescr=&amp;gt;create( p_components = lt_components ).
DATA(lo_tabdesc) = cl_abap_tabledescr=&amp;gt;create( lo_structdescr_out ).
CREATE DATA lref_tab TYPE HANDLE lo_tabdesc.
ASSIGN lref_tab-&amp;gt;* TO FIELD-SYMBOL(&amp;lt;lt_tab&amp;gt;).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jan 2020 14:31:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210844#M1982830</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2020-01-27T14:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210845#M1982831</link>
      <description>&lt;P&gt;Prefer RTTS to this non-official method which works with GENERATE SUBROUTINE POOL (limited to 36 calls in one program then runtime error).&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:04:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210845#M1982831</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-01-27T15:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210846#M1982832</link>
      <description>&lt;P&gt;Thank you Tomas,&lt;/P&gt;&lt;P&gt;It worked!&lt;BR /&gt;I had to adjust the code to the following since my original internal table (DS) was dynamically defined:&lt;/P&gt;&lt;P&gt;lo_descr ?= cl_abap_typedescr=&amp;gt;describe_by_data( DS ).&lt;BR /&gt;
lo_type = lo_descr-&amp;gt;get_table_line_type( ).&lt;BR /&gt;
lo_struct ?= cl_abap_typedescr=&amp;gt;describe_by_name( lo_type-&amp;gt;absolute_name ).&lt;BR /&gt;
lt_components = lo_struct-&amp;gt;get_components( ).&lt;/P&gt;&lt;P&gt;lo_datadescr ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'BSID' ).&lt;BR /&gt;
APPEND VALUE cl_abap_structdescr=&amp;gt;component( name = 'BSID'&lt;BR /&gt;
 type = lo_datadescr ) TO lt_components.&lt;BR /&gt;
&lt;BR /&gt;
"Create new dynamic structure and new table&lt;BR /&gt;
lo_structdescr_out ?= cl_abap_structdescr=&amp;gt;create( p_components = lt_components ).&lt;BR /&gt;
DATA(lo_tabdesc) = cl_abap_tabledescr=&amp;gt;create( lo_structdescr_out ).&lt;BR /&gt;
CREATE DATA lref_tab TYPE HANDLE lo_tabdesc.&lt;BR /&gt;
ASSIGN lref_tab-&amp;gt;* TO FIELD-SYMBOL(&amp;lt;lt_tab&amp;gt;).&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Fred&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:48:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210846#M1982832</guid>
      <dc:creator>fcousin</dc:creator>
      <dc:date>2020-01-27T15:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate internal table definition and add additional fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210847#M1982833</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;fcousin&lt;/SPAN&gt; Please do not forget to take care of exceptions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 07:37:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duplicate-internal-table-definition-and-add-additional-fields/m-p/12210847#M1982833</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2020-01-28T07:37:59Z</dc:date>
    </item>
  </channel>
</rss>

