Skip to Content
avatar image
Former Member

How to provide checkboxes for particular records in alv ?

Hi experts ,

  Can i know how to provide checkboxes for particular records in alv.I am using  reuse_alv_grid_display??

for example:

      name    city

1   mike    abc

2   harry    xyz

3    bob    

So i need only checkbox for 3rd record i.e if city is initial?  can you please suggest me how to achieve it?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 31, 2015 at 04:28 AM

    Hi experts,

    The issue is solved .Slight modification with ROBERT'S code.

    TYPES: BEGIN OF ty_final_1,

            chk(1),

           HANDLE_STYLE TYPE LVC_T_STYL,

            soldto TYPE bu_partner,

            shipto TYPE bu_partner,

            report TYPE zserino,

            soldnm TYPE char40,

            shipnm TYPE char40,

            END OF ty_final_1.

    DATA: wa_final1 TYPE ty_final_1,

           it_final1 type table of ty_final_1.

      DATA: wa_celltab TYPE lvc_s_styl,

           ta_celltab TYPE lvc_t_styl.

      DATA:H_TABIX TYPE SY-TABIX.

    DATA:wa_LAYOUT TYPE LVC_S_LAYO.

        REFRESH ta_celltab.

       loop at it_final1 into WA_FINAL1.

         H_TABIX = SY-TABIX.

       IF wa_FINAL1-REPORT IS INITIAL.

         wa_celltab-fieldname = 'CHK'.

         wa_celltab-style = cl_gui_alv_grid=>mc_style_enabled.

       ELSE.

         wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.

      ENDIF.

       INSERT wa_celltab INTO TABLE TA_CELLTAB.

    INSERT LINES OF Ta_celltab INTO TABLE wa_final1-HANDLE_STYLE.

         MODIFY IT_FINAL1 INDEX h_tabix FROM wa_final1  TRANSPORTING

                                           HANDLE_STYLE.

         wa_layout-STYLEFNAME = 'HANDLE_STYLE'.

    clear:wa_final1.


    Warm Regards,

    Ramesh Moka

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 29, 2015 at 12:01 PM

    Hi.

    For OO oriented:

    You should include a field called cellstyles in output table as below:

    TYPES: BEGIN OF my_type.

                        include your_structure.

    * For cell editing

    TYPES:        cellstyles TYPE lvc_t_styl,

                 END OF my_type.

    DATA: w_style TYPE lvc_s_styl.

    Set the layout stylefname:

    w_layout-stylefname = 'CELLSTYLES'.

    When you'll have your data.

    LOOP AT gt_outtab. "Your tab

    w_style-fieldname = "ZCHECKBOX". "<= your checkbox fieldname

    w_style-style = cl_gui_alv_grid=>mc_style_enabled. "<= if you need or mc_style_disabled.

    INSERT w_style INTO TABLE gt_outtab-cellstyles. "->You'll need to modify your tab

      MODIFY gt_outtab.

    ENDLOOP.

    For reuse_alv.. :

    While populating field_catalague for particular field, just pass fieldcat-edit = 'X' this will set column in editable mode.

    Hope to help

    Bye

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 29, 2015 at 12:03 PM

    Hello Ramesh,

    In my opinion, you cannot achieve above requirement directly.

    Reasons -

    1. You cannot have a specific column for some records and not for some others.

    2. Based on data values(like city as null) you cannot dynamically control the column behavior.

    My suggestion is to split the data in two separate tables and show accordingly, one with a checkbox(char 1 type column) and other without.

    Let's wait for the reply from other gurus.

    BR.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 29, 2015 at 12:05 PM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded