Checkbox in alv grid

Hello friends
i have an internal table displayed in alv with one field as editable checkbox.
The display is OK.
After the user click the SAVE button, I want to process the ckecked records only.
My problem: after clicking the SAVE  button, in USER_COMMAND form, all the records of the internal table have the checkbox field empty even if they were checked.
MOVE 'SET_PF_STATUS' TO wv_slis_formname.
  wv_repid = sy-repid.
  DELETE wt_input INDEX 1.   "remove the header texts
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_program       = wv_repid
      i_callback_pf_status_set = wv_slis_formname
      is_layout                = ws_layout
      it_fieldcat              = wt_field1
*      i_save                   = 'X'
    TABLES
      t_outtab                 = wt_input
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
anybody could give me a hint?
In debug session I check : wt_input table here
FORM user_command USING r_ucomm LIKE sy-ucomm
                        ls_selfield type slis_selfield.
  DATA: save_ok TYPE sy-ucomm.
  DATA: ref1 TYPE REF TO cl_gui_alv_grid.
  save_ok = sy-ucomm.
  CASE save_ok.
    WHEN 'SAVE'.
  ENDCASE.
ENDFORM.                    "user_command
and its fields corresponding for the checkbox are all empty

Hi,
Go through this code . This code is for interactive alv . This interactive alv will display only for Checked ones.
TYPE-POOLS : SLIS.
PARAMETERS : P_EBELN TYPE EKKO-EBELN.
TYPES: BEGIN OF TY_EKKO,
        CHECK TYPE C,
        EBELN TYPE EKKO-EBELN,
        BUKRS TYPE EKKO-BUKRS,
        EKORG TYPE EKKO-EKORG,
        BEDAT TYPE EKKO-BEDAT,
      END OF TY_EKKO.
DATA : REPID TYPE SY-REPID.
DATA : IT_EKKO TYPE TABLE OF TY_EKKO,
       WA_EKKO TYPE TY_EKKO.
DATA : ITAB TYPE TABLE OF TY_EKKO.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.
data : gs_layout type SLIS_LAYOUT_ALV.
FIELD-SYMBOLS : <WA_EKKO> LIKE LINE OF IT_EKKO.
SELECT EBELN BUKRS EKORG BEDAT FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO UP TO 10 ROWS.
PERFORM FIELDCAT.
PERFORM DISPLAY_DATA.
FORM SET_PF_STATUS USING STATUS.
  SET PF-STATUS 'STATUS'.
ENDFORM.
FORM USER_COMMAND USING FU_UCOMM LIKE SY-UCOMM FU_SELFIELD TYPE SLIS_SELFIELD.
  CASE fu_ucomm.
WHEN 'CHECK'.
      LOOP AT IT_EKKO ASSIGNING <WA_EKKO>.
        <WA_EKKO>-check = 'X'.
        MODIFY TABLE IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK.
      ENDLOOP.
      FU_SELFIELD-REFRESH = 'X'.
    WHEN 'UNCHECK'.
      LOOP AT IT_EKKO ASSIGNING <WA_EKKO>.
        <WA_EKKO>-check = ' '.
        MODIFY TABLE IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK.
      ENDLOOP.
      FU_SELFIELD-REFRESH = 'X'.
WHEN 'READ'.
IF IT_EKKO IS NOT INITIAL.
LOOP AT IT_EKKO INTO <WA_EKKO> WHERE CHECK = 'X'.
  BREAK-POINT.
   APPEND <WA_EKKO> TO ITAB.
   ENDLOOP.
  ENDIF.
if itab is not initial.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
     I_CALLBACK_PROGRAM                = SY-REPID
     I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
     I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
     IS_LAYOUT                         = GS_LAYOUT
     IT_FIELDCAT                       = IT_FCAT
     I_SAVE                            = 'X'
     TABLES
     T_OUTTAB                          = ITAB
EXCEPTIONS
  PROGRAM_ERROR                     = 1
  OTHERS                            = 2
endif.
WHEN OTHERS.
READ TABLE IT_EKKO ASSIGNING <WA_EKKO> INDEX FU_SELFIELD-TABINDEX.
<WA_EKKO>-CHECK = 'X'.
MODIFY table  IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK .
*BREAK-POINT.
FU_SELFIELD-REFRESH = 'X'.
  ENDCASE.
ENDFORM.                
FORM FIELDCAT .
  WA_FCAT-FIELDNAME = 'CHECK'.
  wa_fcat-seltext_m = 'Select' .
  wa_fcat-checkbox = 'X'.
  wa_fcat-edit = 'X'.
  WA_FCAT-COL_POS = 5.
  WA_FCAT-OUTPUTLEN = '20'.
  wa_fcat-hotspot = 'X'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME = 'EBELN' .
  WA_FCAT-TABNAME = 'EKKO' .
  WA_FCAT-COL_POS = 1.
  WA_FCAT-OUTPUTLEN = '20'.
  wa_fcat-seltext_m = 'BILLING NUM' .
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME = 'BUKRS' .
  WA_FCAT-TABNAME = 'EKKO' .
  WA_FCAT-COL_POS = 2.
  WA_FCAT-OUTPUTLEN = '20'.
  wa_fcat-seltext_m = 'COMPANY CODE' .
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME = 'EKORG' .
  WA_FCAT-TABNAME = 'EKKO' .
  WA_FCAT-COL_POS = 3.
  WA_FCAT-OUTPUTLEN = '20'.
  wa_fcat-seltext_m = 'ORGANIZATION' .
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME = 'BEDAT' .
  WA_FCAT-TABNAME = 'EKKO' .
  WA_FCAT-COL_POS = 4.
  WA_FCAT-OUTPUTLEN = '20'.
  wa_fcat-seltext_m = 'BILLING DATE' .
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
ENDFORM.                  
FORM DISPLAY_DATA .
  IF NOT IT_EKKO IS INITIAL.
    GS_LAYOUT-zebra = 'X' .
    GS_LAYOUT-colwidth_optimize = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
     I_CALLBACK_PROGRAM                = SY-REPID
     I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
     I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
     IS_LAYOUT                         = GS_LAYOUT
     IT_FIELDCAT                       = IT_FCAT
     I_SAVE                            = 'X'
     TABLES
     T_OUTTAB                          = IT_EKKO
EXCEPTIONS
  PROGRAM_ERROR                     = 1
  OTHERS                            = 2
  ENDIF.
ENDFORM.
Edited by: Aditya.G on Dec 29, 2011 12:35 PM

