‎2005 Dec 09 4:01 PM
Hello. I want an object that can hold a private reference
to a global internal table so that when one of it's methods are invoked, the global table contents are modified.
Simplification of scenario:
class myObject definition.
*
public section.
*
methods:
set_global_table
importing reference(i_table) type standard table,
*
change_global_table.
*
private section.
*
data:
m_pointer_to_table " not sure how to type this"
*
endclass.
*
class myObject implementation.
*
method set_global_table.
*
m_pointer_to_table = i_table. " this needs to "
" assign a pointer to "
" the global variable "
*
endmethod.
*
*
method change_global_table.
*
refresh m_pointer_to_table. "this should change "
"the contents of global "
"variable "
endmethod.
*
endclass.
*
*
data: gt_itable type standard table of t_widget,
go_myobject type ref to myobject.
*
* Main code
*
create object go_myobject.
*
*
*
* phantom code fills gt_itable
*
*
call method go_myobject->set_global_table
exporting i_table = gt_itable.
*
call method go_myobject->change_global_table.
*
*
if gt_itable is initial.
*
write 'this should output'.
*
endif.The code here doesn't work and I've tried messing with field-symbols, etc. all to no avail. Thank you for any help you could provide!
Brett
‎2005 Dec 09 4:07 PM
Hi,
One small question. Is this pointer to global table always pointing to same internal table or differnt tables depending on the situation in runtime.
Regards,
Ramesh
‎2005 Dec 09 4:23 PM
Hi Ramesh,
There's a global table that stores the data for an ALV grid control.
I have an object that holds the event handler for a tree control. When a person double clicks on a node, I want to query a db and reset the grid data within the event handler.
Since there's no way to pass in the global table on the event handler method, the object I've defined needs to have a reference to it already in the form of a class/private variable.
Hope this helps clarify!
Thanks,
Brett
‎2005 Dec 09 5:23 PM
‎2005 Dec 09 5:34 PM
Rich,
That's definitely an option. I was just hoping to find a way within the OO context.
I'm going to settle with your suggestion.
Thanks!
Brett
‎2005 Dec 09 5:39 PM
‎2005 Dec 10 9:56 PM
Just typed in this editor - so no syntax-check but you will get the idea:
Pass the internal table and get the reference of it
Store the reference and manipulate the global contents with local field-symbols to which you have assigned the reference.
Hope this helps
Christian
>
> class myObject definition.
> *
> public section.
> *
> methods:
> set_global_table
> importing reference(i_table) type standard
> standard table,
> *
> change_global_table.
> *
> private section.
> *
> data:
> m_pointer_to_table type ref to data
> *
> endclass.
> *
> class myObject implementation.
> *
> method set_global_table.
> *
GET REFERENCE of i_table into m_pointer_to_table.
> endmethod.
> *
> *
> method change_global_table.
> *
field-symbols: <lit_table> type any table.
assign m_pointer_to_table to <lit_table>.
* manipulate <lit_table>
> endmethod.
> *
> endclass.
> *
> *
> data: gt_itable type standard table of t_widget,
> go_myobject type ref to myobject.
> *
> * Main code
> *
> create object go_myobject.
> *
> *
> *
> * phantom code fills gt_itable
> *
> *
> call method go_myobject->set_global_table
> exporting i_table = gt_itable.
> *
> call method go_myobject->change_global_table.
> *
> *
> if gt_itable is initial.
> *
> write 'this should output'.
> *
> endif.>
>
> The code here doesn't work and I've tried messing
> with field-symbols, etc. all to no avail. Thank you
> for any help you could provide!
>
> Brett