11-27-2008 12:51 PM
Hi All,
i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command.
i have given the below code also in fieldcatolg.
f_fldcat-fieldname = 'checkbox'.
f_fldcat-tabname ='gi_output'
f_fldcat-checkbox = 'X'.
f_fldcat-edit = 'X'.
but the checkbox is not getting set in internal table when i select some checkboxes.
can anybody explain y the checkbox in internal table not getting set?
Thanks,
Srilakshmi.
11-27-2008 1:48 PM
Hi Sreelakshmi,
I hope you know how to write CLICK event. if yes , in that event please use this statement. It will automatically update your internal table.
CALL METHOD LP_ALV_GRID->CHECK_CHANGED_DATA.
If helpful, apprise me.
Regards
Satish
11-27-2008 1:00 PM
hi,
use the method Get_selected_row of this class
before using plz set the sel_mode of layout as 'A', 'C' or 'D'....
Call this method as follows:
data: gi_itab type lvc_t_row.
call method <ref variable of cl_gui_alv_grid>->get_selected_row
importing
et_index_rows = gi_itab.
this table will have the indexes of the selected rows.
hope this solves your problem...
regards,
ags.
11-27-2008 1:02 PM
11-27-2008 1:07 PM
Hi,
i tried already whatever u said, but still not resolved.Pasted my code below..can u please look into it.
MODULE pbo OUTPUT.
PERFORM init_container.
PERFORM prepare_field_catalog.
PERFORM prepare_layout.
PERFORM display_output.
ENDMODULE. " PBO OUTPUT
&----
*& Module PAI INPUT
&----
text
----
MODULE pai INPUT.
DATA: lt_rows TYPE lvc_t_row.
CASE gv_okcode.
WHEN gc_exit OR gc_back OR gc_canc. " Finish program
LEAVE PROGRAM.
when 'PRINT'.
CALL METHOD gv_grid->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
ENDCASE.
ENDMODULE. " PAI INPUT
&----
*& Form INIT_CONTAINER
&----
text
----
FORM init_container .
CREATE OBJECT gv_custom_container
EXPORTING
container_name = gc_container.
CREATE OBJECT gv_grid
EXPORTING
i_parent = gv_custom_container.
CREATE OBJECT gv_document
EXPORTING
style = 'ALV_GRID'.
&----
*& Form PREPARE_FIELD_CATALOG
&----
text
----
FORM prepare_field_catalog .
PERFORM fill_catalog USING:
'Table Name' 'Field Name' 'NoZero' 'sel-text'
'GI_OUTPUT' 'CHECKBOX' ' ' text-013 'X',
'GI_OUTPUT' 'KUNNR' 'X' text-003 ' ',
'GI_OUTPUT' 'NAME1' ' ' text-004 ' ',
'GI_OUTPUT' 'BELNR' 'X' text-005 ' ',
'GI_OUTPUT' 'BLART' ' ' text-006 ' ',
'GI_OUTPUT' 'BUDAT' ' ' text-007 ' ',
'GI_OUTPUT' 'BLDAT' ' ' text-008 ' ',
'GI_OUTPUT' 'DMBTR' ' ' text-009 ' ',
'GI_OUTPUT' 'WAERS' ' ' text-010 ' '.
ENDFORM. " PREPARE_FIELD_CATALOG
&----
*& Form FILL_CATALOG
&----
text
----
FORM fill_catalog USING fv_tabname
fv_fldname
fv_nozero
fv_seltxt
fv_checkbox.
DATA f_fldcat TYPE lvc_s_fcat.
f_fldcat-fieldname = fv_fldname.
f_fldcat-tabname = fv_tabname.
f_fldcat-no_zero = fv_nozero.
f_fldcat-coltext = fv_seltxt.
f_fldcat-checkbox = fv_checkbox.
IF fv_checkbox = gc_x.
f_fldcat-edit = gc_x.
ENDIF.
APPEND f_fldcat TO gi_fieldcat.
ENDFORM. " FILL_CATALOG
&----
*& Form PREPARE_LAYOUT
&----
text
----
FORM prepare_layout .
gs_layout-info_fname = 'COL'.
gs_layout-cwidth_opt = gc_x.
gs_layout-zebra = gc_x.
gs_layout-no_toolbar = gc_x.
gs_layout-no_rowmark = '1'.
gs_layout-sel_mode = 'A'.
ENDFORM. " PREPARE_LAYOUT
&----
*& Form DISPLAY_OUTPUT
&----
text
----
FORM display_output .
CALL METHOD gv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gi_output
it_fieldcatalog = gi_fieldcat.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR gv_grid.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = gv_grid.
ENDFORM. " DISPLAY_OUTPUT
11-27-2008 1:12 PM
Hi,
Please use the foloowing Code:
data lo_grid type ref to cl_gui_alv_grid.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = lo_grid.
call method lo_grid->check_changed_data.
This will capture when u click the 'Standard' SAVE button.
Simple way is----
case sy-ucomm.
when 'CLICK'. 'When checkboxselected and click to any Application Toolbar which u have
suppose in the application toolbar u have click button,
loop at it_final into is_final where select = 'X'.
endloop.
endcase.
Its will work.
Enjoy
arbind
11-27-2008 1:31 PM
Hi arbind,
as per my requirement i should not press the save button after i select some rows so i cant use ur first logic. second logic will work in resue_alv but not in oops alv.
11-27-2008 1:48 PM
Hi Sreelakshmi,
I hope you know how to write CLICK event. if yes , in that event please use this statement. It will automatically update your internal table.
CALL METHOD LP_ALV_GRID->CHECK_CHANGED_DATA.
If helpful, apprise me.
Regards
Satish
11-27-2008 2:57 PM
Hi Satish,
Thanks a lot for ur reply. my problem is solved.
Thanks,
Srilakshmi.