<?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 create dynamic nested internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526116#M1262718</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can create Nested Internal table Dynamically like Normal Internal table . &lt;/P&gt;&lt;P&gt;Give the Dataelement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate the fieldcatalog for other Fields.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: 
      lt_comptab         TYPE cl_abap_structdescr=&amp;gt;component_table,
      ls_comp            LIKE LINE OF lt_comptab,
      lref_newstr        TYPE REF TO cl_abap_structdescr,
      lref_tab_type      TYPE REF TO cl_abap_tabledescr.


LOOP AT lt_fcat INTO ls_fcat.
      IF ls_fcat-ref_table IS NOT INITIAL.
        CLEAR ls_dd03p.
        CALL FUNCTION 'BUS_DDFIELD_GET'
          EXPORTING
            i_tabnm         = ls_fcat-ref_table
            i_fldnm         = ls_fcat-fieldname
          IMPORTING
            e_dd03p         = ls_dd03p
          EXCEPTIONS
            field_not_found = 1
            OTHERS          = 2.
        IF sy-subrc EQ 0.
          ls_comp-name = ls_fcat-fieldname.
          ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_dd03p-rollname ).
          APPEND ls_comp TO lt_comptab.
          CLEAR ls_comp.
        ENDIF.
      ELSE.
        ls_comp-name = ls_fcat-fieldname.
        ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
        APPEND ls_comp TO lt_comptab.
        CLEAR ls_comp.
      ENDIF.
    ENDLOOP.

*Now for the Field which you want deep table then you can do like this
      ls_fcat-fieldname  = 'NESTED_TABLE'.
      ls_fcat-inttype    = 'C'.
      ls_fcat-intlen     = '000006'.
      ls_fcat-rollname   = 'SFLIGHT_TAB1'. "For SFLIGHT   
      APPEND ls_fcat TO lt_fcat.


    ls_comp-name = ls_fcat-fieldname.
    ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
    INSERT ls_comp INTO lt_comptab INDEX lv_count.
    CLEAR ls_comp.
    ADD 1 TO lv_count.

    lref_newstr = cl_abap_structdescr=&amp;gt;create( lt_comptab ).
    lref_tab_type = cl_abap_tabledescr=&amp;gt;create( lref_newstr ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can define your internal table using lref_tab_type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Apr 2009 10:24:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-27T10:24:26Z</dc:date>
    <item>
      <title>How to create dynamic nested internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526115#M1262717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pleae tell me or give sample code, how to create dynamic &lt;STRONG&gt;nested&lt;/STRONG&gt; internal table ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have seen threads saying creation of dynamic internal tables using some table structure only. But now the requirement is to &lt;STRONG&gt;create dynamic nested internal table&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt; For example the internal table contains two fields viz., one is field1 of dynamic internal table and other is normal field2 and values as shown below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested internal table: &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;field1                     |     field2 ...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------" /&gt;&lt;P&gt;&amp;lt;table content1&amp;gt;     |     value2..&lt;/P&gt;&lt;P&gt;&amp;lt;table content1&amp;gt;     |     value2..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the [table content] should also a dynamic internal table. &lt;/P&gt;&lt;P&gt;Let me know if you need any other info. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Saravanan R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2009 10:16:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526115#M1262717</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-27T10:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic nested internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526116#M1262718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can create Nested Internal table Dynamically like Normal Internal table . &lt;/P&gt;&lt;P&gt;Give the Dataelement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate the fieldcatalog for other Fields.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: 
      lt_comptab         TYPE cl_abap_structdescr=&amp;gt;component_table,
      ls_comp            LIKE LINE OF lt_comptab,
      lref_newstr        TYPE REF TO cl_abap_structdescr,
      lref_tab_type      TYPE REF TO cl_abap_tabledescr.


LOOP AT lt_fcat INTO ls_fcat.
      IF ls_fcat-ref_table IS NOT INITIAL.
        CLEAR ls_dd03p.
        CALL FUNCTION 'BUS_DDFIELD_GET'
          EXPORTING
            i_tabnm         = ls_fcat-ref_table
            i_fldnm         = ls_fcat-fieldname
          IMPORTING
            e_dd03p         = ls_dd03p
          EXCEPTIONS
            field_not_found = 1
            OTHERS          = 2.
        IF sy-subrc EQ 0.
          ls_comp-name = ls_fcat-fieldname.
          ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_dd03p-rollname ).
          APPEND ls_comp TO lt_comptab.
          CLEAR ls_comp.
        ENDIF.
      ELSE.
        ls_comp-name = ls_fcat-fieldname.
        ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
        APPEND ls_comp TO lt_comptab.
        CLEAR ls_comp.
      ENDIF.
    ENDLOOP.

