‎2009 Mar 16 6:26 AM
Hi All,
I have a report which display's the output in ALV grid. i also have checkbox to all the rows.
my requirement is that if i check any checkbox of a particular row, i should be able to take that data in intenal table.
how to achieve this?
‎2009 Mar 16 6:30 AM
Hi,
You need to write the following code in the User-Command routine :
DATA: GD_REPID LIKE SY-REPID,
REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C.
*Code to reflect the changes done in the internal table
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
ENDIF.
LOOP AT IT_MAT WHERE CHK = 'X'.
"Process your logic here
ENDLOOP.
Thanks & Regards,
Rock.
‎2009 Mar 16 6:30 AM
Hi,
You need to write the following code in the User-Command routine :
DATA: GD_REPID LIKE SY-REPID,
REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C.
*Code to reflect the changes done in the internal table
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
ENDIF.
LOOP AT IT_MAT WHERE CHK = 'X'.
"Process your logic here
ENDLOOP.
Thanks & Regards,
Rock.
‎2009 Mar 16 6:35 AM
A little search could solve you problem more quickly.
refer>
‎2009 Mar 16 6:36 AM
Hi,
Refer this wiki code by me on ALV Grid Display with checkbox to process selected records at runtime
It will definitely help you.
Regards,
Tarun
‎2009 Mar 16 6:36 AM
Hi Poonam,
* to reflect the data changed into internal table try doing like this:
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
Hope it helps
Regrds
Mansi
‎2009 Mar 16 7:07 AM
The below mention process is to
1)First keep a checkbox in your ALV display so that you can mark the row that you wan to delete.
to do so what you have to do is keep a field like below in your final ITAB that you want to ALVdisplay.
BEGIN OF T_final ,
chk(1) TYPE c, for making checkbox..
............
..............
END OF T_final.
2) Then when you create the field catalog for the checkbox(chk field of your ITAB)
write down the following code
WA_fieldcat-fieldname = 'CHK'.
WA_fieldcat-seltext_m = 'CheckBox'.
WA_fieldcat-checkbox = 'X'.
WA_fieldcat-edit = 'X' .
WA_fieldcat-input = 'X'.
WA_fieldcat-tabname = 'IT_FINAL'.
WA_fieldcat-col_pos = 1.
APPEND WA_fieldcat TO IT_fieldcat.
CLEAR WA_fieldcat.
3) Declare a data at your data section of the report
DATA : lc_s_glay TYPE lvc_s_glay.
then before calling REUSE_ALV_GRID_DISPLAY
just write down the following piece of code
lc_s_glay-edt_cll_cb = 'X'.
In the REUSE_ALV_GRID_DISPLAY FM
you must set the follwing 2 Exporting Parameter
i) i_callback_user_command = 'USER_COMMAND'
ii) i_grid_settings = lc_s_glay
for i) write down the following subroutine........
FORM user_command USING I_r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: l_out_string TYPE string,
l_out_final TYPE ekpo-menge,
l_cntr TYPE i.
CASE I_r_ucomm.
WHEN 'SEL1'. assuming your Fcode
loop at itab into wa_itab where chk = 'X'.
append wa_itab to itab2.
ENDCASE.
ENDFORM.
hope it solve your problem.
Edited by: Sarbajit Majumdar on Mar 16, 2009 12:37 PM