Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Checkbox in ALV rows

Former Member
0 Likes
814

Hi Experts,

I have 10 rows in my ALV output. Among those rows, one row I want to have checkbox for all the fields.

How can I do it at row level. Once I check the checkbox, some activity is to happen. How can I do that?

Kindly help me...

Regards,

Venkat

Hi Experts,

I have 10 rows in my ALV output. Among those rows, one row I want to have checkbox for all the fields.

How can I do it at row level. Once I check the checkbox, some activity is to happen. How can I do that?

Kindly help me...

Regards,

Venkat

4 REPLIES 4
Read only

Former Member
0 Likes
755

BCALV_EDIT_05

Read only

Former Member
0 Likes
755

hi,

sample code

TABLES : SFLIGHT,SCARR,SPFLI.

TYPES : BEGIN OF STR_SFLIGHT,

        CARRID TYPE SFLIGHT-CARRID,
        CONNID TYPE SFLIGHT-CONNID,
        FLDATE TYPE SFLIGHT-FLDATE,
        CHECK TYPE C,
        END OF STR_SFLIGHT.

TYPES : BEGIN OF STR1_SFLIGHT,
        CARRID TYPE SFLIGHT-CARRID,
        CONNID TYPE SFLIGHT-CONNID,
        FLDATE TYPE SFLIGHT-FLDATE,
        END OF STR1_SFLIGHT.


        DATA: COUNT TYPE I,
              V_INDEX TYPE I.

DATA : IT_SFLIGHT TYPE STANDARD TABLE OF STR_SFLIGHT WITH HEADER LINE,
      IT_SFLIGHT1 TYPE STANDARD TABLE OF STR1_SFLIGHT WITH HEADER LINE..


DATA: IT_SCARR LIKE TABLE OF SCARR WITH HEADER LINE,
      IT_SPFLI LIKE TABLE OF SPFLI WITH HEADER LINE,
      IT_SBOOK LIKE TABLE OF SBOOK WITH HEADER LINE.

START-OF-SELECTION.
  PERFORM SET_PFSTATUS.
  PERFORM GET_DATA.
  PERFORM SHOW_DATA.

AT USER-COMMAND.
  PERFORM HANDEL_INPUT.

FORM GET_DATA .

  SELECT CARRID
         CONNID
         FLDATE
         FROM SFLIGHT
         INTO TABLE IT_SFLIGHT.
ENDFORM.                    " GET_DATA

FORM SHOW_DATA .

  LOOP AT IT_SFLIGHT.

    WRITE : / IT_SFLIGHT-CHECK AS CHECKBOX,IT_SFLIGHT-CARRID.", IT_SFLIGHT-CONNID,IT_SFLIGHT-FLDATE.

    ENDLOOP.

ENDFORM.                    " SHOW_DATA


FORM SET_PFSTATUS .

  SET PF-STATUS  '  '.   " PF status

ENDFORM.                    " SET_PFSTATUS


FORM HANDEL_INPUT .

  case SY-UCOMM.

    WHEN 'PUSH'.  " handel the push button created in pf status

      DESCRIBE TABLE IT_SFLIGHT LINES COUNT.

      DO COUNT TIMES.

        V_INDEX = SY-INDEX + 2.

        READ LINE V_INDEX FIELD VALUE IT_SFLIGHT-CHECK.

        IF IT_SFLIGHT-CHECK = 'X'.

         READ TABLE IT_SFLIGHT INDEX SY-INDEX.

          IT_SFLIGHT1-CARRID =  IT_SFLIGHT-CARRID.
          IT_SFLIGHT1-CONNID =  IT_SFLIGHT-CONNID.
          IT_SFLIGHT1-FLDATE =  IT_SFLIGHT-CONNID.

          APPEND IT_SFLIGHT1.
          CLEAR IT_SFLIGHT1.

         ENDIF.

        ENDDO.

        SY-LSIND = 1.

        LOOP AT IT_SFLIGHT1.

             WRITE : /  IT_SFLIGHT1-CARRID,IT_SFLIGHT1-CONNID,IT_SFLIGHT1-FLDATE.
              CLEAR IT_SFLIGHT1.
         ENDLOOP.

        REFRESH IT_SFLIGHT1.
    ENDCASE.
ENDFORM.

Read only

anup_deshmukh4
Active Contributor
0 Likes
755

hello vankar raman....!

hope the Internal table field is of type C lenght 1

you just have to mark 'X' to the CHECKBOX field in the fieldcatlogue thats it...!

Enjoy...!

for the activity...!

just write the 'CALLBACK_USERROUTING'

in your main program and pass the routine name to the alv display function say REUSE_ALV_GRID_DISPLAY (CHECK THE PASSING PARAMETERS...!)

in the routine you will get the changed values of the itab from the alv table like if a checbox was clicked you will get a X or space if its unchecked

Edited by: Anup Deshmukh on Jan 28, 2010 6:03 AM

Read only

Former Member
0 Likes
755

Hi,

Declare a character field in your internal table.

eg: check type c,

in the field catalog give the values like


wa_fieldcat-col_pos = 1.
 wa_fieldcat-fieldname = 'CHECK'.
 wa_fieldcat-seltext_m = 'Select'.
 wa_fieldcat-checkbox = 'X'.
 wa_fieldcat-edit = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR  wa_fieldcat.

In user commnad,


FORM user_command USING
     r_ucomm LIKE sy-ucomm
     rs_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN '&DATA_SAVE'. "Here do when save button is clicked
   LOOP AT itab INTO wa_tab. "Table which you have displayed
     IF wa_tab-check EQ 'X'.
       "Do your operations
    ENDIF.
  ENDLOOP.
 ENDCASE.
 

Hope this helps you.

Regards

Ritesh