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

ALV GRID

how to activate check box in ALV GRID.

its displaying properly in list but not in grid display.

plz help.

thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 12:17 PM

    Hi,

    Check the below code...

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = W_REPID

    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

    P_SELFLD TYPE SLIS_SELFIELD.

    DATA : L_REP_MODE. "report mode

    CASE P_UCOMM.

    Data ref1 type ref to cl_gui_alv_grid.

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

    E_GRID = ref1.

    call method ref1->check_changed_data

    WHEN 'SAVE'.

    loop at itab where check eq 'X'.

    endloop.

    ENDCASE.

    Cheers,

    Bujji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 12:19 PM

    Hi

    REPORT ZALV_DISPLAY_CHANGE.

    TABLES :T247.

    TYPE-POOLS SLIS. "Type definitions for alv report

    DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

    WA_FIELDCAT TYPE LVC_S_FCAT.

    DATA: WA_LAYOUT TYPE LVC_S_LAYO.

    DATA : BEGIN OF IT_FINAL OCCURS 0,

    CHECK(1),

    CELLTAB TYPE LVC_T_STYL, " Switch between display/change

    MNR LIKE T247-MNR,

    LTX LIKE T247-LTX,

    END OF IT_FINAL.

    DATA : WA_FINAL LIKE IT_FINAL.

    DATA : W_REPID LIKE SY-REPID.

    W_REPID = SY-REPID.

    REFRESH IT_FINAL.

    SELECT MNR LTX

    FROM T247

    INTO CORRESPONDING FIELDS OF TABLE IT_FINAL

    WHERE SPRAS EQ 'E'.

    WA_FIELDCAT-FIELDNAME = 'CHECK'.

    WA_FIELDCAT-TABNAME = 'IT_FINAL'.

    WA_FIELDCAT-CHECKBOX = 'X'.

    WA_FIELDCAT-EDIT = 'X'..

    WA_FIELDCAT-OUTPUTLEN = '3'.

    WA_FIELDCAT-COL_POS = '1'.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MNR'.

    WA_FIELDCAT-TABNAME = 'IT_FINAL'.

    WA_FIELDCAT-OUTPUTLEN = '8'.

    WA_FIELDCAT-COL_POS = '2'.

    WA_FIELDCAT-REPTEXT = 'Month'.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'LTX'.

    WA_FIELDCAT-TABNAME = 'IT_FINAL'.

    WA_FIELDCAT-OUTPUTLEN = '20'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-REPTEXT = 'Month Desc'.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    DATA: WA_CELLTAB TYPE LVC_S_STYL,

    IT_CELLTAB TYPE LVC_T_STYL,

    L_INDEX TYPE I.

    CLEAR : WA_CELLTAB,WA_FINAL,IT_CELLTAB.

    REFRESH IT_CELLTAB.

    *Initialize the celltab table

    LOOP AT IT_FINAL INTO WA_FINAL.

    L_INDEX = SY-TABIX.

    WA_CELLTAB-FIELDNAME = 'CHECK'.

    WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

    INSERT WA_CELLTAB INTO TABLE IT_CELLTAB.

    INSERT LINES OF IT_CELLTAB INTO TABLE WA_FINAL-CELLTAB.

    MODIFY IT_FINAL FROM WA_FINAL INDEX L_INDEX.

    ENDLOOP.

    *Make the first five 5 rows as disabled

    CLEAR L_INDEX.

    LOOP AT IT_FINAL INTO WA_FINAL.

    L_INDEX = SY-TABIX.

    IF SY-TABIX LE 5.

    LOOP AT WA_FINAL-CELLTAB INTO WA_CELLTAB.

    IF WA_CELLTAB-FIELDNAME EQ 'CHECK' .

    WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.

    MODIFY WA_FINAL-CELLTAB FROM WA_CELLTAB.

    MODIFY IT_FINAL INDEX L_INDEX FROM WA_FINAL TRANSPORTING CELLTAB.

    ENDIF.

    ENDLOOP.

    ENDIF.

    ENDLOOP.

    WA_LAYOUT-BOX_FNAME = 'CHECK'.

    WA_LAYOUT-NO_ROWMARK = 'X'.

    WA_LAYOUT-STYLEFNAME = 'CELLTAB'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

    EXPORTING

    I_CALLBACK_PROGRAM = W_REPID

    I_GRID_TITLE = 'GRID DISPLAY'

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    IS_LAYOUT_LVC = WA_LAYOUT

    IT_FIELDCAT_LVC = IT_FIELDCAT

    TABLES

    T_OUTTAB = IT_FINAL

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

    P_SELFLD TYPE SLIS_SELFIELD.

    Data ref1 type ref to cl_gui_alv_grid.

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

    E_GRID = ref1.

    call method ref1->check_changed_data

    CASE P_UCOMM.

    WHEN 'DELETE'.

    loop at it_final where check eq 'X'.

    count = count + 1. " Counts the no of checked records

    endloop.

    ENDCASE.

    ENDFORM.

    Please refer the links,

    radiobutton or checkbox in alv

    Check box in ALV Grid Report

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 12:20 PM

    Hi prachi,

    you have to set feld_catalog-checkbox = 'X'. for column you want to display as checkbox.

    LOOP AT lt_fieldcat ASSIGNING <ls_fc>.
        CASE <ls_fc>-fieldname.
          WHEN <your check box column name> .
            <ls_fc>-checkbox = 'X'.
           ...
        ENDCASE.
      ENDLOOP.

    Regards Bogdan

    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.