‎2008 Nov 21 6:47 AM
Hello all,
I'm totally new to OOP so I hope anyone can help me.
I'm using the code below for displaying a layout entered on de selection screen.
*Data declaration
Data: gr_variant TYPE REF TO cl_gui_alv_grid,
gs_variant type disvariant.
*Set layout functions ALV
gr_variant = gr_table->get_variant( ).
gr_variant->get_variant( gs_variant ).
gr_variant->SAVE_VARIANT( save ).
When I'm trying to activate the program it tells me that "get_variant" doesn't exists....
When I double click on "cl_gui_alv_grid" I can find method "Get_variant".
Whats wrong?
knd rgds,
Patrick
‎2008 Nov 21 7:41 AM
hi,
Please check the attached code:
DATA:alv_grid TYPE REF TO
cl_gui_alv_grid.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = G_CUS_CONTAINER.
MOVE GS_VARIANT TO LS_VARIANT.
CALL METHOD ALV_GRID->GET_VARIANT
IMPORTING
ES_VARIANT = LS_VARIANT
E_SAVE =
‎2008 Nov 21 6:54 AM
Hello Pat,
I think you missed this stmt:
CREATE OBJECT gr_variant.
Plz try this & hope this will help.
BR,
Suhas
‎2008 Nov 21 7:00 AM
Hello Suhas,
Thx for the quick reply.
I'm changing an existing program and for other ALV settings they didn't use "Create object". See below code:
*&- ALV grid data definition
DATA: gr_table TYPE REF TO cl_salv_table,
gr_functions TYPE REF TO cl_salv_functions,
gr_display TYPE REF TO cl_salv_display_settings,
gs_layout TYPE salv_s_layout_key,
gr_layout TYPE REF TO cl_salv_layout.
----
IF NOT gt_sbr IS INITIAL.
cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
CHANGING t_table = gt_sbr ).
Set ALV functions
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
Set display functions ALV
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( lv_header_text ).
Set layout functions ALV
gr_layout = gr_table->get_layout( ).
gs_layout-report = sy-repid.
gr_layout->set_key( gs_layout ).
gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
*&- Output ALV
gr_table->display( ).
ELSE.
MESSAGE text-t01 TYPE 'I'.
ENDIF.
‎2008 Nov 21 7:11 AM
Hello Pat,
If you see the stmt
cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
CHANGING t_table = gt_sbr ).
The method FACTORY of the class CL_SALV_TABLE is used to "Get New Instance for ALV Table Object".
Inside this method there is a stmt
create object r_salv_table
exporting
display_object = l_display_object
r_container = r_container
container_name = container_name.
So the methos FACTORY creates an instance of CL_SALV_TABLE. But for CL_GUI_ALV_GRID you have to do this in the code.
Hope this helps.
BR,
Suhas
‎2008 Nov 21 7:41 AM
hi,
Please check the attached code:
DATA:alv_grid TYPE REF TO
cl_gui_alv_grid.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = G_CUS_CONTAINER.
MOVE GS_VARIANT TO LS_VARIANT.
CALL METHOD ALV_GRID->GET_VARIANT
IMPORTING
ES_VARIANT = LS_VARIANT
E_SAVE =
‎2008 Nov 21 7:52 AM
Ok, as said before I'm totally new to OOP so what is G_CUS_CONTAINER?
LS_VARIANT is the same as GS_VARIANT?
‎2008 Dec 10 12:28 PM