Skip to Content
author's profile photo Former Member
Former Member

Help required in object oriented alv

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:57 AM

    Hi..

    Write a validation in screen's PAI..

    Regards

    Manish Hadiyel.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:58 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 12: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03: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 IMPLEMENTATION

    Cheers,

    Jose.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.