CheckBox in ALV

Hi all,
I need to display three fields say customer, name and one check box,
user will select few records from the risplayed report and i need to display detailed report for those customers.
how to find out that the records selected by the customer(he will tick the checkbox but in the program how to find out them)
thanks.
SAI

hi,
chk this sample code.'
report z_alvtest .
*& Report Z_ALVTEST *
type-pools: slis.
tables: vbak,vbap,mara.
data: p_repid like sy-repid.
p_repid = sy-repid.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
auart like vbak-auart,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
posnr like vbap-posnr,
charg like vbap-charg,
check(1),
end of itab.
data: begin of jtab occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
mbrsh like mara-mbrsh,
matkl like mara-matkl,
end of jtab.
data: it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv,
gt_fieldcat type slis_t_fieldcat_alv,
x_fieldcat type slis_fieldcat_alv.
start-of-selection.
  perform get_data.
  perform field_catalog.
  perform display_data.
*& Form GET_DATA
* text
* --> p1 text
* <-- p2 text
form get_data .
  select a~vbeln a~erdat a~auart a~vkorg b~matnr b~posnr b~charg into
  corresponding fields of table itab
  up to 100 rows
  from vbak as a inner join vbap as b
  on a~vbeln = b~vbeln.
* loop at itab.
* SELECT MTART MBRSH MATKL FROM MARA INTO TABLE JTAB
* FOR ALL ENTRIES IN ITAB WHERE MATNR = ITAB-MATNR.
* endloop.
* endif.
endform. " GET_DATA
*& Form FIELD_CATALOG
* text
* --> p1 text
* <-- p2 text
form field_catalog .
  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
  exporting
  i_program_name = p_repid
  i_internal_tabname = 'ITAB'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
  i_inclname = p_repid
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
  changing
  ct_fieldcat = it_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.
<b>  loop at it_fieldcat into wa_fieldcat where fieldname = 'CHECK'.
    wa_fieldcat-checkbox = 'X'.
    wa_fieldcat-input = 'X'.
    wa_fieldcat-col_pos = 1.
     wa_fieldcat-edit = 'X'.
   modify it_fieldcat from wa_fieldcat .
    clear wa_fieldcat.
  endloop.</b>
endform. " FIELD_CATALOG
*& Form DISPLAY_DATA
* text
* --> p1 text
* <-- p2 text
form display_data .
  call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
  i_callback_program = p_repid
* I_CALLBACK_PF_STATUS_SET = ' '
  i_callback_user_command = 'USER_COMMAND'
  it_fieldcat = it_fieldcat
  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.
endform. "DISPLAY_DATA
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
* Check function code
  case r_ucomm.
    when '&IC1'.
      if rs_selfield-fieldname = 'MATNR'.
        call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
        i_program_name = p_repid
        i_internal_tabname = 'JTAB'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
        i_inclname = p_repid
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
        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.
        if not itab[] is initial.
          if not rs_selfield-value is initial.
            read table itab index rs_selfield-tabindex.
            select matnr mtart mbrsh matkl
            from mara
            into table jtab
            where matnr = itab-matnr.
          endif.
        endif.
        call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
        i_callback_program = p_repid
* 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 =
* I_GRID_SETTINGS =
* IS_LAYOUT =
        it_fieldcat = gt_fieldcat
* 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
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
        tables
        t_outtab = jtab
        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.
      endif.
  endcase.
endform. " DISPLAY_DATA
Rgds
Anver

