<?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: Internal Table Data Created in a Class=&amp;gt;Method? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263515#M779840</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jimbo,&lt;/P&gt;&lt;P&gt;I have tested your example now.&lt;/P&gt;&lt;P&gt;It is very good. Thank you.&lt;/P&gt;&lt;P&gt;Bye, Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jan 2008 07:38:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-10T07:38:22Z</dc:date>
    <item>
      <title>Internal Table Data Created in a Class=&gt;Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263512#M779837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyway to store this Internal Table in the Class Memory? So when I return to another Method within the Class during Runtime the Internal table still holds its values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         Thank-You&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 13:53:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263512#M779837</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T13:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Data Created in a Class=&gt;Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263513#M779838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No problem - you have to declare the table as "Static Attribute" &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Mader on Jan 9, 2008 3:03 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 14:03:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263513#M779838</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T14:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Data Created in a Class=&gt;Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263514#M779839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Even easier &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a dynamic table . This is then available in your entire program plus all methods in a class call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

program zzz_simple_dynamic_table.

* Define any structure
types:  begin of s_elements,
  vbeln   type vapma-vbeln,
  posnr   type vapma-posnr,
  matnr   type vapma-matnr,
  kunnr   type vapma-kunnr,
  werks   type vapma-werks,
  vkorg   type vapma-vkorg,
  vkbur   type vapma-vkbur,
  status  type c,

end of  s_elements.

* end of your structure

data lr_rtti_struc type ref to cl_abap_structdescr .
data:
    zog                     like line of lr_rtti_struc-&amp;gt;components .
data:
  zogt                    like table of zog,
wa_it_fldcat type lvc_s_fcat,
it_fldcat type lvc_t_fcat ,
dy_line            type ref to data,
dy_table           type ref to data.


data:  dref               type ref to data.
field-symbols: &amp;lt;fs&amp;gt; type any,
   &amp;lt;dyn_table&amp;gt;    type  standard table,
   &amp;lt;dyn_wa&amp;gt;.

data grid_container1 type ref to cl_gui_custom_container .
data grid1 type ref to cl_gui_alv_grid .
data: ok_code type sy-ucomm.
data: struct_grid_lset type lvc_s_layo.

*now I want to build a field catalog
* First get your data structure into a field symbol

create data dref type s_elements.
assign dref-&amp;gt;* to &amp;lt;fs&amp;gt;.

lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

* Now get the structure details into a table.
* table zogt[] contains the structure details
* From which we can build the field catalog

zogt[]  = lr_rtti_struc-&amp;gt;components.
loop at zogt into zog.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = zog-name .
  wa_it_fldcat-datatype = zog-type_kind.
  wa_it_fldcat-inttype = zog-type_kind.
  wa_it_fldcat-intlen = zog-length.
  wa_it_fldcat-decimals = zog-decimals.
  wa_it_fldcat-coltext = zog-name.
  wa_it_fldcat-lowercase = 'X'.
  append wa_it_fldcat to it_fldcat .
endloop.
*
* You can perform any modifications / additions to your field catalog
* here such as your own column names etc.

* Now using the field catalog created above we can
* build a dynamic table
* and populate it

* First build the dynamic table
* the table will contain entries for
* our structure defined at the start of the program

call method cl_alv_table_create=&amp;gt;create_dynamic_table
       exporting
            it_fieldcatalog = it_fldcat
       importing
            ep_table = dy_table.


assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.
create data dy_line like line of &amp;lt;dyn_table&amp;gt;.
assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

* Now fill our table with data

select vbeln posnr matnr kunnr werks vkorg vkbur
       up to 200 rows
       from vapma
       into  corresponding fields of table &amp;lt;dyn_table&amp;gt;.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now values in &amp;lt;dyn_table&amp;gt; will be available throughout your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to transfer to a "Classical table'&lt;/P&gt;&lt;P&gt;then just use something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int_table[] = &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same code will work if it's in a method. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you are using a field symbol you shouldn't even need to pass the value as a parameterr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once the field symbol is assigned it's available everywhere in your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just ensure you have defined the field symbol before using in a method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;jimbo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 14:39:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263514#M779839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T14:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Data Created in a Class=&gt;Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263515#M779840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jimbo,&lt;/P&gt;&lt;P&gt;I have tested your example now.&lt;/P&gt;&lt;P&gt;It is very good. Thank you.&lt;/P&gt;&lt;P&gt;Bye, Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 07:38:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263515#M779840</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T07:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Data Created in a Class=&gt;Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263516#M779841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes i think it is possible to store internal table in the Class memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you faced that problem as i think when you return to the another method please clear the data which internal table already holds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR &amp;lt;INTERNAL TABLE NAME&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then return to the another method.&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;Sayak....                                                                               "if it useful to you pls reward"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 10:46:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-data-created-in-a-class-gt-method/m-p/3263516#M779841</guid>
      <dc:creator>RoySayak</dc:creator>
      <dc:date>2008-01-10T10:46:54Z</dc:date>
    </item>
  </channel>
</rss>

