‎2008 Jan 09 1:53 PM
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?
Thank-You
‎2008 Jan 09 2:03 PM
Hello,
No problem - you have to declare the table as "Static Attribute"
Regards
Thomas
Edited by: Thomas Mader on Jan 9, 2008 3:03 PM
‎2008 Jan 09 2:03 PM
Hello,
No problem - you have to declare the table as "Static Attribute"
Regards
Thomas
Edited by: Thomas Mader on Jan 9, 2008 3:03 PM
‎2008 Jan 09 2:39 PM
Even easier
Create a dynamic table . This is then available in your entire program plus all methods in a class call
For example
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->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: <fs> type any,
<dyn_table> type standard table,
<dyn_wa>.
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->* to <fs>.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
* 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->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=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
* 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 <dyn_table>.
Now values in <dyn_table> will be available throughout your code.
If you want to transfer to a "Classical table'
then just use something like
int_table[] = <dyn_table>.
The same code will work if it's in a method.
As you are using a field symbol you shouldn't even need to pass the value as a parameterr.
Once the field symbol is assigned it's available everywhere in your code.
Just ensure you have defined the field symbol before using in a method
Cheers
jimbo.
‎2008 Jan 10 7:38 AM
Hello Jimbo,
I have tested your example now.
It is very good. Thank you.
Bye, Peter
‎2008 Jan 10 10:46 AM
Hi Tom,
Yes i think it is possible to store internal table in the Class memory.
But you faced that problem as i think when you return to the another method please clear the data which internal table already holds.
CLEAR <INTERNAL TABLE NAME>.
and then return to the another method.
Regards,
Sayak.... "if it useful to you pls reward"