Similar Messages

  • RE: Use of checkbox in ALV

    Hi All,
    Please provide a solution. how to use checkboxes in ALV report.
    •     “Include Blocked A ” checkbox – default is unchecked –
    THEN the report data should include all A flagged for Block (as well as all active A )
    •     “Include Deleted A ” checkbox – default is unchecked –
    Then the report data should include all  A flagged for deletion (as well as all active A )
    •     “Include Deactivated A ” checkbox – default is unchecked –
    Then the report data should include all A  flagged for deactivated on
    •     “Include Disposed/Retired A” checkbox – default is unchecked –
    When checked
    •      “Include A without values” checkbox – default is unchecked
    When checked
    Then also include A Master Records without an A Value Date.

    Check below code for Dynamic selection screen as per radio buttons
    TABLES: ekpo, resb, ltak.
    PARAMETER : p_res RADIOBUTTON GROUP rb1 DEFAULT 'X'  USER-COMMAND ucom,
                p_sto    RADIOBUTTON GROUP rb1.
    SELECT-OPTIONS :
               s_rwerks FOR ekpo-werks NO INTERVALS NO-EXTENSION MODIF ID s,
               s_wempf  FOR resb-wempf NO INTERVALS NO-EXTENSION MODIF ID r,
               s_deldt  FOR resb-bdter NO-EXTENSION DEFAULT sy-datum,
               s_tanum  FOR ltak-tanum NO-EXTENSION MODIF ID s,
               s_bdatu  FOR ltak-bdatu NO-EXTENSION MODIF ID r.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF p_sto = 'X'.
          IF screen-group1 = 'R'.
            screen-input  = 0.
            MODIFY SCREEN.
            CONTINUE.
          ENDIF.
        ENDIF.
        IF p_res = 'X'.
          IF screen-group1 = 'S'.
            screen-input  = 0.
            MODIFY SCREEN.
            CONTINUE.
          ENDIF.
        ENDIF.
      ENDLOOP.
    I think this will solve your problem....
    Rewards if helpful...
    Regards,
    Minal

  • Checkbox in alv report

    hi all,
    i am facing one problem regarding checkbox in alv.
    i have to buttons on alv report as 'select all' (to select all) and 'send mail'(as i have to send mail to selected record)
    wat i have done till now is:
    1. when i run the report and cleck on checkboxes the action is reflected in internal table..n i can capture the data.
    2.when i click on select all button all the records get selected and i can capture the data again.
    now the problem :
    when i clcik on "select all" and all the record get selected ..but when i deselect any of those record..the changes in internal table lost i.e. the checkbox field because empty for all the record.....
    PLZ GIVE SOLUTION FOR FUNCTION "REUSE_ALV_GRID_DISPLAY" ONLY...
    now the code:
    ************LAYOUT**************
    DATA: gd_layout TYPE SLIS_LAYOUT_ALV.
      gd_layout-colwidth_optimize = 'X'.
    gd_layout-zebra      = 'X'.
      gd_layout-box_fieldname  = 'CHECKBOX'.
      gd_layout-box_tabname  = 'IT_CONF'.
    ****alv display*************
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_grid_title             = 'Detailed List'
            it_fieldcat              = fieldcat
            i_callback_program       = sy-repid
            i_callback_user_command  = 'USER_CMD'
            i_callback_pf_status_set = 'EMAILS'
            IS_LAYOUT                = gd_layout
          TABLES
            t_outtab                 = it_conf
          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.
      endif.
    endform.                    "alv_display
    *&      Form  sush1
          text
         -->RT_EXTAB   text
    FORM emails USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'EMAILS'.
    ENDFORM.                    "emails
    *&      Form  user_cmd
          text
         -->P_UCOMM    text
         -->LS_SELFIELDtext
    FORM user_cmd USING p_ucomm LIKE sy-ucomm ls_selfield type slis_selfield.
    IF REF_GRID IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            E_GRID = REF_GRID.
      ENDIF.
    IF NOT REF_GRID IS INITIAL.
        CALL METHOD REF_GRID->CHECK_CHANGED_DATA.
      ENDIF.
      IF p_ucomm = 'EMAIL'.
        loop at it_conf  where checkbox = 'X'.
    **[[[[[[[U MAY NOT SEE THIS THIS IS FOR MAIL PUPOSE]]]]]]]]]]]]*********
          select single  sachn  telnr  into (tc_name , tc_num ) from t526
          where SACHX = it_conf-zztc
          and werks = it_conf-werks .
      ******find the emil of employee.
           clear : p_0105,p_0105[].
            CALL FUNCTION 'HR_READ_INFOTYPE'
              EXPORTING
                pernr           = it_conf-pernr
                infty           = '0105'
                BEGDA           = pn-begda
                ENDDA           = pn-endda
              TABLES
                infty_tab       = p_0105
              EXCEPTIONS
                infty_not_found = 1
                OTHERS          = 2.
           if sy-subrc = 0.
            read table p_0105 with key subty = 10.
            move p_0105-USRID_LONG to email.
        endif.
    find immediate superior by Z FM.
          clear pernr_s.
          CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
            EXPORTING
              pernr     = it_conf-pernr
              begda     = '18000101'
              endda     = '99991231'
            IMPORTING
              v_pernr   = pernr_s
            EXCEPTIONS
              not_found = 1
              OTHERS    = 2.
          if sy-subrc = 0.
    find the email of the immed. superiors personal number..
            clear : p_0105,p_0105[].
            CALL FUNCTION 'HR_READ_INFOTYPE'
              EXPORTING
                pernr           = pernr_s
                infty           = '0105'
                BEGDA           = pn-begda
                ENDDA           = pn-endda
              TABLES
                infty_tab       = p_0105
              EXCEPTIONS
                infty_not_found = 1
                OTHERS          = 2.
            read table p_0105 with key subty = 10.
            move p_0105-USRID_LONG to email_s.
              endif.
            if email <> ' '.
            perform send_mail using it_conf-ename email email_s tc_name tc_num.
            endif.
            if email_s <> ' '.
            perform send_mail using it_conf-ename email email_s tc_name tc_num.
            endif.
    ****MAIL PART IS OVER*******************************************
        endloop.
    endif.
    *****FOR  "SELECT ALL " BUTTON**************
       IF p_ucomm = 'SELECT'.
       flag = 1.
        loop at it_conf.
          move 'X' to it_conf-checkbox.
          MODIFY IT_CONF.
        endloop.
        ls_selfield-refresh = 'X'.
        endif.

    " Please  see the code  of  myin  in the    'SELECT' & 'DESELECT'.
    case save_ok.
        when 'EXIT'.
          perform exit_program.
        when 'SELECT'.
          perform select_all_entries changing gt_outtab[].
        when 'DESELECT'.
          perform deselect_all_entries changing gt_outtab[].
        when 'RESET'.
          perform reset_selected_entries changing gt_outtab[].
        when 'SWITCH'.
          perform switch_activation changing gt_outtab[].
      endcase.
    form select_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
    *       you must check the input cells.
    * If all entries are ok, ALV transferes new values to the output
    * table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                             changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = 'X'.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.   
    form check_lock using    ps_outtab type gs_outtab
                    changing p_locked.
      data ls_celltab type lvc_s_styl.
      loop at ps_outtab-celltab into ls_celltab.
        if ls_celltab-fieldname = 'CHECKBOX'.
          if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
            p_locked = 'X'.
          else.
            p_locked = space.
          endif.
        endif.
      endloop.
    endform.       
    form deselect_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
    *       you must check the input cells.
    * If all entries are ok, ALV transferes new values to the output
    * table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                           changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = ' '.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    reward  points if it is usefull ......
    Girish

  • 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

  • On Change or On Toggle Action of Checkbox in ALV

    Hi,
    i have a checkbox column in alv and i want to update database which checkbox of which row is changed so i must create an on changed or on toggle action for checkbox of alv.
    How can i create an on changed or on toggle action for checkbox of alv?
    or is there anyway else?
    Thanks.

    Hi Nurullah,
    This functionality is quite possible. You need to create an event handler method (say for example CHECK_DATA_CHANGE) for the event ON_DATA_CHECK of the ALV.
    You would have to first call the DATA_CHECK method of the ALV component. This method checks if any data has changed in the ALV and then triggers the ON_DATA_CHECK event if it finds that something has changed in the ALV. Create an eventhandler method for the ON_DATA_CHECK method and within this method enable your SAVE button for the user.
    Call this DATA_CHECK method from WDDOAFTERACTION so that whenever any action is performed the system would check if any data has changed in the ALV & then eventually execute your eventhandler method resulting in the button getting enabled. Hope that this is clear for you now.
    method WDDOAFTERACTION .
      DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
      lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).
      lo_interfacecontroller->data_check( ).
    endmethod.
    Regards,
    Uday

  • 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

  • Checkboxes in alv

    Hi ,
    I'm getting runtime error while creating checkboxes in alv.Like this
    ABAP runtime error CONVT_NO_NUMBER.
    Unable to interpret 'X' as a number.
       Report lines are,
        w_fcat-fieldname = 'F'.
        w_fcat-tabname   = 'IG_EK'.
        w_fcat-checkbox   = 'X'.
        w_fcat-outputlen = '5'.
        append w_fcat to g_fcat.
    The field F is of type c,which is declared in the internal table ig_ek.
    Cud u pls help me to come out of this error?
    Thanks

    Hi,
    Check this :
    DATA : BEGIN OF i_filenames OCCURS 0,
            name LIKE epsfili-name,
            sel TYPE char1,
           END OF i_filenames.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'SEL'.
      ls_fcat-outputlen = '000003'.
      ls_fcat-coltext   = 'Selection'.
      ls_fcat-seltext   = 'Selection'.
      ls_fcat-fix_column = 'X'.
      ls_fcat-just      =  'X'.
      ls_fcat-checkbox   = 'X'.
      ls_fcat-edit =       'X'.
      ls_fcat-tabname   = 'I_FILENAMES'.
      APPEND ls_fcat TO p_fieldcat.
    Regards
    L Appana

  • How to read a checkbox in ALV (FM used)

    Hi Experts,
    I have generated an ALV grid using funtion module. There are 9 coloumns with checkbox col at first position. Each row has a checkbox. Now I want to read that particular row for which  the checkbox is checked. Kindly tell me the procedure.
    Points will be awarded...
    Thanks,
    Vishal S.

    Hi
    1. You will have to make the field editable. In the field catalog set the EDIT = 'X' for the check box field.
    2. Once the check box is checked, call the method CHECK_CHANGED_DATA of the grid in the PAI of the screen which will update the internal table. Now, you can just loop at the internal table with a where clause on the check box field.
    loop at itab where checkbox = 'x'.
    endloop.
    same thread...
    Re: Output Format for Amount in SAP Script PO
    Re: Checkbox in ALV
    Steps..
    In the layout you need to have the BOX_FIELDNAME with a value..Let's say BOX
    Declare the same value BOX in the internal table that you display in the output..
    Then if the check box is selected...automatically the internal table will be filled X in the BOX column..
    Check this example..
    TYPE-POOLS: slis.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: s_layout TYPE slis_layout_alv.
    DATA: BEGIN OF itab OCCURS 0,
    icon TYPE icon-id,
    vbeln TYPE vbeln,
    kunnr TYPE kunnr,
    erdat TYPE erdat,
    box TYPE c,
    END OF itab.
    DATA: v_repid TYPE syrepid.
    START-OF-SELECTION.
    Get the data.
    SELECT vbeln kunnr erdat UP TO 100 ROWS
    FROM vbak
    INTO CORRESPONDING FIELDS OF TABLE itab.
    IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'No data found'.
    LEAVE LIST-PROCESSING.
    ENDIF.
    Modify the record with red light.
    itab-icon = '@0A@'.
    MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
    v_repid = sy-repid.
    Get the field catalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '1'.
    s_fieldcatalog-fieldname = 'ICON'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-seltext_l = 'Status'.
    s_fieldcatalog-icon = 'X'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '2'.
    s_fieldcatalog-fieldname = 'VBELN'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'VBELN'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '3'.
    s_fieldcatalog-fieldname = 'KUNNR'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'KUNNR'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '4'.
    s_fieldcatalog-fieldname = 'ERDAT'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'ERDAT'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    Set the layout.
    s_layout-box_fieldname = 'BOX'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    is_layout = s_layout
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = t_fieldcatalog[]
    TABLES
    t_outtab = itab.
    FORM SET_PF_STATUS *
    --> EXTAB *
    FORM set_pf_status USING extab TYPE slis_t_extab.
    SET PF-STATUS 'TEST2'.
    ENDFORM.
    FORM user_command *
    --> UCOMM *
    --> SELFIELD *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
    Check the ucomm.
    IF ucomm = 'DETAIL'.
    LOOP AT itab WHERE box = 'X'.
    itab-icon = '@08@'.
    MODIFY itab TRANSPORTING icon.
    ENDLOOP.
    ENDIF.
    selfield-refresh = 'X'.
    ENDFORM.
    <b>Reward if usefull</b>

  • 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

  • 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

  • ALV Sorting Not Working after Adding Checkbox to ALV

    Hi All.
    I am currently doing an ALV report using REUSE_ALV_GRID_DISPLAY function. I am sorting the list by Employee Name and Personnel Area. It works fine where the personnel are field and employee name field are merger together for same personnel are and employee name. But afterwards I added a checkbox field to the internal table and the list outputs a checkbox for each line. Afer  putting the checkbox the list no long merges the same personnel are and employee name fields according to original sorting.
    Can anyone explain if there is a way to solve this?
    Thanks a lot.
    Lily

    yes there is a way. Just see this..
    There is no Straight forward solution. There is a work around.
    REPORT  ztest_check_box                         .
    TYPE-POOLS: slis,icon.
    DATA: BEGIN OF it_vbap OCCURS 0,
           vbeln LIKE vbap-vbeln,
           matnr LIKE vbap-matnr,
           posnr LIKE vbap-posnr,
           kunnr LIKE vbak-kunnr,
           kwmeng LIKE vbap-kwmeng,
           check TYPE c,
           id TYPE icon-id,
          END OF it_vbap.
    DATA: it_fieldcat  TYPE slis_t_fieldcat_alv.
    DATA:  x_fieldcat  TYPE slis_fieldcat_alv.
    DATA: it_sort TYPE slis_t_sortinfo_alv,
          x_sort TYPE slis_sortinfo_alv.
    SELECT vbak~vbeln
           vbak~kunnr
           vbap~posnr
           vbap~matnr
           vbap~kwmeng
           INTO CORRESPONDING FIELDS OF TABLE it_vbap
           FROM vbak JOIN vbap
           ON vbak~vbeln = vbap~vbeln.
    SORT it_vbap BY matnr.
    DELETE it_vbap WHERE matnr IS INITIAL.
    LOOP AT it_vbap.
      it_vbap-id = '@T9@'.
      MODIFY it_vbap.
    ENDLOOP.
    x_fieldcat-fieldname = 'ID'.
    x_fieldcat-seltext_l = 'CHECK'.
    x_fieldcat-outputlen = 4.
    x_fieldcat-icon  = 'X'.
    x_fieldcat-col_pos   = 1.
    x_fieldcat-hotspot  = 'X'.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'MATNR'.
    x_fieldcat-seltext_l = 'MATNR'.
    x_fieldcat-col_pos   = 2.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'KUNNR'.
    x_fieldcat-seltext_l = 'KUNNR'.
    x_fieldcat-col_pos   = 3.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-col_pos   = 4.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-col_pos   = 5.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'KWMENG'.
    x_fieldcat-seltext_l = 'KWMENG'.
    x_fieldcat-col_pos   = 6.
    x_fieldcat-do_sum   = 'X'.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_sort-fieldname = 'MATNR'.
    x_sort-spos       = 1.
    x_sort-up = 'X'.
    x_sort-group = 'X'.
    x_sort-subtot = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    x_sort-fieldname = 'KUNNR'.
    x_sort-spos       = 2.
    x_sort-up = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    x_sort-fieldname = 'VBELN'.
    x_sort-spos       = 3.
    x_sort-up = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    *DATA:x_layout TYPE lvc_s_layo.
    *x_layout-box_fname = 'CHECK'.
    *x_layout-no_rowmark = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
    *   is_layout          = x_layout
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat        = it_fieldcat
        it_sort            = it_sort
      TABLES
        t_outtab           = it_vbap[]
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
    IF sy-subrc ne 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *&      Form  itab_user_command
    *       text
    *      -->WHATCOMM   text
    *      -->WHATROW    text
    FORM user_command USING whatcomm TYPE sy-ucomm selfield TYPE
    slis_selfield.
      IF selfield-fieldname = 'ID'.
        READ TABLE it_vbap INDEX selfield-tabindex.
        IF sy-subrc = 0.
          IF it_vbap-check = ''.
            it_vbap-id = '@R7@'.
            it_vbap-check = 'X'.
          ELSE.
            it_vbap-id = '@T9@'.
            it_vbap-check = ''.
          ENDIF.
          MODIFY it_vbap INDEX selfield-tabindex.
        ENDIF.
      ENDIF.
      selfield-refresh = 'X'.
    ENDFORM.                    "itab_user_command
    if you want to make the above code to work in lower versions then you have to do this..
    then maintain the ICON using the view V_ICON from SM30 add the New Entry.
    get the properties from the below screen shot.
    http://img404.imageshack.us/img404/3338/testig9.png

  • 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............

  • Need to add checkbox in alv header Not  in grid

    Dear Guru's,
                       My question is i want to add checkbox on top of alv grid ie on top of page .
    my requriement is for SD module- status of order -Mass Update.
    suppose status checkbox on header is HFSC is checked ( check box),
    for all the sales order which are showed on the alv grid must be updated with this status for which i am calling trasaction VA02 in program and doing changes but i am not able to create checkbox on header .
    Again i have already used ALV without classesso please give me solution accordinglly . Thanks in advance.

    Hi,
    For working with top of page we generally use SLIS_LISTHEADER right.
    In this type the first field is
    type - which can accept values as follows
               H - Heading
               S - Selection
               A - Action
    May be the options Selection or Action may help u.

  • How to  select multiple chek in checkbox in alv

    how to  select multiple chek in checkbox in alv

    Hi,
    Following report is the checkbox alv sample report.
    REPORT  YMS_CHECKBOXALV.
    TYPE-POOLS: slis.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: s_layout TYPE slis_layout_alv.
    DATA: BEGIN OF itab OCCURS 0,
    icon TYPE icon-id,
    vbeln TYPE vbeln,
    kunnr TYPE kunnr,
    erdat TYPE erdat,
    box TYPE c,
    END OF itab.
    DATA: v_repid TYPE syrepid.
    START-OF-SELECTION.
    Get the data.
    SELECT vbeln kunnr erdat UP TO 100 ROWS
    FROM vbak
    INTO CORRESPONDING FIELDS OF TABLE itab.
    IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'No data found'.
    LEAVE LIST-PROCESSING.
    ENDIF.
    Modify the record with red light.
    itab-icon = '@0A@'.
    MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
    v_repid = sy-repid.
    Get the field catalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '1'.
    s_fieldcatalog-fieldname = 'ICON'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-seltext_l = 'Status'.
    s_fieldcatalog-icon = 'X'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '2'.
    s_fieldcatalog-fieldname = 'VBELN'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'VBELN'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '3'.
    s_fieldcatalog-fieldname = 'KUNNR'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'KUNNR'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '4'.
    s_fieldcatalog-fieldname = 'ERDAT'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'ERDAT'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    Set the layout.
    s_layout-box_fieldname = 'BOX'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    is_layout = s_layout
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = t_fieldcatalog[]
    TABLES
    t_outtab = itab.
    FORM SET_PF_STATUS *
    --> EXTAB *
    FORM set_pf_status USING extab TYPE slis_t_extab.
    SET PF-STATUS 'TEST2'.
    ENDFORM.
    FORM user_command *
    --> UCOMM *
    --> SELFIELD *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
    Check the ucomm.
    IF ucomm = 'DETAIL'.
    LOOP AT itab WHERE box = 'X'.
    itab-icon = '@08@'.
    MODIFY itab TRANSPORTING icon.
    ENDLOOP.
    ENDIF.
    selfield-refresh = 'X'.
    ENDFORM.
    Thanks,
    Sankar M

