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

check box in ALV report

dear all,

In my ALV report, after selecting checkbox i want to perform some process based on selected checkbox.

how to pass value 'X' when selecting checkbox in ALV Grid display.

thanks in advance.

regards,

venthan.g

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Aug 24, 2009 at 04:27 AM
    REPORT  YMS_CHECKBOXOOPSALV NO STANDARD PAGE HEADING.
    
    TYPE-POOLS: slis.
    
    DATA: BEGIN OF i_data OCCURS 0,
    qmnum LIKE qmel-qmnum,
    qmart LIKE qmel-qmart,
    qmtxt LIKE qmel-qmtxt,
    ws_row TYPE i,
    ws_char(5) TYPE c,
    chk,
    END OF i_data.
    
    DATA: report_id LIKE sy-repid.
    DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
    DATA: i_layout TYPE slis_layout_alv.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: i_events TYPE slis_t_event.
    DATA: i_header TYPE slis_t_listheader.
    DATA: i_extab TYPE slis_t_extab.
    
    SELECT qmnum
    qmart
    qmtxt
    INTO TABLE i_data
    FROM qmel
    WHERE qmnum <= '00030000010'.
    
    
    LOOP AT i_data.
    i_data-ws_row = sy-tabix.
    i_data-ws_char = 'AAAAA'.
    MODIFY i_data.
    ENDLOOP.
    
    report_id = sy-repid.
    PERFORM f1000_layout_init CHANGING i_layout.
    PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
    PERFORM f3000_build_header CHANGING i_header.
    PERFORM f4000_events_init CHANGING i_events.
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    * I_INTERFACE_CHECK = ' '
    * I_BYPASSING_BUFFER =
    * I_BUFFER_ACTIVE = ' '
    i_callback_program = report_id
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * I_CALLBACK_TOP_OF_PAGE = ' '
    * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    * I_CALLBACK_HTML_END_OF_LIST = ' '
    * i_structure_name = ' '
    * I_BACKGROUND_ID = ' '
    i_grid_title = ws_title
    * I_GRID_SETTINGS =
    is_layout = i_layout
    it_fieldcat = i_fieldcat
    * IT_EXCLUDING =
    * IT_SPECIAL_GROUPS =
    * IT_SORT =
    * IT_FILTER =
    * IS_SEL_HIDE =
    * I_DEFAULT = 'X'
    i_save = 'A'
    * IS_VARIANT =
    it_events = i_events
    * IT_EVENT_EXIT =
    * IS_PRINT =
    * IS_REPREP_ID =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IT_ALV_GRAPHICS =
    * IT_ADD_FIELDCAT =
    * IT_HYPERLINK =
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = i_data
    EXCEPTIONS
    program_error = 1
    OTHERS = 2
    .
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    *&---------------------------------------------------------------------*
    *& Form F1000_Layout_Init
    *&---------------------------------------------------------------------*
    
    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
    
    CLEAR i_layout.
    i_layout-colwidth_optimize = 'X'.
    i_layout-edit = 'X'.
    
    ENDFORM. " F1000_Layout_Init
    *&---------------------------------------------------------------------*
    *& Form f2000_fieldcat_init
    *&---------------------------------------------------------------------*
    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
    
    DATA: line_fieldcat TYPE slis_fieldcat_alv.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
    line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
    line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
    line_fieldcat-seltext_m = 'Notification No.'. " Column Header
    APPEND line_fieldcat TO i_fieldcat.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMART'.
    line_fieldcat-ref_tabname = 'I_DATA'.
    line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
    line_fieldcat-seltext_m = 'Notif Type'.
    APPEND line_fieldcat TO i_fieldcat.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMTXT'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Description'.
    APPEND line_fieldcat TO i_fieldcat.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_ROW'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Row Number'.
    APPEND line_fieldcat TO i_fieldcat.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_CHAR'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Test Character Field'.
    line_fieldcat-datatype = 'CHAR'.
    line_fieldcat-outputlen = '15'. " You can specify the width of a
    APPEND line_fieldcat TO i_fieldcat. " column.
    
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'CHK'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Checkbox'.
    line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
    line_fieldcat-edit = 'X'. " This option ensures that you can
    " edit the checkbox. Else it will
    " be protected.
    APPEND line_fieldcat TO i_fieldcat.
    
    ENDFORM. " f2000_fieldcat_init
    
    *&---------------------------------------------------------------------*
    *& Form f3000_build_header
    *&---------------------------------------------------------------------*
    
    FORM f3000_build_header USING i_header TYPE slis_t_listheader.
    
    DATA: gs_line TYPE slis_listheader.
    
    CLEAR gs_line.
    gs_line-typ = 'H'.
    gs_line-info = 'This is line of type HEADER'.
    APPEND gs_line TO i_header.
    
    CLEAR gs_line.
    gs_line-typ = 'S'.
    gs_line-key = 'STATUS 1'.
    gs_line-info = 'This is line of type STATUS'.
    APPEND gs_line TO i_header.
    gs_line-key = 'STATUS 2'.
    gs_line-info = 'This is also line of type STATUS'.
    APPEND gs_line TO i_header.
    
    CLEAR gs_line.
    gs_line-typ = 'A'.
    gs_line-info = 'This is line of type ACTION'.
    APPEND gs_line TO i_header.
    
    ENDFORM. " f3000_build_header
    
    *&---------------------------------------------------------------------*
    *& Form f4000_events_init
    *&---------------------------------------------------------------------*
    FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
    
    DATA: line_event TYPE slis_alv_event.
    
    CLEAR line_event.
    line_event-name = 'TOP_OF_PAGE'.
    line_event-form = 'F4100_TOP_OF_PAGE'.
    APPEND line_event TO i_events.
    
    CLEAR line_event.
    line_event-name = 'PF_STATUS_SET'.
    line_event-form = 'F4200_PF_STATUS_SET'.
    APPEND line_event TO i_events.
    
    ENDFORM. " f3000_events_init
    
    *---------------------------------------------------------------------*
    * FORM F4100_TOP_OF_PAGE *
    *---------------------------------------------------------------------*
    
    FORM f4100_top_of_page.
    
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_header.
    ENDFORM.
    
    *---------------------------------------------------------------------*
    * FORM F4200_PF_STATUS_SET *
    *---------------------------------------------------------------------*
    
    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
    
    REFRESH i_extab.
    PERFORM f4210_exclude_fcodes CHANGING i_extab.
    SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.
    
    ENDFORM.
    
    *&---------------------------------------------------------------------*
    *& Form f4210_exclude_fcodes
    *&---------------------------------------------------------------------*
    
    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
    
    DATA: ws_fcode TYPE slis_extab.
    
    CLEAR ws_fcode.
    ws_fcode = '&EB9'. " Call up Report.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&ABC'. " ABC Analysis.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&NFO'. " Info Select.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&LFO'. " Information.
    APPEND ws_fcode TO i_extab.
    
    ENDFORM. " f4210_exclude_fcodes
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2009 at 04:32 AM

    Hi,

    Take the Help of Program BCALV_EDIT_05

    Hope this will serve your purpose.

    Cheers.

    Ram

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2009 at 04:59 AM

    hi ,

    there is a field in fieldcatlog like

    make fieldcat-checkbox = 'X'.

    if you set X for this field the check box is created to which column you want.

    for further more information refer to the thread given below

    Check box in ALV report

    -Thanks & Regards.

    Saurabh Goel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2009 at 05:03 AM

    hii,

    there r two ways for creating checkbox col on the ALV grid.

    1.) take an extra field in your internal table i.e

    data:

    checkbox type c.

    loop at internal_table into wa.

    checkbox.

    endloop.

    or

    the fieldcatalog attribute

    2.) wa_fcat-checkbox = 'X'.

    append wa_fcat to t_fcat.

    clear wa_fcat.

    if itab-checkbox = 'X'.

    call screen <dialogbox screen number>.

    endif.

    regards,

    Shweta

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2009 at 05:17 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2009 at 06:02 AM

    Hi all,

    Thanks for reply, i mentioned my codes below, in that i did nt get check box value for ALV display. I need after user select a check box in alv display set 'X' in itab.

    TABLES:ZPS_POSTSHIPMENT,ZPS_BANKREG.

    TYPE-POOLS: SLIS.

    TYPES:BEGIN OF TY_ITAB,

    EX_UNIT LIKE ZPS_BANKREG-EX_UNIT,

    EX_CEX LIKE ZPS_BANKREG-EX_CEX,

    EX_INVDT LIKE ZPS_BANKREG-EX_INVDT,

    EX_WAERK LIKE ZPS_BANKREG-EX_WAERK,

    CHECK TYPE C,

    END OF TY_ITAB.

    DATA:ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE,

    IT_CHECK TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE.

    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FCAT TYPE SLIS_FIELDCAT_ALV,

    FCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    WA_FCAT1 TYPE SLIS_FIELDCAT_ALV,

    LAYOUT TYPE SLIS_LAYOUT_ALV,

    WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

    LAYOUT1 TYPE SLIS_LAYOUT_ALV,

    WA_LAYOUT1 TYPE SLIS_LAYOUT_ALV.

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    *PARAMETERS:P_BURKS LIKE ZPS_BANKREG-BUKRS.

    SELECT-OPTIONS:S_UNIT FOR ZPS_BANKREG-EX_UNIT,

    S_INVDT FOR ZPS_BANKREG-EX_INVDT.

    SELECTION-SCREEN END OF BLOCK B1.

    START-OF-SELECTION.

    PERFORM FIELDCAT.

    LAYOUT-ZEBRA = 'X'.

    PERFORM OUTPUT.

    *AT SELECTION-SCREEN OUTPUT.

    &----


    *& Form PF_STATUS

    &----


    • text

    ----


    • -->RT_EXTAB text

    ----


    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

    SET PF-STATUS 'COVER'.

    ENDFORM. "PF_STATUS

    &----


    *& Form PUSH_BUTT1

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->RS_SELFIELD text

    ----


    FORM PRINT USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN 'PRINT'.

    READ LINE SY-TABIX FIELD VALUE ITAB-CHECK .

    IF SY-SUBRC EQ 0.

    ITAB-CHECK = 'X'.

    MODIFY ITAB INDEX SY-TABIX.

    ENDIF.

    ENDLOOP.

    DATA: IT_CHKBOX TYPE TABLE OF TY_ITAB.

    *

    LOOP AT ITAB.

    IF ITAB-CHECK IS NOT INITIAL.

    ITAB-CHECK = 'X'.

    ENDIF.

    ENDLOOP.

    • LOOP AT ITAB.

    • IF ITAB-CHECK EQ 'X'.

    • APPEND ITAB TO IT_CHECK.

    • ENDIF.

    • ENDLOOP.

    IF SY-SUBRC EQ 0.

    CALL TRANSACTION 'SE11'.

    ELSE.

    ENDIF.

    WHEN 'EXIT'.

    • LEAVE TO TRANSACTION 'ZRBOE'.

    LEAVE PROGRAM.

    WHEN 'CANCEL'.

    • LEAVE TO TRANSACTION 'ZRBOE'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDFORM. "PUSH_BUTT1

    &----


    *& Form FIELDCAT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FIELDCAT .

    WA_FCAT-SELTEXT_L = 'Select'.

    WA_FCAT-COL_POS = '1'.

    WA_FCAT-FIELDNAME = 'CHECK'.

    WA_FCAT-CHECKBOX = 'X'.

    WA_FCAT-TABNAME = 'ITAB'.

    WA_FCAT-OUTPUTLEN = '4'.

    WA_FCAT-INPUT(1) = 'X'.

    WA_FCAT-EDIT(1) = 'X'.

    APPEND WA_FCAT TO FCAT.

    CLEAR WA_FCAT.

    WA_FCAT-SELTEXT_L = 'Sales Organization'.

    WA_FCAT-COL_POS = '2'.

    WA_FCAT-FIELDNAME = 'EX_UNIT'.

    WA_FCAT-TABNAME = 'ITAB'.

    WA_FCAT-OUTPUTLEN = '12'.

    APPEND WA_FCAT TO FCAT.

    CLEAR WA_FCAT.

    WA_FCAT-SELTEXT_L = 'Export/Plant/Cex No'.

    WA_FCAT-COL_POS = '3'.

    WA_FCAT-FIELDNAME = 'EX_CEX'.

    WA_FCAT-TABNAME = 'ITAB'.

    WA_FCAT-OUTPUTLEN = '20'.

    APPEND WA_FCAT TO FCAT.

    CLEAR WA_FCAT.

    WA_FCAT-SELTEXT_L = 'Excise Document Date'.

    WA_FCAT-COL_POS = '4'.

    WA_FCAT-FIELDNAME = 'EX_INVDT'.

    WA_FCAT-TABNAME = 'ITAB'.

    WA_FCAT-OUTPUTLEN = '20'.

    APPEND WA_FCAT TO FCAT.

    CLEAR WA_FCAT.

    ENDFORM. " FIELDCAT

    &----


    *& Form OUTPUT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM OUTPUT .

    SELECT EX_UNIT EX_CEX EX_INVDT EX_WAERK FROM ZPS_BANKREG

    INTO TABLE ITAB

    WHERE EX_UNIT IN S_UNIT

    AND EX_INVDT IN S_INVDT.

    IF SY-SUBRC EQ 0.

    PERFORM GRID.

    ELSE.

    MESSAGE 'No Records Found' TYPE 'I'.

    ENDIF.

    ENDFORM. " OUTPUT

    &----


    *& Form GRID

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM GRID .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = SY-REPID

    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

    I_CALLBACK_USER_COMMAND = 'PRINT'

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    IS_LAYOUT = LAYOUT

    IT_FIELDCAT = FCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = ITAB

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 06:05 AM

    Thanks for all

    got answer

    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.