*Now for the Field which you want deep table then you can do like this
      ls_fcat-fieldname  = 'NESTED_TABLE'.
      ls_fcat-inttype    = 'C'.
      ls_fcat-intlen     = '000006'.
      ls_fcat-rollname   = 'SFLIGHT_TAB1'. "For SFLIGHT   
      APPEND ls_fcat TO lt_fcat.


    ls_comp-name = ls_fcat-fieldname.
    ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
    INSERT ls_comp INTO lt_comptab INDEX lv_count.
    CLEAR ls_comp.
    ADD 1 TO lv_count.

    lref_newstr = cl_abap_structdescr=&amp;gt;create( lt_comptab ).
    lref_tab_type = cl_abap_tabledescr=&amp;gt;create( lref_newstr ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can define your internal table using lref_tab_type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2009 10:24:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526116#M1262718</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-27T10:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic nested internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526117#M1262719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for giving quick reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems you have given part of code from the program. But the above code does not seem to work, it gives syntax error "COMPONENT_TABLE" is unkown" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check to help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Saravanan R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 08:49:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526117#M1262719</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T08:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic nested internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526118#M1262720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;see the complete code..i am currently working in ECC6.0 EHP4. just check which version you are using..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  yst_test_000.

DATA:
      lt_comptab         TYPE cl_abap_structdescr=&amp;gt;component_table,
      ls_comp            LIKE LINE OF lt_comptab,
      lref_newstr        TYPE REF TO cl_abap_structdescr,
      lref_tab_type      TYPE REF TO cl_abap_tabledescr,
      lt_fcat            TYPE lvc_t_fcat,
      ls_fcat            TYPE lvc_s_fcat,
      ls_dd03p           TYPE dd03p,
      lt_data            type ref to data.
field-symbols: &amp;lt;fs_table&amp;gt; type standard table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
    i_structure_name       = 'SCARR'
  CHANGING
    ct_fieldcat            = lt_fcat
  EXCEPTIONS
    inconsistent_interface = 1
    program_error          = 2
    OTHERS                 = 3.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

LOOP AT lt_fcat INTO ls_fcat.
  IF ls_fcat-ref_table IS NOT INITIAL.
    CLEAR ls_dd03p.
    CALL FUNCTION 'BUS_DDFIELD_GET'
      EXPORTING
        i_tabnm         = ls_fcat-ref_table
        i_fldnm         = ls_fcat-fieldname
      IMPORTING
        e_dd03p         = ls_dd03p
      EXCEPTIONS
        field_not_found = 1
        OTHERS          = 2.
    IF sy-subrc EQ 0.
      ls_comp-name = ls_fcat-fieldname.
      ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_dd03p-rollname ).
      APPEND ls_comp TO lt_comptab.
      CLEAR ls_comp.
    ENDIF.
  ELSE.
    ls_comp-name = ls_fcat-fieldname.
    ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
    APPEND ls_comp TO lt_comptab.
    CLEAR ls_comp.
  ENDIF.
ENDLOOP.

*Now for the Field which you want deep table then you can do like this
ls_fcat-fieldname  = 'NESTED_TABLE'.
ls_fcat-inttype    = 'C'.
ls_fcat-intlen     = '000006'.
ls_fcat-rollname   = 'SFLIGHT_TAB1'. "For SFLIGHT
APPEND ls_fcat TO lt_fcat.


ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( ls_fcat-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.


lref_newstr = cl_abap_structdescr=&amp;gt;create( lt_comptab ).
lref_tab_type = cl_abap_tabledescr=&amp;gt;create( lref_newstr ).

create data lt_data type handle lref_tab_type.
assign lt_data-&amp;gt;* to &amp;lt;fs_table&amp;gt;.
 
break-point.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vijay Babu Dudla on Apr 28, 2009 8:05 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 12:04:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526118#M1262720</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T12:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic nested internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526119#M1262721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Saravanan &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may have a look at my Wiki posting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[ Creating Flat and Complex Internal Tables Dynamically using RTTI |https://wiki.sdn.sap.com/wiki/display/Snippets/Creating&lt;EM&gt;Flat&lt;/EM&gt;and&lt;EM&gt;Complex&lt;/EM&gt;Internal&lt;EM&gt;Tables&lt;/EM&gt;Dynamically&lt;EM&gt;using&lt;/EM&gt;RTTI]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 12:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-dynamic-nested-internal-table/m-p/5526119#M1262721</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-04-28T12:21:47Z</dc:date>
    </item>
  </channel>
</rss>