Similar Messages

  • Problems with checkbox in ALV-GRID OO

    Hi,
    i have Problems by listing an editable checkbox
    in ALV GRID OO and handle the itab with
    the marked fields.
    Here my Code extract. Has anybody an idea or a short example.
    TYPES: BEGIN OF ALV_TAB,
            SGTXT  LIKE RK23B-SGTXT,
            CHECK(1),
          END   OF ALV_TAB.
    DATA: ITAB    TYPE TABLE OF ALV_TAB.
    Is this Declaration correct??
    <b>  GS_FIELDCAT-FIELDNAME  = 'CHECK'.
      GS_FIELDCAT-CHECKBOX   = 'X'.
      APPEND GS_FIELDCAT TO GT_FIELDCAT.
      GS_LAYOUT-EDIT         = 'X'.
      GS_LAYOUT-BOX_FNAME    = 'CHECK'.</b>
      CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = PT_EXCLUDE
          IS_LAYOUT            = GS_LAYOUT
        CHANGING
          IT_FIELDCATALOG      = GT_FIELDCAT
          IT_OUTTAB            = ITAB.
    FORM HANDLE_USER_COMMAND USING E_UCOMM.
      CASE E_UCOMM.
        WHEN 'REFR'.
    <b>      Here i will have the itab with the marked checkbox.
          how can i refresh?</b>*
        WHEN 'EXCEL'.
          MESSAGE I010 WITH E_UCOMM.
      ENDCASE.
    ENDFORM.                    "HANDLE_USER_COMMAND
    Regards, Dieter

    Hi, in reference to....
    ASE E_UCOMM.
    WHEN 'REFR'.
    Here i will have the itab with the marked checkbox.
    how can i refresh?*
    Do you want to get rid of the checks in any checkbox?
    If so,  just loop at modify.
    ASE E_UCOMM.
    WHEN 'REFR'.
    <b>   Loop at itab where check = 'X'.
            itab-check = space.
            modify itab.
       endloop.</b>
    Regards,
    Rich Heilman

  • User command for checkbox in alv grid output

    Hi,
    Does anyone knows the user command for checkbox in alv grid display. My requirement is to have a column for checkbox in alv output. When the user checks the checkbox, a pop-up dialog box will appear. This dialog box was created in screen painter. I can't find the user command for this. Please help.
    Thanks in advance.

    Hi,
    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
    ravi

  • Set editable/non-editable checkbox in alv grid

    Hi all,
    How to set a checkbox in alv grid in editable/non-editable. i am using alv gird display function module for this. i tried to used method  cl_gui_alv_grid=>mc_style_disabled. but its not working. is it possible to have this functionality in grid? please help. thanks in advance.

    Hi,
    Try like this.
    CALL METHOD gr_alvgrid->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    I_SAVE =
    I_DEFAULT = 'X'
    is_layout = gs_layout
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING =
    IT_HYPERLINK =
    CHANGING
    it_outtab = gt_list[]
    it_fieldcatalog = gt_fieldcat
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    regards
    Rajesh kumar

  • How to Set Checkbox of ALV Grid Dark on Display Mode

        ABAP experts, I want to switch between display mode and edit mode for some columns of ALV Grid. So I set "LVC_S_FCAT-EDIT" "X" for the columns which need to switch mode, and use method "SET_READY_FOR_INPUT" to switch.
        Currently, the function of switch mode has been achieved. But icons of checkbox columns are light but not dark when display mode, although the columns can't be edited. (Please refer to the image below.) I want to make checkbox columns dark as other columns on display mode.
        I tried to use "CL_GUI_ALV_GRID=>MC_STYLE_ENABLED" and "CL_GUI_ALV_GRID=>MC_STYLE_DISABLED", but failed. I also studied sample program "BCALV_EDIT_05" which is related to checkbox in ALV Grid, and compared my program with this program. But I still have not found problems.
        Help me solve this problem, please.
        Part of my codes are as follows.
        Part 1:
    IF iv_is_create_group = abap_true OR iv_is_edit_group = abap_true.
           set_enable( iv_flag = 1 ).
           LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
             CLEAR ls_celltab.
             IF <lfs_acct_group_item>-celltab IS INITIAL.
               CLEAR ls_celltab.
               ls_celltab-fieldname = 'CHECK_BOX'.
               ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
               APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
               CLEAR ls_celltab.
               ls_celltab-fieldname = 'XPORE'.
               ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
               APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
             ELSE.
               LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
                 <lfs_celltab>-style = cl_gui_alv_grid=>mc_style_enabled.
               ENDLOOP.
             ENDIF.
           ENDLOOP.
         ELSE.
           set_enable( iv_flag = 0 ).
           LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
             IF <lfs_acct_group_item>-celltab IS INITIAL.
               CLEAR ls_celltab.
               ls_celltab-fieldname = 'CHECK_BOX'.
               ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
               APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
               CLEAR ls_celltab.
               ls_celltab-fieldname = 'XPORE'.
               ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
               APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
             ELSE.
               LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
                 <lfs_celltab>-style = cl_gui_alv_grid=>mc_style_disabled.
               ENDLOOP.
             ENDIF.
           ENDLOOP.
         ENDIF.
         CALL METHOD gr_grid->refresh_table_display
    *      EXPORTING
    *        is_stable      =
    *        i_soft_refresh =
           EXCEPTIONS
             finished       = 1
             OTHERS         = 2
         IF sy-subrc <> 0.
    *     Implement suitable error handling here
         ENDIF.
        Part 2:
    METHOD set_enable.
         gr_grid->set_ready_for_input(
             i_ready_for_input = iv_flag
    ENDMETHOD.

    Hi Liu,
        Please go through the below code.
    *& Report  YEDIT_DISPLAY
    REPORT  YEDIT_DISPLAY.
    TABLES : VBAK.
    TYPE-POOLS SLIS.
    TYPES : BEGIN OF TY_VBAK,
              VBELN TYPE VBAK-VBELN,
             END OF TY_VBAK,
             BEGIN OF TY_FINAL,
               BOX TYPE C,
               VBELN TYPE VBAK-VBELN,
             END OF TY_FINAL.
    DATA : IT_VBAK TYPE TABLE OF TY_VBAK,
            WA_VBAK TYPE TY_VBAK,
            IT_FINAL TYPE TABLE OF TY_FINAL,
            WA_FINAL TYPE TY_FINAL,
            IT_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV,
            WA_FCAT TYPE SLIS_FIELDCAT_ALV.
    START-OF-SELECTION.
       PERFORM FETCH_DATA.
       PERFORM FCAT_DATA.
       PERFORM DISPLAY.
    *&      Form  FETCH_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FETCH_DATA .
       SELECT VBELN INTO TABLE IT_VBAK FROM VBAK UP TO 10 ROWS.
       LOOP AT IT_VBAK INTO WA_VBAK.
         WA_FINAL-VBELN = WA_VBAK-VBELN.
         APPEND WA_FINAL TO IT_FINAL.
         CLEAR : WA_FINAL , WA_VBAK.
       ENDLOOP.
    ENDFORM.                    " FETCH_DATA
    *&      Form  FCAT_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FCAT_DATA .
       WA_FCAT-COL_POS = 1.
       WA_FCAT-FIELDNAME = 'BOX'.
       WA_FCAT-TABNAME = 'IT_FINAL'.
       WA_FCAT-OUTPUTLEN = '3'.
       WA_FCAT-SELTEXT_M = 'BOX'.
       wa_fcat-checkbox = 'X'.
       WA_FCAT-EDIT = 'X'.
       APPEND WA_FCAT TO IT_FCAT.
       CLEAR WA_FCAT.
       WA_FCAT-COL_POS = 2.
       WA_FCAT-FIELDNAME = 'VBELN'.
       WA_FCAT-TABNAME = 'IT_FINAL'.
       WA_FCAT-OUTPUTLEN = '3'.
       WA_FCAT-SELTEXT_M = 'Sales Document'.
       APPEND WA_FCAT TO IT_FCAT.
       CLEAR WA_FCAT.
    ENDFORM.                    " FCAT_DATA
    *&      Form  DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY .
       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          = ' '
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
          IT_FIELDCAT                       = IT_FCAT
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
         TABLES
           T_OUTTAB                          = IT_FINAL
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
       IF SY-SUBRC <> 0.
    * Implement suitable error handling here
       ENDIF.
    ENDFORM.                    " DISPLAY
    FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM
                             RTAB TYPE slis_selfield.
       CASE UCOMM.
         WHEN '&IC1'.
           MESSAGE 'SUCESSFUL' TYPE 'S'.
         WHEN '&DATA_SAVE'.
           PERFORM FIL_FCAT.
           PERFORM DISPLAY1.
         WHEN 'BACK'.
           LEAVE TO SCREEN 0.
         WHEN OTHERS.
           LEAVE TO SCREEN 0.
       ENDCASE.
    ENDFORM.
    *&      Form  FIL_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FIL_FCAT .
    CLEAR IT_FCAT.
       WA_FCAT-COL_POS = 1.
       WA_FCAT-FIELDNAME = 'BOX'.
       WA_FCAT-TABNAME = 'IT_FINAL'.
       WA_FCAT-OUTPUTLEN = '3'.
       WA_FCAT-SELTEXT_M = 'BOX'.
       wa_fcat-checkbox = 'X'.
    **  WA_FCAT-EDIT = 'X'.
       APPEND WA_FCAT TO IT_FCAT.
       CLEAR WA_FCAT.
       WA_FCAT-COL_POS = 2.
       WA_FCAT-FIELDNAME = 'VBELN'.
       WA_FCAT-TABNAME = 'IT_FINAL'.
       WA_FCAT-OUTPUTLEN = '3'.
       WA_FCAT-SELTEXT_M = 'Sales Document'.
       APPEND WA_FCAT TO IT_FCAT.
       CLEAR WA_FCAT.
    ENDFORM.                    " FIL_FCAT
    *&      Form  DISPLAY1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY1 .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
          I_CALLBACK_PROGRAM                = SY-REPID
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
          IT_FIELDCAT                       = IT_FCAT
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
         TABLES
           T_OUTTAB                          = IT_FINAL
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
       IF SY-SUBRC <> 0.
    * Implement suitable error handling here
       ENDIF.
    ENDFORM.                    " DISPLAY1
    Here i written code under the SAVE button , if requires you create your own status and apply.
    Regards,
    Krishna

  • Functionality of Checkbox in ALV Grid Report

    Hi Experts,
    I created a ALV grid report with the checkbox as my first coloum and other fields as shown below. Initially, my ALV report displays as below. It is working fine till here.
    checkbox       customer     material      quantity       UOM         Sales Order    Delivery
                           C1                  M1           1                  KG
                           C1                   M2           2                  KG
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    I have created a push button on application toolbar for creating sales order and delivery using bapi's. When I click on my pushbutton, as of now it creates the SO and delivery for the first customer C1 and updates my Internal table with the sales order number and delivery number. If I need to create sales order for the second customer I need to run my ALV report again and so on for 3rd, 4th and 5th customers. It is also working fine till here.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
                           C1                  M1           1                  KG          SO1               DEL1
                           C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    Need help on this:
    When I select the check boxes as shown below and when I click the push button to create SO and Delivery then my program should create sales order and delivery for all the checked ones as shown below. What is the condition do I need to put here for selecting the checkbox.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
    X                      C1                  M1           1                  KG         SO1               DEL1
    X                     C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
    X                     C3                   M1          1                   KG        SO3             DEL3
    X                     C3                   M2          2                   KG        SO3             DEL3
    X                     C3                   M3           3                 KG          SO3            DEL3
                            C4                  M1           1                  KG
    X                     C5                   M5           1                  KG          SO5            DEL5
    I would really appreciate if somebody could help me / guide me on this. I will also post my code if someone needs to understand what I am doing exactly.
    Thanks.

    You need to use OO ABAP
    Use Class the class  1)  CL_GUI_ALV_GRID, 2) CL_GUI_CUSTOM_CONTAINER
    Create Sceen and container on same screen.
    Check following COde it used for printing purpose.
    Using AFTER_USER_COMMAND  Event you will find Check box selected entries.
    Capture those in another internal Table and use it for SO Creation
    DATA:  O_GRID TYPE REF TO CL_GUI_ALV_GRID,
           O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           T_FCAT TYPE LVC_T_FCAT,
           CONTAINER(15) TYPE C VALUE 'ET_CONTAINER'.
          CLASS EVENT_CLASS DEFINITION
    CLASS EVENT_CLASS DEFINITION.
      PUBLIC SECTION.
        METHODS: BEFORE_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
                 DOUBLE_CLICK_N  FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN,
                 TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT.
    ENDCLASS.                    "EVENT_CLASS DEFINITION
          CLASS EVENT_CLASS IMPLEMENTATION
    CLASS EVENT_CLASS IMPLEMENTATION.
      METHOD BEFORE_COMMAND.
        IF E_UCOMM = 'PRINT'.
          CLEAR : W_FLAG.
          T_FINAL2 = T_FINAL.
          SORT T_FINAL2 BY COL_CHK .
          DELETE   T_FINAL2 WHERE COL_CHK = ' '.
          IF NOT T_FINAL2 IS INITIAL.
            LOOP AT T_FINAL2 INTO WA_FINAL.
              IF W_FLAG IS INITIAL.
      Does some of modification/s in control parameters
                W_CONTROL_PARAM-NO_OPEN   = 'X'.
                W_CONTROL_PARAM-NO_CLOSE  = 'X'.
                W_CONTROL_PARAM-PREVIEW   = 'X'.
                W_CONTROL_PARAM-NO_DIALOG = SPACE.
                W_OUTPUT_OPTIONS-TDNEWID = 'X'.
                W_OUTPUT_OPTIONS-TDIMMED = SPACE.
      Opens the smartform print-job
                CALL FUNCTION 'SSF_OPEN'
                  EXPORTING
                    OUTPUT_OPTIONS     = W_OUTPUT_OPTIONS
                    CONTROL_PARAMETERS = W_CONTROL_PARAM
                  EXCEPTIONS
                    FORMATTING_ERROR   = 1
                    INTERNAL_ERROR     = 2
                    SEND_ERROR         = 3
                    USER_CANCELED      = 4
                    OTHERS             = 5.
                IF SY-SUBRC EQ 0.
                  W_FLAG = 'X'.
                ELSE.
                 LEAVE LIST-PROCESSING.
                ENDIF.
              ENDIF.
              IF W_FLAG = 'X'.
                CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
                  EXPORTING
                    FORMNAME           = 'ZFORM_BIW_PRINT'
                  IMPORTING
                    FM_NAME            = LF_FM_NAME
                  EXCEPTIONS
                    NO_FORM            = 1
                    NO_FUNCTION_MODULE = 2
                    OTHERS             = 3.
                IF SY-SUBRC <> 0.
                ENDIF.
                IF SY-SUBRC = 0.
                  CALL FUNCTION LF_FM_NAME
                    EXPORTING
                      CONTROL_PARAMETERS = W_CONTROL_PARAM
                     V_VBELN            = WA_FINAL-VBELN
                      WA_FINAL           = WA_FINAL.
                   TABLES
                     T_FINAL            = T_FINAL.
                ELSE.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                ENDIF.
              ENDIF.
            ENDLOOP.
           * Close the smartform print job
            IF W_FLAG EQ 'X'.
              CALL FUNCTION 'SSF_CLOSE'
                EXCEPTIONS
                  FORMATTING_ERROR = 1
                  INTERNAL_ERROR   = 2
                  SEND_ERROR       = 3
                  OTHERS           = 4.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "BEFORE_COMMAND

  • Reg: CheckBox in ALV Grid Display

    Hi all,
    My requirement is to display checkbox field in ALV Grid which is editable.
    And i also need to get all the records that i have selected in ALV grid.
    How can i do it. Kindly Help me with sample codes.
    Its Urgent.
    <REMOVED BY MODERATOR>
    Regards
    Naveen
    Edited by: Alvaro Tejada Galindo on Feb 18, 2008 5:41 PM

    Hi,
    First declare ur itab with the first field of length 1 char,
    Dont mention dat in the field cat.
    Give that field name and itab name in the layout.
    as
      is_layout-box_fieldname = 'CHECK'.
      is_layout-box_tabname   = 'IT_FINAL'.
    u can dispaly ur checkbox in the output dispaly.
    now to read the selected checkboxes u need to read the display with the syntax..
    first describe the table + headre length = w_count.
    FORM sub_read_checkbox.
      DATA: w_cbox TYPE char1.
      REFRESH : it_mail,it_text,it_selected.                   
      REFRESH : it_selected.
      DO w_count TIMES.
        READ LINE sy-index FIELD VALUE  : is_final-cbox  INTO w_cbox.
        IF w_cbox = c_x.
          READ TABLE it_header INTO is_header WITH KEY lifnr = is_header-lifnr
                                                       u_r   = is_header-u_r.
          IF sy-subrc = 0.
            APPEND is_header TO it_selected .
            CLEAR: is_header,w_cbox.
          ENDIF.
        ENDIF.
      ENDDO.
    endform.
    This serves ur purpose.
    Regards............

  • Handling checkboxes in ALV Grid.

    Hi  guys.
    I have displayed an ALV grid with checkboxes. I want to opearate on the selected checkboxes by the user by clicking on a added button.
    I am using oops and using function set_table_for_first_display.
    if no box is selected the function works properly. If i select a checkbox, i get a dump.
    Thanks

    Hi arun
    here is the required code.
    <b>Form to register events</b>
    FORM register_events .
      CREATE OBJECT gr_event_handler .
      SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid .
      SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid.
      SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid.
      SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid.
    ENDFORM. 
    <b>Class Defination and implementation</b>
    CLASS LCL_EVENT_HANDLER DEFINITION.
        PUBLIC SECTION .
          METHODS:
    *To add new functional buttons to the ALV toolbar
          handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING e_object e_interactive,
    *To implement user commands.
          handle_user_command
          FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING e_ucomm,
       To handle hotspot click.
          handle_hotspot_click
          FOR EVENT hotspot_click OF cl_gui_alv_grid
          IMPORTING e_row_id e_column_id es_row_no,
         To handle Double Click
          handle_double_click
          FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column .
      ENDCLASS.                    "LCL_EVENT_HANDLER DEFINITION
    *&       Class (Implementation)  lcl_event_handler
           Text
      CLASS lcl_event_handler IMPLEMENTATION.
        METHOD handle_toolbar.
          PERFORM handle_toolbar USING e_object.
        ENDMETHOD .                    "handle_toolbar
        METHOD handle_user_command.
          perform handler_user_command using e_ucomm .
        ENDMETHOD.                    "handle_user_command
        METHOD handle_hotspot_click .
          PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
        ENDMETHOD .                    "handle_hotspot_click
        METHOD handle_double_click .
          PERFORM handle_double_click USING e_row e_column .
        ENDMETHOD .                    "handle_hotspot_click
      ENDCLASS.            "lcl_event_handler
    <b>
    PBO of screen that is called after the pushbutton is pressed.</b>
    MODULE STATUS_9400 OUTPUT.
      SET PF-STATUS 'SCREEN9400'.
      perform diaply_checkbox.
    <b>and the method display_checkbox.</b>
    FORM diaply_checkbox .
      data: count type i.
      count = 0.
      loop at za004_t_t into wa_a004_t_t.
        if wa_a004_t_t-checkboc = 'X'.
          count = count + 1.
        endif.
          count = count + 1.
      endloop.
    ENDFORM.                    " diaply_checkbox
    thanks
    Abhinav Dhasmana

  • ALV REPORT: read selected checkbox in alv grid and process the pushbutton

    my requirement is to check some rows from alv grid and the press the pushbutton. Thereby following things should process:
    select all checked rows into an itab and call the transaction code CJ01 for all
    entries......
    I am finding the problem that when I select the checkbox....the internal table doesnt recognize the boxes as checked ones......
    thanks in advance...
    Kartikey Singh,

    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.
          loop at t_output where Flag = 'X'.
            if t_output-VKUEGRU is initial.
              message e000 with text-110.
            endif.
    endloop.

  • Click checkbox on alv grid

    hi all,
    Is there any way to handle the single click/tick on checkbox. Is there user command on that? For now, if we will click on the checkbox, the changes made on it does not reflect. I checked on the debugging mode, checkbox is not populated/ marked even if it was ticked by the user.
    thanks in advance.

    Hi Akira,
    For Controling  Check Box , you have to use grid display using customised  Container screen.
    From there you can control check Box .
    CREATE OBJECT custom_container
         EXPORTING container_name = o_container.
      CREATE OBJECT o_grid
               EXPORTING i_parent = custom_container.
    Form for building the fieldcatalog
      PERFORM build_fieldcat CHANGING it_fieldcat.
    Form for excluding the unwanted functionalities from the toolbar.
      PERFORM exclude_tb_functions CHANGING it_exclude.
    Method for displaying the ALV grid.
      CALL METHOD o_grid->set_table_for_first_display
        EXPORTING
          is_layout            = it_layout
          it_toolbar_excluding = it_exclude
        CHANGING
          it_fieldcatalog      = it_fieldcat
          it_outtab            = it_final.
      CREATE OBJECT o_event_receiver.
    Setting the event handlers for events toolbar, usercommand and datachange.
      SET HANDLER o_event_receiver->catch_toolbar FOR o_grid.
      SET HANDLER o_event_receiver->catch_user_command FOR o_grid.
      SET HANDLER o_event_receiver->catch_datachange FOR o_grid.
    Set editable cells to ready for input.
      CALL METHOD o_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.

  • To activate/deactivate checkbox in ALV grid report

    Hi All,
    I am trying to create an ALV Grid that contains check-box as column fields. I am able to either activate or deactivate all the check-boxes in the entire column. But, I need to keep only certain check-boxes for editing based on certain conditions. The other check-boxes in the column should be deactivated for editing by the user. Any help is appreciated.
    -Dinesh

    Hi dinesh babu ,
    In this example, i use 'REUSE_ALV_GRID_DISPLAY_LVC'
    FORM display_alv .
    DATA: ls_event_exit TYPE slis_event_exit,
          lt_event_exit TYPE slis_event_exit OCCURS 1.
    DESCRIBE TABLE itab_data LINES lv_cont.
    PERFORM layout_build   USING gs_layout.
    PERFORM eventtab_build USING gt_events[].
    PERFORM comment_build  USING gt_lheader[].
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    i_structure_name            = 'ZHRESS_FORMACION_ALV'
    i_client_never_display   = 'X'
    i_bypassing_buffer         = 'X'
    CHANGING
    ct_fieldcat                      = gt_fieldcat[]
    EXCEPTIONS
    inconsistent_interface   = 1
    program_error               = 2
    OTHERS                         = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT gt_fieldcat INTO ls_fcat.
    Active check field
      IF ls_fcat-fieldname EQ 'CHECK'.
         ls_fcat-checkbox     = 'X'.
         ls_fcat-edit             = 'X'.
         ls_fcat-fix_column  = 'X'.
         ls_fcat-reptext        = 'Check'.
      ENDIF.
      PERFORM field_attributes.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
         i_background_id                   = 'ALV_BACKGROUND'
    i_callback_program             = g_repid
    i_callback_pf_status_set      = 'PF_STATUS'
    i_callback_user_command  = 'USER_COMMAND'
    is_layout_lvc                       = gs_layout
    it_fieldcat_lvc                     = gt_fieldcat[]
    i_save                                 = g_save
    is_variant                            = g_variant
    it_events                             = gt_events[]
    it_event_exit                       = lt_event_exit
    i_default                             = 'X'
    TABLES
    t_outtab                              = itab_data.
    ENDFORM.                    " DISPLAY_ALV
    FORM field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
      LOOP AT itab_data INTO wa_data.
        IF wa_data-status NE c_status_p.         " Condition for enable / disable check
          ls_stylerow-fieldname = 'CHECK' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.  "set field to disabled
          APPEND ls_stylerow TO wa_data-field_style.
          MODIFY itab_data FROM wa_data.
        ENDIF.
      ENDLOOP.
    ENDFORM.   
    Regards,
    José
    Edited by: Jose Luzardo on Oct 6, 2009 3:37 PM

  • Change Totals based on Checkbox  in ALV Grid

    Hi,
    My report is having 5 Columns with 50 records as Output.
    First :Check box.
    Second : Inbound Delivery Number.
    Third : Carton Id
    Fourth: Weight
    Fifth : Volume.
    User can select/ deselect the records using Check box. I am writing this logic under Hot spot event.
    I need to calculate sum of Weight and Volume for the records which user selects using Check box and 
    display it Total Weight and Total Volume.
    How can i change the Totals in Top_of_page at run time based on user selection? Please suggest..
    Thanks
    Bhuvana

    Hi,
    Instead you could have one "Sum" button on application toolbar and if user selects the number of rows and clicks on that button, then you can sum up the selected rows and show (WRITE command at TOP_OF_PAGE event) it in screen.
    Try it!
    Regards
    Sarav

  • Urgent checkboxes handling in alv grid

    helo all .i need to handle checkboxes in alv grid.
    i did like
    case u_comm.
    when 'save'.
    perform save.
    endcase.
    in the form.
    form save.
    loop at it_mara into it_mara1 where chk = 'X'
    and moving the contents to it_mara1.
    but after doing it is not looping when i have seen in debug .
    plz help me
    i need to have those selected values and move a head.

    Hi rakhee,
    First add a single charecter field into the internal table you want to display in the ALV.Then set the field cataloge and set the value for Checkbox as 'X'.it wil display the field as a check box.when you check the check box it will update the internal table also.
    please check the below code.
    TYPE-POOLS : slis.
    TYPES : BEGIN OF st_mara.
    TYPES : matnr TYPE mara-matnr.
    TYPES : a,
    END OF st_mara.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
           wa_fieldcat LIKE LINE OF it_fieldcat.
    DATA : it_mara TYPE TABLE OF st_mara.
    SELECT * FROM mara
             INTO CORRESPONDING FIELDS OF TABLE it_mara UP TO 1 ROWS.
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'A'.
    wa_fieldcat-checkbox = 'X'.
    wa_fieldcat-edit = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = 2.
    wa_fieldcat-fieldname = 'MATNR'.
    APPEND wa_fieldcat TO it_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        it_fieldcat = it_fieldcat
      TABLES
        t_outtab    = it_mara.
    BREAK-POINT.
    if you are using controls just call the method
      CALL METHOD grid1->check_changed_data.
    grid1 is the instance of the ALV grid.
    when the method is called you will get the internal table with the field marked as 'X'.
    Regards
    Sandeep

  • How to put a check boc in alv grid

    hi gurus i  need to put a checkbox in alv grid output
    not a pop up window
    can anybody inform me
    thank you
    raghavendra

    Hi,
    check these threads
    How can I display a checkbox in ALV? http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Regards

  • Disabling push button column cell on alv grid control (OOABAP)

    Hello All,
    I have a requirement where I need to add one column as pushbutton in alv grid display. I have done that and it's triggering button_click event also. The problem here is that I want the few <b>push button cells</b> of that column to be disbaled (depending on my requirement). I tried using a internal table lvc_t_styl and adding a field of same lvc_t_styl in my main internal table. This works for all other fields (e.g disbaling checkbox in alv grid and other editable fields) but not for push buttons. My exact requirement is that I want some of the <b>cells of pushbutton column to be grayed out (made inactive)</b>. Can anyone tell me how to do that. Thanks.
    Note:Helpful answers will be duly rewarded.
    null

    Hi,
    I had the same problem.
    what I did I just added the  cl_gui_alv_grid=>mc_style_button at each row of the data table instead of adding it at the field catalog level.
    Hope this solve your problem.
    Thanks,
    Harish

Maybe you are looking for