‎2008 Jun 18 12:50 PM
i have a checkbox in a object oriented alv and when the box is checked need to carry out some validation what event to use in this
‎2008 Jun 18 12:57 PM
Hi..
Write a validation in screen's PAI..
Regards
Manish Hadiyel.
‎2008 Jun 18 12:58 PM
hi,
Refer to following links,
https://forums.sdn.sap.com/click.jspa?searchID=13042072&messageID=5089171
reward pts if usefull.
Regards,
dhan
‎2008 Jun 18 1:03 PM
Hello Gurpreet
Use The Method :
call method gr_alvgrid->check_changed_data.
this metho transfers all data of alv on the screen to the related internal table.
Than the value of checkbox field will be 'X' on internal table.
But if u use the line selection of alv,
you must use the method : gr_alvgrid->get_Selected_lines.
Bye
‎2008 Jun 18 1:07 PM
The validation can be done in any of the events below as per the requirement:
1. double_click
2. user_command
3. Hotspot_click
For getting the rows selected using the checkbox, you have to use the method CHECK_CHANGED_DATA in the program.
check the below link for all events and methods of grid class.
[http://help.sap.com/saphelp_47x200/helpdata/en/0a/b55321d30911d2b467006094192fe3/frameset.htm]
Regards,
Lakshmi.
‎2008 Jun 18 4:11 PM
Hi Gurpreet,
Check the below sample code.....jus copy paste and execute...
here delayed callback event is used.....
Click on the row u need to check...
*---------------------------------------------------------------------*
* CLASS event_responder DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_responder DEFINITION.
PUBLIC SECTION.
METHODS click_a FOR EVENT delayed_callback OF cl_gui_alv_grid.
ENDCLASS. "event_responder DEFINITION
TYPES BEGIN OF ty_disp.
TYPES chkbox TYPE checkbox.
INCLUDE TYPE qals.
TYPES END OF ty_disp.
DATA : container TYPE REF TO cl_gui_docking_container,
alv_grid TYPE REF TO cl_gui_alv_grid,
handler TYPE REF TO lcl_event_responder,
lt_disp TYPE TABLE OF ty_disp WITH HEADER LINE,
ls_disp TYPE ty_disp ,
lt_fldcat TYPE TABLE OF lvc_s_fcat WITH HEADER LINE,
lt_event TYPE cntl_simple_events WITH HEADER LINE,
lt_cells TYPE lvc_t_ceno WITH HEADER LINE.
PARAMETER p. " dummy
AT SELECTION-SCREEN OUTPUT.
IF container IS NOT BOUND.
CREATE OBJECT container EXPORTING side = cl_gui_docking_container=>dock_at_bottom
extension = '99999'.
CREATE OBJECT alv_grid EXPORTING i_parent = container.
PERFORM field_catalog.
SELECT * FROM qals INTO CORRESPONDING FIELDS OF TABLE lt_disp UP TO 30 ROWS.
alv_grid->set_table_for_first_display( CHANGING it_outtab = lt_disp[]
it_fieldcatalog = lt_fldcat[] ).
alv_grid->register_delayed_event( i_event_id = cl_gui_alv_grid=>mc_evt_delayed_move_curr_cell ).
CREATE OBJECT handler.
SET HANDLER handler->click_a FOR alv_grid.
ENDIF.
*&--------------------------------------------------------------------*
*& Form field_catalog
*&--------------------------------------------------------------------*
FORM field_catalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'QALS'
CHANGING
ct_fieldcat = lt_fldcat[].
lt_fldcat-fieldname = 'CHKBOX'.
lt_fldcat-checkbox = 'X'.
lt_fldcat-reptext = 'Validated'.
INSERT lt_fldcat INDEX 1.
ENDFORM. "field_catalog
*---------------------------------------------------------------------*
* CLASS event_responder IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_responder IMPLEMENTATION.
METHOD click_a.
FREE lt_cells.
alv_grid->get_selected_cells_id( IMPORTING et_cells = lt_cells[] ).
READ TABLE lt_cells INTO lt_cells INDEX 1.
LOOP AT lt_disp INTO ls_disp.
CHECK sy-tabix EQ lt_cells-row_id.
CHECK ls_disp-chkbox NE 'X'.
ls_disp-chkbox = 'X'.
MODIFY lt_disp FROM ls_disp TRANSPORTING chkbox.
MESSAGE ' Use this event to validate ' TYPE 'I'.
alv_grid->refresh_table_display( ).
ENDLOOP.
ENDMETHOD. "click
ENDCLASS. "event_responder IMPLEMENTATIONCheers,
Jose.