Maybe you are looking for

  • USB Driver for IOS 7

    After updating to IOS 7, I no longer can see my iPhone as a USB Drive on my PC, Windows 8 64bit Pro. Are there new USB Drivers that I have to install ?

  • Sort by Path and Filename - What does a guy have to do?

    Hello all, First post here and such, but as the title reads. I have been using iTunes since early versions of 7 when I aquired my used 2gen Mini. In a past incident where people were attaching viruses to the ID3 Tags (see: http://en.wikipedia.org/wik

  • My Skype Number is not working!!! HELP

    been trying to call my skype number +xxx xxx xxxx all my business contacts are trying to call but it keeps saying user is busy. i dunt get it Solved! Go to Solution.

  • I imported my music to itunes from my phone and now itunes wont open

    Process:         iTunes [461] Path:            /Applications/iTunes.app/Contents/MacOS/iTunes Identifier:      com.apple.iTunes Version:         10.6 (10.6) Build Info:      iTunes-10604001~1 Code Type:       X86 (Native) Parent Process:  launchd [87

  • Printer needs static IP address - I think I know what to do, but not sure

    I got a new HP 8500A wireless network printer. I have used a US Robotics MAXg wireless router (Model 5461A) for years with zero issues. I have 2 Windows XP PRO computers, and 1 Windows 7 Home Premium. (Plus the Wii, a Kindle, Blu-Ray player, and coup