Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

cl_gui_alv_grid:exporting protected table data MT_OUTTAB to local int.table

andrea_galluccio2
Contributor
0 Kudos

Hi guys,

this is my problem.

I've an instance of cl_gui_alv_grid in the reference variable gos_alv. This instance

is populated by "sap GOS service".

Now, i'd like to save locally the internal data table of the gos_alv (populated

automatically by the service call).

The data tables is called "mt_outtab" and is a standard protected component of the cl_gui_alv_grid class

(you can see it in the se24 transaction).

I think to create a subclass of the cl_gui_lav_grid and make a public method to

save data like this :


field-symbols: <outtab> type standard table.

*---------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class lcl_gui_alv_grid definition inheriting from cl_gui_alv_grid.
  public section.
    methods : get_tab_line.
endclass.                    "lcl_gui_alv_grid DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class lcl_gui_alv_grid implementation.
  method get_tab_line.
* mt_outtab is the data table held as a protected attribute
* in class cl_gui_alv_grid.
    assign me->mt_outtab->* to <outtab>. "Original data
  endmethod.                    "get_tab_line
endclass.                    "lcl_gui_alv_grid IMPLEMENTATION

data : l_alv type ref to lcl_gui_alv_grid.

But when i do a downcast like this :


l_alv ?= gos_alv.

I have an exception of casting error. SO, how i can extract protected data into

local internal table?

I've already try to debug the service that build the alv list to understand how the data table

is populated but it's too complex.

Thank you

Andrea

3 REPLIES 3

andrea_galluccio2
Contributor
0 Kudos

Hi,

not yet any suggestion?

Generally speaking, i cannot understand why i cannot use down-cast with an instance declared as a subclass of a super-class.

Many examples, shows that i can create a sub-class inheriting from a super-class, add methods and attributes, make something like this : subclass ?= superclass and the call method of the subclass.

But when i try to do the same with a class derived from cl_gui_alv_grid, i have always a casting type exception in the down-cast instruction.

Could you explain me why?

Thank you very much

Andrea

0 Kudos

Solved on another forum section (OO Programming).

I close this thread.

Andrea

former_member826996
Discoverer
0 Kudos

DATA: l_o_grid TYPE REF TO cl_gui_alv_grid.
DATA: l_o_facade_grid TYPE REF TO cl_salv_gui_grid_facade.
DATA: l_t_detail_report TYPE zfoca_t_alv_mrr_detail.
DATA: l_s_itab TYPE zfoca_s_alv_mrr_detail. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_o_grid.

CREATE OBJECT l_o_facade_grid
EXPORTING
o_grid = l_o_grid.

DATA l_t_data TYPE REF TO data.
FIELD-SYMBOLS: <l_t_data> TYPE zfoca_t_alv_mrr_detail.
CREATE DATA l_t_data TYPE zfoca_t_alv_mrr_detail.
l_t_data = l_o_facade_grid->if_salv_gui_grid_data_source~get_r_appl_data( ).
ASSIGN l_t_data->* TO <l_t_data>.
IF <l_t_data> IS ASSIGNED.
l_t_detail_report[] = <l_t_data>.

ENDIF.