2007 Jun 22 1:53 PM
Hi all,
i'm using class CL_GUI_ALV_GRID and i want the buttons at begin of every row to select it.
With the classic function REUSE_ALV_GRID_DISPLAY i used the layout parameter box_fieldname:
<b>layout-box_fieldname = 'CBOX'.</b>
where CBOX is the name field of my internal table in the first position (char1)
and it works.
with the CL_GUI_ALV_GRID ther's not parameter box_fieldname but BOX_FNAME.
<b>layout_alv-BOX_FNAME = 'CBOX'.</b>
When i call the method
call method grid->set_table_for_first_display
EXPORTING
is_layout = layout_alv
CHANGING
IT_FIELDCATALOG = it_fieldcat_voci
it_sort = gt_sort_grid[]
it_outtab = gt_voci[].
it doesn't work.
Somebody knows why? Do i have to do something else?
Thanks a lot?
Massimo.
2007 Jun 22 2:09 PM
Its a little different using the class, First you need to set the selection module before calling the SET_TABLE_FOR_FIRST_DISPLAY method.
data: LAYOUT TYPE LVC_S_LAYO,
LAYOUT-SEL_MODE = 'D'.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
CHANGING
IT_OUTTAB = IALV[]
IT_FIELDCATALOG = FIELDCAT[].
So this will give you the selection box in the ALV output, then you use the method GET_SELECTED_ROWS to determine what rows the user has selected.
DATA: INDEX_ROWS TYPE LVC_T_ROW,
INDEX LIKE LINE OF INDEX_ROWS.
CLEAR INDEX_ROWS. REFRESH INDEX_ROWS.
CALL METHOD ALV_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = INDEX_ROWS.
* Do something with those selected rows here
LOOP AT INDEX_ROWS INTO INDEX.
* Use the index to read the specific line of ALV which is selected
READ TABLE IALV INDEX INDEX-INDEX.
IF SY-SUBRC = 0.
* Now do what ever you need to with the selected line
ENDIF.
ENDLOOP.
Regards,
Rich Heilman
2007 Jun 22 2:09 PM
Its a little different using the class, First you need to set the selection module before calling the SET_TABLE_FOR_FIRST_DISPLAY method.
data: LAYOUT TYPE LVC_S_LAYO,
LAYOUT-SEL_MODE = 'D'.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
CHANGING
IT_OUTTAB = IALV[]
IT_FIELDCATALOG = FIELDCAT[].
So this will give you the selection box in the ALV output, then you use the method GET_SELECTED_ROWS to determine what rows the user has selected.
DATA: INDEX_ROWS TYPE LVC_T_ROW,
INDEX LIKE LINE OF INDEX_ROWS.
CLEAR INDEX_ROWS. REFRESH INDEX_ROWS.
CALL METHOD ALV_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = INDEX_ROWS.
* Do something with those selected rows here
LOOP AT INDEX_ROWS INTO INDEX.
* Use the index to read the specific line of ALV which is selected
READ TABLE IALV INDEX INDEX-INDEX.
IF SY-SUBRC = 0.
* Now do what ever you need to with the selected line
ENDIF.
ENDLOOP.
Regards,
Rich Heilman
2007 Jun 22 3:15 PM
2007 Jun 22 3:22 PM
2011 Apr 20 1:38 PM
Hi Rich,
I tried the to capture the selected row in the ALV display but INDEX_ROWS remains intial when i checked in debug.
Pls let me know why this happening.
Regards,
Naba
2024 Mar 02 8:25 AM