‎2013 Oct 01 6:06 AM
Hi All,
Please let me know can we use cl_gui_alv_grid class without creating container for it.
Regards,
Deepak kansal.
‎2013 Oct 01 6:11 AM
Hello,
Yes we can use CL_GUI_ALV_GRID without container provide you have used Fullscreen
Example
DATA: goobj_grid type ref to cl_gui_alv_grid.
"Set the daefault screen which will be full size.
CREATE OBJECT gobj_grid
EXPORTING
i_parent = cl_gui_custom_container=>default_screen.
Call method gonj_grid->set_table_for_first_display
exporting
i_structure_name = ' ' "=> Pass he strcture here
changing
it_outtab = gt_table "=> Pass he strcture here
exceptions
others = 4.
Thanks,
Pramod
Message was edited by: Pramod Kumar Upadhyay
‎2013 Oct 01 6:57 AM
‎2013 Oct 01 6:14 AM
‎2013 Oct 01 6:37 AM
Hi,
Try the below code.
Replace GT_ALV with the name of your internal table
DATA : L_ALV TYPE REF TO CL_SALV_TABLE,
L_DISPLAY TYPE REF TO CL_SALV_DISPLAY_SETTINGS,
L_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
L_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS,
L_LAYOUT TYPE REF TO CL_SALV_LAYOUT,
L_COLUMN TYPE REF TO CL_SALV_COLUMN_TABLE.
DATA : LS_COLUMN TYPE SALV_S_COLUMN_REF,
LS_KEY TYPE SALV_S_LAYOUT_KEY.
DATA : LT_COLUMN TYPE SALV_T_COLUMN_REF.
DATA : LV_VALUE TYPE SCRTEXT_L.
* DISPLAY ALV
TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = L_ALV
CHANGING
T_TABLE = GT_ALV.
CATCH CX_SALV_MSG .
ENDTRY.
L_DISPLAY = L_ALV->GET_DISPLAY_SETTINGS( ).
L_DISPLAY->SET_STRIPED_PATTERN( CL_SALV_DISPLAY_SETTINGS=>TRUE ).
L_COLUMNS = L_ALV->GET_COLUMNS( ).
L_COLUMNS->SET_OPTIMIZE( 'X' ).
LT_COLUMN = L_COLUMNS->GET( ). "TO GET SINGLE COL NAME IN LT_COLUMN
L_LAYOUT = L_ALV->GET_LAYOUT( ).
LS_KEY-REPORT = SY-REPID.
L_LAYOUT->SET_KEY( LS_KEY ).
L_LAYOUT->SET_SAVE_RESTRICTION( IF_SALV_C_LAYOUT=>RESTRICT_NONE ).
L_FUNCTIONS = L_ALV->GET_FUNCTIONS( ).
L_FUNCTIONS->SET_ALL( ABAP_TRUE ).
L_ALV->DISPLAY( ).
‎2013 Oct 01 6:56 AM
Hi deepak,
yes we can create a alv without the container .
You can use se80 -> SLIS package -> Programs , u will find many programs there
we can use cl_gui_custom_container=>screen0 or cl_gui_custom_container=> default_screen just as below .
data lo_grid type ref to cl_gui_alv_grid.
CREATE OBJECT lo_grid
EXPORTING
i_parent = cl_gui_custom_container=>screen 0. " instead fo creating custom container u can use standard screens
lo_grid->set_table_for_first_display( .... ).
Regards,
Sivaganesh
‎2013 Oct 01 7:03 AM
Hi Deepak,
Go through this link https://scn.sap.com/thread/2122042
‎2013 Oct 01 7:55 AM
Hi Deepak,
Instead of below code
CREATE OBJECT gobj_grid
EXPORTING
i_parent = cl_gui_custom_container=>default_screen.
Use CREATE OBJECT gobj_grid
EXPORTING
i_parent = cl_gui_custom_container=>screen0.
it will also work.
Thanks,
Satya.
‎2013 Oct 01 8:35 AM
Hi Deepak,
Code is as below:
WRITE: /n Text-001. "Text-001 will contain blank value.
DATA: gr_grid type ref to cl_gui_alv_grid.
Call method gr_grid->set_table_for_first_display
exporting
i_structure_name = ' ' "=> Pass he strcture here
changing
it_outtab = gt_table "=> Pass he strcture here
exceptions
others = 4.
BR,
Debopriya Ghosh
‎2013 Oct 01 8:47 AM
What is your exact question : executing this class with initial/no container or using an implicit container like current screen, or a docking container attached to current screen ?
Nevertheless the answer is yes, we do it usually during background process, only creating container when online using a parent container in a dynpro and not creating when in background (cl_gui_alv_grid=>offline returned true) in second case the class will generate a spool list (using good old REUSE FM)
Regards,
Raymond
‎2013 Oct 01 8:55 AM
Hi
why you dont want to create the custom container?
İs there a specific reason?
you can attach to a dockıng contaıner too
‎2013 Oct 01 9:29 AM
Hii deepak,
We can use cl_gui_alv_grid without using custom container.
While creating object of cl_gui_alv_grid like below,
data obj_grid type ref to cl_gui_alv_grid.
start-of-selection.
IF obj_grid IS INITIAL.
CREATE OBJECT obj_grid
EXPORTING
i_parent = cl_gui_custom_container=>default_screen
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
then call method
IF NOT <internal_table> IS INITIAL.
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
i_structure_name = ur structure name
is_layout = lx_layout
CHANGING
it_outtab = it_trans "output internal table want to display in grid
* it_fieldcatalog = lt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* STOP.
ENDIF.
ENDIF.
regards
Syed