ALV grid check box

Hi,
I am using ALV gid with FM 'REUSE_ALV_GRID_DISPLAY_LVC'. I am displaying a check box on the screen. I have to know how many check box were selected.
Any idea how to get that.
I have used lay-box_fnname = checkbox and looped the itab in user command. But I am not getting the desired result. Please lte me know how its managed.
KK.

REPORT ZALV_DISPLAY_CHANGE.
TABLES :T247.
TYPE-POOLS SLIS. "Type definitions for alv report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT.
DATA: WA_LAYOUT TYPE LVC_S_LAYO.
DATA : BEGIN OF IT_FINAL OCCURS 0,
CHECK(1),
CELLTAB TYPE LVC_T_STYL, " Switch between display/change
MNR LIKE T247-MNR,
LTX LIKE T247-LTX,
END OF IT_FINAL.
DATA : WA_FINAL LIKE IT_FINAL.
DATA : W_REPID LIKE SY-REPID.
W_REPID = SY-REPID.
REFRESH IT_FINAL.
SELECT MNR LTX
FROM T247
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
WHERE SPRAS EQ 'E'.
WA_FIELDCAT-FIELDNAME = 'CHECK'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = 'X'..
WA_FIELDCAT-OUTPUTLEN = '3'.
WA_FIELDCAT-COL_POS = '1'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'MNR'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-OUTPUTLEN = '8'.
WA_FIELDCAT-COL_POS = '2'.
WA_FIELDCAT-REPTEXT = 'Month'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'LTX'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-OUTPUTLEN = '20'.
WA_FIELDCAT-COL_POS = '3'.
WA_FIELDCAT-REPTEXT = 'Month Desc'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
DATA: WA_CELLTAB TYPE LVC_S_STYL,
IT_CELLTAB TYPE LVC_T_STYL,
L_INDEX TYPE I.
CLEAR : WA_CELLTAB,WA_FINAL,IT_CELLTAB.
REFRESH IT_CELLTAB.
*Initialize the celltab table
LOOP AT IT_FINAL INTO WA_FINAL.
L_INDEX = SY-TABIX.
WA_CELLTAB-FIELDNAME = 'CHECK'.
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
INSERT WA_CELLTAB INTO TABLE IT_CELLTAB.
INSERT LINES OF IT_CELLTAB INTO TABLE WA_FINAL-CELLTAB.
MODIFY IT_FINAL FROM WA_FINAL INDEX L_INDEX.
ENDLOOP.
*Make the first five 5 rows as disabled
CLEAR L_INDEX.
LOOP AT IT_FINAL INTO WA_FINAL.
L_INDEX = SY-TABIX.
IF SY-TABIX LE 5.
LOOP AT WA_FINAL-CELLTAB INTO WA_CELLTAB.
IF WA_CELLTAB-FIELDNAME EQ 'CHECK' .
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
MODIFY WA_FINAL-CELLTAB FROM WA_CELLTAB.
MODIFY IT_FINAL INDEX L_INDEX FROM WA_FINAL TRANSPORTING CELLTAB.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
WA_LAYOUT-BOX_FNAME = 'CHECK'.
WA_LAYOUT-NO_ROWMARK = 'X'.
WA_LAYOUT-STYLEFNAME = 'CELLTAB'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_GRID_TITLE = 'GRID DISPLAY'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
                        P_SELFLD TYPE SLIS_SELFIELD.
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
CASE P_UCOMM.
  WHEN 'DELETE'.
      loop at it_final where check eq 'X'.
        count = count + 1.                       " Counts the no of checked records
      endloop.
ENDCASE.
ENDFORM.

Similar Messages

  • ALV GRID - check box functionality

    Hello all,
    In ALV GRID display I want to have check box as the first column. I should be able to select some records using this checkbox and identify the selected records on USER_COMMAND. Could some one post some sample code to do this?
    Thanks,

    Check this [thread|How to select a row using a checkbox in ALV Grid??;

  • ALV with Check Boxes

    Can I get a sample program of ALV (oops) with check boxes in it. thank you.

    Types: begin of lt_io.
    include structure mara. " Your Structure
    Types: style_table type lvc_t_style.
    Types: end of lt_io.
    data: lt_io type table of lt_io,
    ls_layout type lvc_s_layo,
    lt_fcat type lvc_t_fcat,
    lo_grid type ref to cl_gui_alv_grid.
    field-symbols: <io> type lt_io,
    <fcat> type lvc_s_fcat.
    ... fill your output table ....
    ls_layout-stylefname = 'STYLE_TABLE'.
    loop at lt_io assigning <io>.
    PERFORM set_style USING 'CHECKBOX' "Your Filename
    CHANGING <io>.
    endloop.
    ... Fill Your Field Catalog lt_fcat
    read table lt_fcat assigning <fcat>
    where fieldname = 'CHECKBOX'.
    <fcat>-checkbox = 'X'.
    create grid control lo_grid.
    CALL METHOD lo_grid->set_table_for_first_display
    EXPORTING
    is_layout = ls_layout
    CHANGING
    it_fieldcatalog = lt_fcat
    it_outtab = lt_io[].
    FORM set_button_to_line
    USING iv_fieldname TYPE lvc_fname
    CHANGING cs_io TYPE io.
    DATA: ls_style TYPE lvc_s_styl,
    lt_style TYPE lvc_t_styl.
    ls_style-fieldname = iv_fieldname.
    if cs_io-checkbox = ' '.
    ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
    else.
    ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
    endif.
    ls_style-maxlen = 2.
    INSERT ls_style INTO TABLE io-style_table.
    ENDFORM. "set_icon_to_status_line
    [/code].
    A classical report is a program that generates a single list, which must contain all of the required detail information.
    1) This procedure may result in extensive lists from which the user has to pick the relevant data.
    2) For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program.
    3) The desired selections must be made beforehand and the list must provide detailed information.
    4) For dialog sessions, there are no such restrictions.
    5) The user is present during the execution of the program and can control and manipulate the program flow directly.
    6) To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.
    ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.
    Advantages.
    Collapse multiple reports into one, drastically cutting down your report development time
    Save many hours using built-in ALV sorting, subtotaling and filtering capabilities
    Add conditional structures into your ALV report: No programming required!
    Combine ALV with display variants to meet a wide range of reporting requirements more easily
    Dynamically reorder column layouts and add/subtract fields
    Enable users and analysts to save their own personalized variants
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    declarations for spl.group.
    GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV
    GT_SORT TYPE SLIS_T_SORTINFO_ALV, "for sort
    DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
      CLEAR LS_SORT.
      LS_SORT-FIELDNAME = 'FIELD1'.
      LS_SORT-SPOS      = 1.
      LS_SORT-UP        = 'X'.
      ls_sort-subtot    = 'X'. "subtotal
      APPEND LS_SORT TO E06_LT_SORT.
      APPEND LS_SORT TO E06_LT_SORT.
      LS_SORT-FIELDNAME = 'FIELD2'.
      LS_SORT-SPOS      = 2.
      LS_SORT-UP        = 'X'.
      ls_sort-subtot    = 'X'. "subtotal
      APPEND LS_SORT TO E06_LT_SORT.
    for creating the group..
      DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
      CLEAR  LS_SP_GROUP.
      LS_SP_GROUP-SP_GROUP = 'A'.
      LS_SP_GROUP-TEXT     = TEXT-005.
      APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
    and pass this info to FM...
    layout-sUBTOTALS_TEXT = 'SUbt...'
    and pass spl group info to fieldcatalog also...
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM      = G_REPID
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
                IT_SPECIAL_GROUPS       = GT_SP_GROUP[]
                IT_SORT                 = GT_SORT[]
    TYPES :
      BEGIN OF ty_vbak,
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        vbeln TYPE vbak-vbeln,             " Sales document
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
        waerk TYPE vbak-waerk,             " Document currency
      END OF ty_vbak.
    DATA:
      vbak    TYPE vbak,
      gt_vbak TYPE TABLE OF ty_vbak.
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
         Form  f_read_data
    FORM f_read_data.
      SELECT vkorg kunnr vbeln netwr waerk
          UP TO p_max ROWS
        INTO TABLE gt_vbak
        FROM vbak
       WHERE kunnr IN s_kunnr
         AND vbeln IN s_vbeln
         AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
         Form  f_display_data
    FORM f_display_data.
      TYPE-POOLS: slis.                    " ALV Global types
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                  
    Check out these sample programs
    BCALV_GRID_01
    This program illustrates how the events for print processing PRINT_TOP_OF_PAGE,
    PRINT_END_OF_PAGE, PRINT_TOP_OF_LIST,PRINT_END_OF_LIST are handled. The
    corresponding handler methods control the appearance of the list printed.
    BCALV_GRID_02
    Show a detail list in an amodal window. There is no second dynro needed in contrast to
    BCALV_GRID_03.
    BCALV_GRID_03
    This program implements a function on event DOUBLE_CLICK. According to the selected line data
    from table SBOOK is selected and displayed by a second ALV Control in a dialog dynpro.
    BCALV_GRID_04
    Illustrates the use of exceptions (lights or leds). According to the values of SFLIGHT-SEATSOCC, the
    lights are set to 1 (red), 2 (yellow) or 3 (green).
    BCALV_GRID_05
    Demonstrate the creation of an own toolbar button.
    BCALV_GRID_06
    Demonstrate the creation of an own context menu.
    BCALV_GRID_07
    Append a menu button to the standard toolbar.
    BCALV_GRID_08
    Append a menu with default button to the standard toolbar. It is exactly the same as
    BCALVC_TB_WITH_MENU except for methods HANDLE_MENU_BUTTON and HANDLE_TOOLBAR.
    Editable ALV grids
    BCALV_EDIT_01
    This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
    BCALV_EDIT_02
    This report illustrates how to set chosen cells of an ALV Grid Control editable.
    BCALV_EDIT_03
    In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
    The report checks the input value(s) semantically and provides protocol messages in case of error
    BCALV_EDIT_04
    This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
    implement the saving of the new data.
    BCALV_EDIT_05
    This example shows how to use checkboxes within an ALV Grid Control. You learn:
    (1) how to define a column for editable checkboxes for an attribute of your list
    (2) how to evaluate the checked checkboxes
    (3) how to switch between editable and non-editable checkboxes
    BCALV_EDIT_06
    This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
    Grid Control.
    BCALV_EDIT_07
    This example shows how to define dropdown listboxes for particular cells of your output table.
    BCALV_EDIT_08
    This report implements an ALV Grid Control with an application specific F4 help. The following aspects
    are dealt with:
    (1) how to replace the standard f4 help
    (2) how to pass the selected value to the ALV Grid Control
    (3) how to build an f4 help, whose value range depend on a value of another cell.
    Check this link tooo
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/07/23/oopsALVin+ABAP&showComments=true
    The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
    standardized format. The list data is displayed as a table on the screen.
    The ALV Grid Control offers a range of interactive standard list functions that users need
    frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
    export list (in different formats), and so on. These functions are implemented in the
    proxy object class. You as the programmer have the possibility to turn off functions not
    needed. In most cases the implementations of the standard functions provided by the
    control are sufficient. However, if required, you can adjust these implementations to
    meet application-specific needs.
    You can add self-defined functions to the toolbar, if necessary.
    The ALV Grid Control allows users to adjust the layout of lists to meet their individual
    requirements (for example, they can swap columns, hide columns, set filters for the
    data to be displayed, calculate totals, and so on). The settings (list customizing) made
    by a specific user are called a display variant. Display variants can be saved on a userspecific
    or on a global basis. If such display variants exist for a list, they can be offered
    to the user for selection. If a display variant is set as the default variant, the associated
    list is always displayed based on the settings of this variant.
    2. REUSE_ALV_LIST_DISPLAY
    REUSE_ALV_GRID_DISPLAY
    REUSE_ALV_FIELDCATALOG_MERGE
    REUSE_ALV_COMMENTARY_WRITE
    3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
    6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
    7.fieldcat-fieldname
    fieldcat-ref_fieldname
    fieldcat-tabname
    fieldcat-seltext_m
    5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
    Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
    In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
    The report output can contain up to 90 columns in the display with the wide array of display options.
    The commonly used ALV functions used for this purpose are;
    1. REUSE_ALV_VARIANT_DEFAULT_GET
    2. REUSE_ALV_VARIANT_F4
    3. REUSE_ALV_VARIANT_EXISTENCE
    4. REUSE_ALV_EVENTS_GET
    5. REUSE_ALV_COMMENTARY_WRITE
    6. REUSE_ALV_FIELDCATALOG_MERGE
    7. REUSE_ALV_LIST_DISPLAY
    8. REUSE_ALV_GRID_DISPLAY
    9. REUSE_ALV_POPUP_TO_SELECT
    Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
    But either no.7 or No.8 is there in the Program.
    How you call this function in your report?
    After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
    Then use follwing function module.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = 'Prog.name'
    I_STRUCTURE_NAME = 'I_ITAB'
    I_DEFAULT = 'X'
    I_SAVE = 'A'
    TABLES
    T_OUTTAB = I_ITAB.
    IF SY-SUBRC <> 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC .
    ENDIF.
    ENDFORM. " GET_FINAL_DATA
    The object F_IT_ALV has a field, the activity ACTVT, which can
    contain four permitted values: 01, 02, 03 and 70. Each of the
    activities 01, 02 and 70 controls the availability of particular
    functions (in the menu and the toolbar) of the ALV line item list:
    a) 01: "Settings -> Display variant -> Save..."
    b) 02: "Settings -> Display variant -> Current..." and
    "Settings -> Display variant -> Current header rows "
    c) 70: "Settings -> Display variant -> Administration..."
    Activity 03 corresponds to the minimum authorization, which is the
    most restricted one: The user can only select layouts which have
    been configured already. In particular, all of the other functions
    named above are inactive with activity 03.
    Now if you want to permit a user to change the column selection and
    the headers as well as to save the layout thus created, for example,
    but if you do not want to permit the user to administrate the
    layouts, you grant him or her the authorization for activities 01
    and 02.
    Check this link it will be mosty usefull for u
    http://www.sap-img.com/fu017.htm
    check this link
    http://abapprogramming.blogspot.com/
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
    Changing width of a custom container dynamically
    Display Page numbers in ALV
    Insert picture in selection screen.
    Logo in OO ALV Grid
    check these links
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    Try these links
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. 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
    For More alv report examples check these Tcodes LIBS, BIBS Here u can find more number of examples on alv reports of different kinds
    check this sample code for intercative alv report
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           BUKRS LIKE EKKO-BUKRS,
           BSART LIKE EKKO-BSART,
           LIFNR LIKE EKKO-LIFNR,
           END OF I_EKKO.
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
          WA_EKKO TYPE I_EKKO.
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           NETPR LIKE EKPO-NETPR,
           END OF I_EKPO.
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE I_EKPO .
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    declaration for events table where user comand or set PF status will
    be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT.
    declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
          I_VARIANT1 TYPE DISVARIANT,
          I_SAVE(1) TYPE C.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    DATA:  I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA:  I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    INITIALIZATION.
      V_REPID = SY-REPID.
      PERFORM BUILD_FIELDCATLOG.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATLOG
          Fieldcatalog has all the field details from ekko
    FORM BUILD_FIELDCATLOG.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'AEDAT'.
      WA_FIELDCAT-SELTEXT_M = 'DATE.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'LIFNR'.
      WA_FIELDCAT-NO_OUT    = 'X'.
      WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG
    *&      Form  EVENT_CALL
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    EXCEPTIONS
       LIST_TYPE_WRONG       = 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.                    "EVENT_CALL
    *&      Form  POPULATE_EVENT
         Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'USER_COMMAND'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-NAME.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    *&      Form  data_retrieval
      retreiving values from the database table ekko
    FORM DATA_RETRIEVAL.
      SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    ENDFORM.                    "data_retrieval
    *&      Form  bUild_listheader
          text
         -->I_LISTHEADEtext
    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA HLINE TYPE SLIS_LISTHEADER.
      HLINE-INFO = 'this is my first alv pgm'.
      HLINE-TYP = 'H'.
    ENDFORM.                    "build_listheader
    *&      Form  display_alv_report
          text
    FORM DISPLAY_ALV_REPORT.
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = V_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
         I_GRID_TITLE                      = I_TITLE_EKKO
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = ALV_LAYOUT
         IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
        i_default                         = 'ZLAY1'
         I_SAVE                            = 'A'
        is_variant                        = i_variant
         IT_EVENTS                         = V_EVENTS
        TABLES
          T_OUTTAB                          = IT_EKKO
    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_alv_report
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
       i_logo                   =
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
          PERFORM BUILD_FIELDCATLOG_EKPO.
          PERFORM EVENT_CALL_EKPO.
          PERFORM POPULATE_EVENT_EKPO.
          PERFORM DATA_RETRIEVAL_EKPO.
          PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
          PERFORM DISPLAY_ALV_EKPO.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  BUILD_FIELDCATLOG_EKPO
          text
    FORM BUILD_FIELDCATLOG_EKPO.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELP'.
      WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MENGE'.
      WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-SELTEXT_M = 'UOM'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'NETPR'.
      WA_FIELDCAT-SELTEXT_M = 'PRICE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG_EKPO
    *&      Form  event_call_ekpo
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL_EKPO.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH

  • ALV - Desactivate Check box on a specific line

    Hello all,
    I need your help for desactivate my checkbox on ALV GRID on specific line.
    See on the screen shot on the link :
    http://www.casimages.com/img.php?i=101006040322252671.jpg
    See the implementation of my ALV and my Catalog :
    g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  type ref to cl_gui_alv_grid,
          g_custom_container type ref to cl_gui_custom_container,
          g_event_receiver type ref to lcl_event_receiver,
          gt_fieldcat type lvc_t_fcat,
          gs_layout type lvc_s_layo.
    types: begin of gs_outtab.
    types: checkbox type c.                "field for checkbox
    * §B1.Extend your output table by a field to dis- or enable
    *     cells for input.
    types: celltab type lvc_t_styl.        "field to switch editability
            include structure zpvprevmaj.
    types: end of gs_outtab.
    form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'ZPVPREVMAJ'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
    *§A2.Add an entry for the checkbox in the fieldcatalog
      clear ls_fcat.
      ls_fcat-fieldname = 'CHECKBOX'.
    * Essential: declare field as checkbox and
    *            mark it as editable field:
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
    * do not forget to provide texts for this extra field
      ls_fcat-coltext = text-f01.
      ls_fcat-tooltip = text-f02.
      ls_fcat-seltext = text-f03.
    * optional: set column width
      ls_fcat-outputlen = 2.
      append ls_fcat to pt_fieldcat.
    endform.                    "build_field
    gs_layout-stylefname = 'CELLTAB'.
      gs_layout-info_fname = 'LINE_COLOR'.
      perform color_line.
      call method g_grid->set_table_for_first_display
        EXPORTING
          is_layout            = gs_layout
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = gt_fieldcat
          it_outtab            = gt_outtab[].
          "it_sort              = it_sortcat.
    Thank you very much for your answers
    Edited by: Emilien P. on Oct 6, 2010 4:10 PM
    Edited by: Emilien P. on Oct 6, 2010 4:13 PM

    I think is no possible with the style i try a little tutorial. I have test the style for normal cell  and in comment i test with the check box and the checkbox always display !! :
    You can easly test this program in SAP and if anyone arrive to no display the checkbox in line 6, he will be my god Thank you :
    report ZCO_AFFACT_TEST.
    TYPE-POOLS: SLIS.
    *- Fieldcatalog
    DATA: IT_FIELDCAT TYPE LVC_T_FCAT.
    DATA: X_FIELDCAT TYPE LVC_S_FCAT.
    DATA: X_LAYOUT TYPE LVC_S_LAYO.
    " FOR DISABLE
    DATA: LS_EDIT TYPE LVC_S_STYL,
    LT_EDIT TYPE LVC_T_STYL.
    " FOR DISABLE
    DATA: BEGIN OF IT_VBAP OCCURS 0,
    VBELN LIKE VBAP-VBELN,
    POSNR LIKE VBAP-POSNR,
    STYLE TYPE LVC_T_STYL, "FOR DISABLE
    END OF IT_VBAP.
    DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
    SELECT VBELN
    POSNR
    UP TO 10 ROWS
    INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
    FROM VBAP.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'VBELN'.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    "Delete commentary for test with check box.
    "X_FIELDCAT-CHECKBOX = 'X'.
    X_FIELDCAT-OUTPUTLEN = '10'.
    x_fieldcat-ref_field = 'VBELN'.
    x_fieldcat-ref_table = 'VBAK'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'POSNR'.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '5'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    "FOR DISABLE HERE 6ROW IS DISABLED
    SY-TABIX = 6.
    LS_EDIT-FIELDNAME = 'VBELN'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 10.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    LS_EDIT-FIELDNAME = 'POSNR'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 6.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-STYLE.
    MODIFY IT_VBAP INDEX SY-TABIX FROM LS_OUTTAB TRANSPORTING
    STYLE .
    X_LAYOUT-STYLEFNAME = 'STYLE'.
    " UP TO HERE
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        IS_LAYOUT_LVC      = X_LAYOUT
        IT_FIELDCAT_LVC    = IT_FIELDCAT
      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.
    Edited by: Emilien P. on Oct 7, 2010 3:09 PM

  • ALV with Check Box

    Hi Experts,
    I have an ALV grid display with check box.
    I need to display the ALV with only check box. I don't need the Grid towards the left.
    So can anyone tell me how to avoid the Grid which is at the left.
    I am using "REUSE_ALV_GRID_DISPLAY" Function Module.
    Thanks,
    Karthik MD

    Hi,
    I am pasted my code below.
    wa_fieldcat_s-fieldname = 'FLAG'.
    wa_fieldcat_s-outputlen = 1.
      wa_fieldcat_s-checkbox = c_check.
      wa_fieldcat_s-edit = c_check.
      wa_fieldcat_s-col_pos = 1.
      wa_fieldcat_s-seltext_l = 'Select'.
    wa_fieldcat_s-no_out = 'X'.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'SRID'.
      wa_fieldcat_s-key = 'X'.
      wa_fieldcat_s-fix_column = 'X'.
      wa_fieldcat_s-seltext_l = 'SR Global ID'(101).
      wa_fieldcat_s-col_pos = 2.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'PERNR'.
      wa_fieldcat_s-seltext_l = 'Employee Number'(102).
      wa_fieldcat_s-col_pos = 3.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'ZZAGREEMENT_ID'.
      wa_fieldcat_s-seltext_l = 'Agreement ID'(103).
      wa_fieldcat_s-col_pos = 4.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'IT0041ENDDA'.
      wa_fieldcat_s-seltext_l = 'HCMS END DATE'(104).
      wa_fieldcat_s-col_pos = 5.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'ASSIGN_END_DATE'.
      wa_fieldcat_s-seltext_l = 'Assignment End Date'(105).
      wa_fieldcat_s-col_pos = 6.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'FNAME'.
      wa_fieldcat_s-seltext_l = 'First Name'(106).
      wa_fieldcat_s-col_pos = 7.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
      wa_fieldcat_s-fieldname = 'LNAME'.
      wa_fieldcat_s-seltext_l = 'Last Name'(106).
      wa_fieldcat_s-col_pos = 8.
      APPEND wa_fieldcat_s TO fieldcat_s.
      CLEAR wa_fieldcat_s.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program       = prog_name
            i_callback_pf_status_set = 'PF_STATUS'
            i_callback_user_command  = 'USER_COMMAND'
            is_layout                = l_layout
            it_fieldcat              = fieldcat_s[]
            it_events                = t_events[]
            i_save                   = 'X'
          TABLES
            t_outtab                 = lt_final
          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.
    Thanks,
    Karthik MD

  • Alv grid dropdown boxes

    hi friends pls tell
    its urgent
    HOW TO PROVIDE DROP OWN BOXES IN ALV GRID FOR PARTICULAR COLUMN OR CELL  .

    check the below links
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm
    dropdown list on screen
    mark the helpful answers
    ~~Guduri

  • ALV-Grid list box in Cell Event when a value is selected

    Hello to all,
    I've got a editable alv grid with a list box in one cell.
    Is there any event fired after user selection in order to update other cells?
    A workaround may be to use event "data_changed" but I think this isn't a smart way.
    Any ideas?
    Best regards
    Christian

    Hi Christian,
    I think data_changed is right one here, as this one has is recording couple "states":
    METHODS: handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
                                  IMPORTING er_data_changed e_onf4 e_onf4_before e_onf4_after,
    "these are fired up in different "state" of control during selection itself
    "e_onF4
    "e_onf4_before
    "e_onf4_after
    You can. however, try with handle_on_f4 . This works fine for input help, I didn't test it for listbox but should work as well. First you need to register this event with:
    DATA: lt_fields_f4 TYPE lvc_t_f4,
            ls_fields_f4 TYPE lvc_s_f4.
    "activate event F4 only for particular fields
      ls_fields_f4-fieldname = 'SEATSMAX_F'.
      ls_fields_f4-register = 'X'.
      ls_fields_f4-getbefore = 'X'.
      ls_fields_f4-chngeafter = 'X'.
      APPEND ls_fields_f4 TO lt_fields_f4.
      CALL METHOD g_alv_grid_ref->register_f4_for_fields
        EXPORTING
          it_f4 = lt_fields_f4[].
    ...and then just method handler
    METHODS: handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
                               IMPORTING e_fieldname e_fieldvalue er_event_data,
    SET HANDLER ...
    Regards
    Marcin

  • Alv with check box issue

    Hello Friends,
    Im using alv with checkbox and im getting selected checkbox values in my internal table but now i want to pass this internal table to another transaction and want to display the same in table control in screen painter.
    also when the user tick the checkbox in the alv grid and click on save button i want tht screen should disappear how can we achieve this?
    pls suggest?
    Regards,
    Sunny

    Hi,
    Check with the following link.
    http://help.sap.com/saphelp_nw04/helpdata/en/26/46fb40f17af66fe10000000a1550b0/content.htm
    ALV GRID update internal table
    Regards,
    Neelima.

  • ALV with check boxs and buttons

    Hi guys,
    It's been a while since last time I used ALV and its options.
    I have a requirement to show many records in ALV format. each record starts with a check box, user can choose which record by checking each and click on a button to merge them (those record contain text). Everything should show up on ALV screen. Any idea what how should I do that??
    I think I should use screen painter but I have no idea how to implement that...
    Thanks,

    Hi Ben,
    Here is the code as per ur requirement ..
    just go through this....i hope u will get some help...
    REPORT zashu_alv_in_popup_mara.
    TYPE-POOLS : slis.
    *Data Declaration
    DATA:i_repid LIKE sy-repid.
         i_repid = sy-repid.
    Declaration for ALV
    DATA: wa_fcat TYPE slis_fieldcat_alv,
          fcat TYPE slis_t_fieldcat_alv,
          wa_fcat1 TYPE slis_fieldcat_alv,
          fcat1 TYPE slis_t_fieldcat_alv.
    *Types Declaration
    TYPES:BEGIN OF ty_mat,
           matnr TYPE mara-matnr,
           checkbox(1),
          END OF ty_mat.
    TYPES:BEGIN OF ty_makt,
           matnr TYPE mara-matnr,
           maktg  TYPE makt-maktg,
           maktx  TYPE makt-maktx,
          END OF ty_makt.
    *Internal table Declaration
    DATA:it_mat TYPE TABLE OF ty_mat WITH HEADER LINE.
    DATA:it_makt TYPE TABLE OF ty_makt WITH HEADER LINE.
    *Range Declaration
    RANGES : r_matnr FOR mara-matnr.
    *Start of Selecdtion
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display_data.
      PERFORM display_alv.
         Form  get_data
    FORM get_data.
    Read material from MARA
      SELECT matnr FROM mara INTO TABLE it_mat.
    ENDFORM.                               " GET_DATA
         Form  display_data
    FORM display_data.
      wa_fcat-row_pos   = '1'.
      wa_fcat-col_pos   = '1'.
      wa_fcat-fieldname = 'CHECKBOX'.
      wa_fcat-tabname   = 'IT_MAT'.
      wa_fcat-seltext_m = 'SELECT'.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      wa_fcat-row_pos   = '1'.
      wa_fcat-col_pos   = '2'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-tabname   = 'IT_MAT'.
      wa_fcat-seltext_m = 'MATERIAL'.
      wa_fcat-outputlen = 50.
      APPEND wa_fcat TO fcat.
    Display data in a POPUP
      CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
           EXPORTING
                i_selection          = 'X'
                i_zebra              = 'X'
                it_fieldcat          = fcat
                i_tabname            = 'IT_MAT'
                 i_checkbox_fieldname = 'CHECKBOX'
           TABLES
                t_outtab             = it_mat.
    IF NOT it_mat[] IS INITIAL.
    LOOP AT it_mat  WHERE checkbox = 'X'.
            r_matnr-sign = 'I'.
            r_matnr-option = 'EQ'.
            r_matnr-low = it_mat-matnr.
            r_matnr-high = ' '  .
            APPEND r_matnr.
            CLEAR r_matnr.
          ENDLOOP.
        ENDIF.
    select matnr maktx maktg from makt  into table it_makt where matnr in
    r_matnr.
    ENDFORM.                               " DISPLAY_DATA
    *&      Form  DISPLAY_ALV
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    *ALV Display in a POPUP window
      wa_fcat1-row_pos   = '1'.
      wa_fcat1-col_pos   = '1'.
      wa_fcat1-fieldname = 'MATNR'.
      wa_fcat1-tabname   = 'IT_MAKT'.
      wa_fcat1-seltext_m = 'Material No'.
      APPEND wa_fcat1 TO fcat1.
      CLEAR wa_fcat.
      wa_fcat1-row_pos   = '1'.
      wa_fcat1-col_pos   = '2'.
      wa_fcat1-fieldname = 'MAKTX'.
      wa_fcat1-tabname   = 'IT_MAKT'.
      wa_fcat1-seltext_m = 'DESCRIPTION'.
      APPEND wa_fcat1 TO fcat1.
      wa_fcat1-row_pos   = '1'.
      wa_fcat1-col_pos   = '3'.
      wa_fcat1-fieldname = 'MAKTG'.
      wa_fcat1-tabname   = 'IT_MAKT'.
      wa_fcat1-seltext_m = 'GROUP'.
      APPEND wa_fcat1 TO fcat1.
      CLEAR wa_fcat1.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = i_repid
         i_grid_title                      = 'Material Description'
         it_fieldcat                       = fcat1
      I_SCREEN_START_COLUMN             = 30
      I_SCREEN_START_LINE               = 10
      I_SCREEN_END_COLUMN               = 70
      I_SCREEN_END_LINE                 = 30
        TABLES
          t_outtab                        = it_makt
    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_ALV
    Thanks & Regards
    Ashu SIngh

  • Check box with alv

    hi
    i am displaying  list alv with check boxes, now i want to select few check boxes and doing some operation, after this operation i need to disable thoese check box.
    can u pls guide me.
    thanks.

    Hi,
    using styles it is possible.
    first you need to declare the one extra field in the internal table..
    1. HANDLE_STYLE TYPE LVC_T_STYL.
    DECLARE work area,and table
    2.  DATA: LS_EDIT TYPE LVC_S_STYL,
            LT_EDIT TYPE LVC_T_STYL.
    changing the style...
    3.
    LOOP AT IT_FINAL INTO LS_OUTTAB WHERE FLAG = 'X'.
        V_INDEX = SY-TABIX.
        LS_EDIT-FIELDNAME = 'MATNR'.
        LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
        LS_EDIT-STYLE2 = SPACE.
        LS_EDIT-STYLE3 = SPACE.
        LS_EDIT-STYLE4 = SPACE.
        LS_EDIT-MAXLEN = 8.
        INSERT LS_EDIT INTO TABLE LT_EDIT.
        LS_EDIT-FIELDNAME = 'VBELN'.
        LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENAABLED.
        LS_EDIT-STYLE2 = SPACE.
        LS_EDIT-STYLE3 = SPACE.
        LS_EDIT-STYLE4 = SPACE.
        LS_EDIT-MAXLEN = 8.
        INSERT LS_EDIT INTO TABLE LT_EDIT.
        LS_EDIT-FIELDNAME = 'POSNR'.
        LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
        LS_EDIT-STYLE2 = SPACE.
        LS_EDIT-STYLE3 = SPACE.
        LS_EDIT-STYLE4 = SPACE.
        LS_EDIT-MAXLEN = 8.
        INSERT LS_EDIT INTO TABLE LT_EDIT.
        INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
        MODIFY IT_FINAL INDEX V_INDEX FROM LS_OUTTAB  TRANSPORTING
                                          HANDLE_STYLE .
      ENDLOOP.
    assigning the style to Layout..
    4.   GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
    REUSE_ALV_GRID_DISPLAY_LVC. you can do the same with CL_GUI_ALV_GRID also.
    REPORT ZTESTALV.
    TYPE-POOLS: SLIS.
    *- Fieldcatalog
    DATA: IT_FIELDCAT  TYPE LVC_T_FCAT,
          IT_FIELDCAT1  TYPE SLIS_T_FIELDCAT_ALV..
    *- For Events
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    DATA:  X_FIELDCAT  TYPE LVC_S_FCAT,
            X_FIELDCAT1  TYPE SLIS_FIELDCAT_ALV.
    DATA:X_LAYOUT TYPE LVC_S_LAYO.
    "{ FOR DISABLE
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    "} FOR DISABLE
    DATA: BEGIN OF IT_VBAP OCCURS 0,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          HANDLE_STYLE TYPE LVC_T_STYL, "FOR DISABLE
          BUTTON(10),
         END OF IT_VBAP.
    DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
    SELECT VBELN
           POSNR
           UP TO 10 ROWS
          INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
          FROM VBAP.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'VBELN'.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    *X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '10'.
    x_fieldcat-ref_field = 'VBELN'.
    x_fieldcat-ref_table = 'VBAK'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'POSNR'.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    *X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '5'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    "{FOR DISABLE HERE 6ROW IS DISABLED
    SY-TABIX = 6.
    LS_EDIT-FIELDNAME = 'VBELN'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 10.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    LS_EDIT-FIELDNAME = 'POSNR'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 6.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
    MODIFY IT_VBAP INDEX SY-TABIX FROM LS_OUTTAB  TRANSPORTING
                                      HANDLE_STYLE .
    X_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
    "} UP TO HERE
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        IS_LAYOUT_LVC      = X_LAYOUT
        IT_FIELDCAT_LVC    = IT_FIELDCAT
      TABLES
        T_OUTTAB           = IT_VBAP[]
      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.
    The above code i am modifying the 6 record . you can place your condition.using loop and endloop. you can disable many records/check box also.
    Follow the next steps:
    1. Add the following fields in the internal table:
    checkbox TYPE c,
    celltab TYPE lvc_t_styl,
    2. Define a table and a work-area:
    DATA: wa_celltab TYPE lvc_s_styl,
    ta_celltab TYPE lvc_t_styl.
    3. Update the internal table BEFORE display :
    LOOP AT ta_data INTO wa_data.
    h_tabix = sy-tabix.
    Update field CHECKBOX (enable/disable INPUT)
    REFRESH ta_celltab.
    wa_celltab-fieldname = 'CHECKBOX'.
    IF NOT wa_data-xxxxx IS INITIAL.
    wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
    ELSE.
    wa_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
    ENDIF.
    INSERT wa_celltab INTO TABLE ta_celltab.
    INSERT LINES OF ta_celltab INTO TABLE wa_data-celltab.
    Update internal table
    MODIFY ta_data FROM wa_data INDEX h_tabix.
    ENDLOOP.
    4. Define CHECKBOX in fieldcatalog
    CLEAR wa_catalog.
    wa_catalog-fieldname = 'CHECKBOX'.
    wa_catalog-col_pos = 9.
    wa_catalog-coltext = 'Checkbox'.
    wa_catalog-checkbox = 'X'.
    wa_catalog-edit = 'X'.
    APPEND wa_catalog TO ta_catalog.
    5. Call ALV
    CREATE OBJECT h_custom_container
    EXPORTING container_name = h_container.
    CREATE OBJECT h_grid
    EXPORTING i_parent = h_custom_container.
    CALL METHOD h_grid->set_table_for_first_display
    EXPORTING
    it_toolbar_excluding = wa_toolbar
    is_layout = wa_layout
    CHANGING
    it_outtab = ta_kntkn
    it_fieldcatalog = ta_catalog
    it_sort = ta_sort.
    CALL METHOD h_grid->set_ready_for_input
    EXPORTING i_ready_for_input = 1.
    Regards
    vasu

  • IF one checked box in the same PERNR is marked, mark the rest of them?

    Hi to everybody!
    I've an ALV with checked boxes, now, when the user check  one check box of one PERNR I need to mark all the check boxes of that PERNR...for example
    CHECKBOX                 PERNR                    DATA
          ◘                             12345                    555.74
          ◘                                                             5552
          ◘                                                           142,55
          ◘                              5214                       23
          ◘                                                             2522
    For example, when the user check the first box, (12345) the next check boxes until the PERNR change must be selected, How can I make this?
    Thanks a lot
    Regards,

    I did the same for VBELN, and it working for me, Only thing is you need to generate some action when you check the checkbox. press some button  and see how it works.
    REPORT ztest_alv_check MESSAGE-ID zz .
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
    it_fieldcat TYPE slis_t_fieldcat_alv,
    l_layout TYPE slis_layout_alv,
    x_events TYPE slis_alv_event,
    it_events TYPE slis_t_event.
    DATA: BEGIN OF itab OCCURS 0,
    vbeln LIKE vbak-vbeln,
    posnr LIKE vbap-posnr,
    chk(1),
    END OF itab.
    SELECT vbeln
    posnr
    FROM vbap
    UP TO 20 ROWS
    INTO TABLE itab.
    x_fieldcat-fieldname = 'CHK'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    x_fieldcat-input = 'X'.
    x_fieldcat-edit = 'X'.
    x_fieldcat-checkbox = 'X'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-hotspot = 'X'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program      = sy-repid
        is_layout               = l_layout
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat             = it_fieldcat
      TABLES
        t_outtab                = itab
      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  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      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.
      LOOP AT itab WHERE chk = 'X'.
        itab-chk = 'X'.
        MODIFY itab  TRANSPORTING chk WHERE vbeln = itab-vbeln .
      ENDLOOP.
      rs_selfield-refresh = 'X'.
      BREAK-POINT.
    ENDFORM. "USER_COMMAND

  • ALV Grid event handlers

    Hello Friends;
    I have a problem with event handlers. I have defined events for double_click, data_change and hotspot_click. At first run of the program everything runs fine but when I make a change at the screen (like pressing Enter or entering a value at a screen field) the handlers seem to be called a couple of times. For example at a hotspot click I call an accounting document display and when I want to return with back button the program seems to be stuck at document display. Actually it calls event handler over and over again. How can I solve this problem? Can refreshing grid be a solution?
    Thx in advance
    Ali

    Hello Ali
    The problem is that after handling the hotspot event the current cell is still on the field with the hotspot. Thus, when you push ENTER the ALV grid checks the current cell which has a hotspot defined which, in turn, raises event HOTSPOT_CLICK.
    Therefore, you have to move the current cell to another cell that has no hotspot defined. Have a look at the implementation of the event handler method. The hotspot is on field KUNNR. After calling transaction XD03 I shift the current cell to field BUKRS.
    If you comment these lines you will see the same behaviour of the report as you described.
    *& Report  ZUS_SDN_TWO_ALV_GRIDS
    REPORT  ZUS_SDN_ALVGRID_EVENTS.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '1000'  OBLIGATORY.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1,
          ls_col_id   type lvc_s_col.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    *   Set active cell to field BUKRS otherwise the focus is still on
    *   field KUNNR which will always raise event HOTSPOT_CLICK
        ls_col_id-fieldname = 'BUKRS'.
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
            IS_ROW_ID    = e_row_id
            IS_COLUMN_ID = ls_col_id.
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_docking
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = gt_knb1
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        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.
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'KUNNR'.
      IF ( syst-subrc = 0 ).
        ls_fcat-hotspot = abap_true.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    Regards
      Uwe

  • Selection using check box in std ALV grid!

    Hi all,
    I have written a custom report to show the O/p in ALV grid.
    This is my code:
    TABLES :zpo_loi.
    TYPE-POOLS : slis.
    TYPE-POOLS: icon.
    TABLES : sscrfields.
    DATA : ls_composer TYPE ssfcompop,
               ls_control TYPE ssfctrlop.
    DATA : wa_return TYPE TABLE OF bapiret2  ,
            wa_address TYPE bapiaddr3.
    DATA : wa_crmd_orderadm_h TYPE zpo_loi,
           it_po TYPE TABLE OF crmd_orderadm_h,
           wa_po TYPE bbp_pds_header.
    DATA : it_tab TYPE TABLE OF zpo_loi.
    DATA :  it_data TYPE TABLE OF crmd_orderadm_h,
            wa_data TYPE bbp_pds_header,
            et_data TYPE bbps_sf_po_output.
    DATA : w_formname TYPE tdsfname ,
           w_sfname TYPE rs38l_fnam.
    DATA :it_po_no TYPE TABLE OF select_be_obj_id,
          wa_it_po_no  LIKE LINE OF it_po_no.
    DATA :r_itab TYPE ddshretval OCCURS 0.
    DATA : it_output LIKE TABLE OF zloi,
           wa_output TYPE zloi.
    DATA : w_answer TYPE c.
    DATA : g_repid LIKE sy-repid,
          g_title TYPE lvc_title,
          g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',
          g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
          g_layout TYPE slis_layout_alv,
          g_print_alv TYPE slis_print_alv,
          g_variant LIKE disvariant,
          c_char_a(1) VALUE 'A',
          c_char_x(1) VALUE 'X',
          itab_alv_sort TYPE slis_t_sortinfo_alv,
          itab_alv_fcat TYPE slis_t_fieldcat_alv.
    *       Internal tables          Begin with IT_                       *
    DATA : it_fcat TYPE slis_t_fieldcat_alv,                           "---ALV
           it_disp TYPE TABLE OF zloi.
    *       Work Area for Internal tables      Begin with WA_             *
    DATA : wa_fcat TYPE slis_fieldcat_alv ,              "---ALV
           wa_layout           TYPE lvc_s_layo,               "---ALV
           wa_it_disp LIKE LINE OF it_disp.
    DATA : it_sf_po TYPE TABLE OF crmd_orderadm_h,
           wa_sf_po TYPE bbp_pds_header.
    *SELECTION-SCREEN:
    *  BEGIN OF SCREEN 500 AS WINDOW TITLE title,
    *  END OF SCREEN 500.
    *DATA : functxt TYPE smp_dyntxt.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS sel_po FOR zpo_loi-zobject_id.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS : pr_loi RADIOBUTTON GROUP grp1 USER-COMMAND ucom,
                 pr_fondo RADIOBUTTON GROUP grp1.
    SELECTION-SCREEN END OF BLOCK b2.
    *       At selection-screen output                                    *
    AT SELECTION-SCREEN OUTPUT.
      IF pr_fondo = 'X'.
        REFRESH sel_po.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF pr_loi = 'X'.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *       At selection-screen on radiobutton                            *
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP grp1.
      IF pr_fondo  = 'X'.
        REFRESH sel_po.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF pr_loi = 'X'.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_po-low.
      PERFORM populate_table.
      PERFORM f4_help.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_po-high.
      PERFORM populate_table.
      PERFORM f4_help.
    *       At selection-screen                                           *
    AT SELECTION-SCREEN.
    *---CHECKING THE INPUT >>>
      IF sy-ucomm = 'ONLI'.
        PERFORM f002-check_input.
        PERFORM f001-check.
      ENDIF.
    *&      Form  POPULATE_TABLE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM populate_table .
      SELECT zobject_id
               description
      FROM zpo_loi
      INTO CORRESPONDING FIELDS OF TABLE it_tab.
      SORT it_tab BY zobject_id ASCENDING.
    ENDFORM.                    " POPULATE_TABLE
    *&      Form  F4_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f4_help .
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          ddic_structure = ' '
          retfield       = 'ZOBJECT_ID'
          dynpprog       = sy-repid
          dynpnr         = sy-dynnr
          dynprofield    = 'A'
          value_org      = 'S'
        TABLES
          value_tab      = it_tab
          return_tab     = r_itab.
    ENDFORM.                                                    " F4_HELP
    *&      Form  F001-CHECK
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f001-check .
      IF pr_fondo = 'X'.
        PERFORM display_expiring_fondos.
      ELSEIF pr_loi = 'X'.
        PERFORM fetch_po_det.
        PERFORM build_fcat.
        PERFORM alv_display.
      ENDIF.
    ENDFORM.                    " F001-CHECK
    *&      Form  F002-CHECK_INPUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f002-check_input .
      IF pr_loi = 'X'.
        REFRESH it_po.
        IF sel_po-low IS NOT INITIAL.
          SELECT object_id
          FROM crmd_orderadm_h
          INTO CORRESPONDING FIELDS OF TABLE it_po
          WHERE object_type = 'BUS2201'
          AND object_id = sel_po-low.
          IF sy-subrc NE 0.
            IF sel_po-high IS NOT INITIAL.
              SELECT object_id
              FROM crmd_orderadm_h
              INTO CORRESPONDING FIELDS OF TABLE it_po
              WHERE object_type = 'BUS2201'
              AND  object_id = sel_po-high.
              IF sy-subrc NE 0.
                MESSAGE e009(zsrm).
              ENDIF.
            ENDIF.
            MESSAGE e007(zsrm).
          ENDIF.
        ELSE.
          MESSAGE e010(zsrm).
        ENDIF.
        IF sel_po-high IS NOT INITIAL.
          SELECT object_id
          FROM crmd_orderadm_h
          INTO CORRESPONDING FIELDS OF TABLE it_po
          WHERE object_type = 'BUS2201'
          AND  object_id = sel_po-high.
          IF sy-subrc NE 0.
            MESSAGE e008(zsrm).
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " F002-CHECK_INPUT
    *&      Form  FETCH_PO_DET
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fetch_po_det .
      REFRESH it_po.
      it_po_no[] = sel_po[].
      DATA : w_count TYPE i,
             w_lines TYPE c,
             wa_header TYPE bbp_pds_po_header_d.
      REFRESH : it_po,it_output.
      IF sel_po-high IS NOT INITIAL.
        SELECT object_id
               description
               posting_date
               created_by
        FROM crmd_orderadm_h
        INTO CORRESPONDING FIELDS OF TABLE it_po
        WHERE object_type = 'BUS2201'
        AND object_id BETWEEN sel_po-low AND sel_po-high.
      ELSE.
        SELECT object_id
               description
               posting_date
               created_by
        FROM crmd_orderadm_h
        INTO CORRESPONDING FIELDS OF TABLE it_po
        WHERE object_type = 'BUS2201'
        AND object_id = sel_po-low.
      ENDIF.
      w_lines = sy-dbcnt.
      w_count = 1.
      DO.
        IF w_count LE w_lines.
          READ TABLE it_po INTO wa_po INDEX w_count.
          MOVE wa_po-object_id TO wa_output-zzpono.
          MOVE wa_po-description TO wa_output-zzpodesc.
          MOVE wa_po-posting_date TO wa_output-zzpodate.
          MOVE wa_po-created_by TO wa_output-zzpocreator.
          CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
            EXPORTING
              i_object_id = wa_output-zzpono
            IMPORTING
              e_header    = wa_header.
          CALL FUNCTION 'BAPI_USER_GET_DETAIL'
            EXPORTING
              username = wa_output-zzpocreator
            IMPORTING
              address  = wa_address
            TABLES
              return   = wa_return.
          CLEAR wa_output-zzpocreator.
          CONCATENATE wa_address-firstname '   '  wa_address-lastname INTO wa_output-zzpocreator .
          MOVE wa_header-total_value TO wa_output-zzpoval.
          MOVE wa_header-currency TO wa_output-zzpocur.
          APPEND wa_output TO it_output.
          w_count = w_count + 1.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " FETCH_PO_DET
    *&      Form  BUILD_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fcat .
      g_repid = sy-repid.
      g_title = 'Print LOI details'.
      g_print_alv-no_print_listinfos = 'X'.
      g_variant-report = sy-repid.
      g_variant-variant = sy-title.
      CLEAR g_layout.
      g_layout-f2code = ' '.
      wa_layout-zebra       = 'X'.
      g_layout-flexible_key = 'X'.
      g_layout-colwidth_optimize = 'X'.
      g_layout-detail_initial_lines = 'X'.
      g_layout-box_fieldname = 'ZZCHECK'.
      REFRESH it_fcat.
    *Po no
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPONO' .
      wa_fcat-tabname = 'IT_DISP'.
      wa_fcat-seltext_m  = 'Purchase Order'.
    *wa_fcat-seltext_s = 'Purchase Order.
      wa_fcat-icon = 'X'.
      wa_fcat-col_pos = '2'.
      wa_fcat-outputlen = 10.
      APPEND wa_fcat TO it_fcat.
    *Description
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPODESC' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Description'.
      wa_fcat-seltext_m = 'Description'.
    *wa_fcat-seltext_s = 'Description'.
      wa_fcat-col_pos = '3'.
      wa_fcat-outputlen = 10.
      APPEND wa_fcat TO it_fcat.
    *Posting date
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPODATE' .
      wa_fcat-tabname = 'IT_DISP'.
      wa_fcat-seltext_l = 'Posting Date'.
      wa_fcat-seltext_m = 'Posting Date'.
    *wa_fcat-seltext_s = 'Posting Date'.
      wa_fcat-col_pos = '4'.
      wa_fcat-outputlen = 8.
      APPEND wa_fcat TO it_fcat.
    *value
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOVAL' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO value'.
      wa_fcat-seltext_m = 'PO value'.
    *wa_fcat-seltext_s = 'PO value'.
      wa_fcat-col_pos = '5'.
      wa_fcat-outputlen = 15.
      wa_fcat-no_zero = 'X'.
      APPEND wa_fcat TO it_fcat.
    *Currency
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOCUR' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO Currency'.
      wa_fcat-seltext_m = 'PO Currency'.
    *wa_fcat-seltext_s = 'PO Currency'.
      wa_fcat-col_pos = '6'.
      wa_fcat-outputlen = 5.
      APPEND wa_fcat TO it_fcat.
    *Creator
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOCREATOR' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Buyer'.
      wa_fcat-seltext_m = 'Buyer'.
    *wa_fcat-seltext_s = 'Buyer'.
      wa_fcat-col_pos = '7'.
      wa_fcat-outputlen = 12.
      APPEND wa_fcat TO it_fcat.
    ENDFORM.                    " BUILD_FCAT
    *&      Form  ALV_DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM alv_display .
      SORT it_output BY zzpono.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = g_repid
          i_callback_pf_status_set = g_set_pf_stat
          i_callback_user_command  = g_user_command
          i_grid_title             = g_title
          is_layout                = g_layout
          it_fieldcat              = it_fcat[]
          is_variant               = g_variant
          is_print                 = g_print_alv
        TABLES
          t_outtab                 = it_output[]
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    " ALV_DISPLAY
    *&      Form  user_command
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.                             "#EC CALLED
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      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.
      rs_selfield-refresh = 'X'.
      CASE r_ucomm.
        WHEN 'PRINTLOI'.
          PERFORM call_sf.
        WHEN 'BACK'.
          CALL SELECTION-SCREEN 1000.
        WHEN 'CANCEL'.
          CALL SELECTION-SCREEN 1000.
        WHEN 'EXIT'.
          CALL SELECTION-SCREEN 1000.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZALV' EXCLUDING rt_extab.
      SET TITLEBAR 'ZALV'.
    ENDFORM.                    "set_pf_status
    *&      Form  CALL_SF
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM call_sf .
      REFRESH it_sf_po.
      LOOP AT it_output INTO wa_output WHERE zzcheck = 'X'.
        wa_sf_po-object_id = wa_output-zzpono.
        APPEND wa_sf_po TO it_sf_po.
      ENDLOOP.
      w_formname = 'ZSR_EBP_DOCU_LETTEROFINTENT1'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = w_formname
        IMPORTING
          fm_name            = w_sfname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
      ENDIF.
      ls_composer-tdnewid = 'X'.
      ls_control-no_dialog = 'X'.
      LOOP AT it_sf_po INTO wa_sf_po.
        CALL FUNCTION w_sfname
          EXPORTING
            control_parameters = ls_control
            output_options     = ls_composer
            wa_object          = wa_sf_po
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc <> 0.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " CALL_SF
    *&      Form  DISPLAY_EXPIRING_FONDOS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_expiring_fondos .
      SET PF-STATUS 'ZLOI'.
      SET TITLEBAR 'ZLOI'.
      TYPES : BEGIN OF ty_output1,
                guid TYPE bbp_guid,
                object_id TYPE crmt_object_id_db,
                description TYPE crmt_process_description,
                posting_date TYPE crmt_posting_date,
                zzfondo_dat TYPE zfondo_dat,
                created_by TYPE crmt_created_by,
               END OF ty_output1.
      DATA : it_output1 TYPE TABLE OF ty_output1,
             wa_output1 TYPE ty_output1,
              w_lines,
              w_count,
              it_fondo TYPE TABLE OF zsr_fondo,
              it_temp_fondo TYPE TABLE OF zsr_fondo,
              wa_temp_fondo TYPE zsr_fondo,
              wa_fondo TYPE zsr_fondo,
              w_diff TYPE p,
              wa_header1  TYPE bbp_pds_po_header_d.
      CONSTANTS : c_otype(8) VALUE 'BUS2201'.
      REFRESH : it_output1,it_temp_fondo,it_fondo.
      SELECT b~zzfondo_dat
             a~guid
             a~object_id
             a~description
             a~posting_date
             a~created_by
      INTO CORRESPONDING FIELDS OF TABLE it_output1
      FROM bbp_pdhsc AS b
      LEFT OUTER JOIN crmd_orderadm_h AS a ON b~guid = a~guid
      AND a~object_type = c_otype.
      LOOP AT it_output1 INTO wa_output1.
        CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
          EXPORTING
            date1            = sy-datum
            date2            = wa_output1-zzfondo_dat
          IMPORTING
            datediff         = w_diff
          EXCEPTIONS
            invalid_datetime = 1
            OTHERS           = 2.
        IF sy-subrc <> 0.
        ENDIF.
        IF w_diff <= '7'.
          wa_temp_fondo-zzpono = wa_output1-object_id.
          APPEND wa_temp_fondo TO it_temp_fondo.
        ENDIF.
      ENDLOOP.
    *select the final entries for PO whose FONDO is expiring
      DESCRIBE TABLE it_temp_fondo LINES w_lines.
      w_count = 1.
      DO.
        IF w_count LE w_lines.
          READ TABLE it_temp_fondo INTO wa_temp_fondo INDEX w_count.
          IF sy-subrc = 0.
            CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
              EXPORTING
                i_object_id = wa_temp_fondo-zzpono
              IMPORTING
                e_header    = wa_header1.
            wa_fondo-zzpono = wa_temp_fondo-zzpono.
            wa_fondo-zzpodesc = wa_header1-description.
            wa_fondo-zzpodate =  wa_header1-posting_date.
            wa_fondo-zzexpdate = wa_header1-zzfondo_dat.
            wa_fondo-zzpoval = wa_header1-total_value.
            wa_fondo-zzpocur = wa_header1-currency.
            wa_fondo-zzpocreator = wa_header1-created_by.
            CLEAR : wa_address.
            REFRESH wa_return.
            CALL FUNCTION 'BAPI_USER_GET_DETAIL'
              EXPORTING
                username = wa_header1-created_by
              IMPORTING
                address  = wa_address
              TABLES
                return   = wa_return.
            CLEAR wa_fondo-zzpocreator.
            CONCATENATE wa_address-firstname '   '  wa_address-lastname INTO wa_fondo-zzpocreator .
            w_count = w_count + 1.
            APPEND wa_fondo TO it_fondo.
          ENDIF.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_structure_name = 'ZSR_FONDO'
          i_grid_title     = 'EXPIRING FONDOS'
        TABLES
          t_outtab         = it_fondo[]
        EXCEPTIONS
          program_error    = 1
          OTHERS           = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    " DISPLAY_EXPIRING_FONDOS
    Now in my ALV grid o/p i can see the check box but if i select one row and then try to select another the first one gets deselected.
    Can anybody tell me what is missing?

    Hi,
    Try like changing  this
    insted of
    g_layout-f2code = ' '.
    use this
    g_layout-f2code = 'DISP'. " Sets fcode for when double
    and
    g_layout-f2code = '&ETA'. " it will display POPUP screen
    Best Regards
    Ranga
    Edited by: Ranga Swamy on Nov 1, 2008 11:07 PM
    Edited by: Ranga Swamy on Nov 1, 2008 11:17 PM

  • Check box in ALV grid gets unselected for new selection

    Hi all,
    This is my code :
    TYPE-POOLS : slis.
    Variable
    DATA: g_repid LIKE sy-repid,
          g_title TYPE lvc_title,
          g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',
          g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
          g_layout TYPE slis_layout_alv,
          g_print_alv TYPE slis_print_alv,
          g_variant LIKE disvariant,
          c_char_a(1) VALUE 'A',
          c_char_x(1) VALUE 'X',
          itab_alv_sort TYPE slis_t_sortinfo_alv,
          itab_alv_fcat TYPE slis_t_fieldcat_alv,
          fm_name type rs38l_fnam," Function Module Name
    *      l_sfctrlparams LIKE ssfctrlop, " Form Print Parameter
    *      l_sfoutopt LIKE ssfcompop,
          pri_params LIKE pri_params,
          c_x type c .
    *       Internal tables          Begin with IT_                       *
    DATA : it_fcat TYPE SLIS_T_FIELDCAT_ALV,                           "---ALV
           it_disp type table of ZLOI.
    *       Work Area for Internal tables      Begin with WA_             *
    data : wa_fcat TYPE slis_fieldcat_alv ,              "---ALV
           wa_layout           TYPE lvc_s_layo,               "---ALV
           wa_it_disp like line of it_disp.
    *       Objects                                                       *
    DATA : cref TYPE REF TO cl_gui_custom_container,          "---ALV
           gref TYPE REF TO cl_gui_alv_grid.                  "---ALV
    *        Start-of-selection
    Start-of-selection.
      perform fetch_po_det.
      perform build_fcat.
      perform alv_display.
    *&      Form  FETCH_PO_DET
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FETCH_PO_DET .
      data : it_po type table of crmd_orderadm_h,
               wa_po like line of it_po,
               wa_header type BBP_PDS_PO_HEADER_D.
      select  guid
              object_id
              DESCRIPTION
              POSTING_DATE
              CREATED_BY
      from crmd_orderadm_h
      into corresponding fields of table it_po
      where object_type = 'BUS2201'.
      loop at it_po into wa_po.
        move wa_po-object_id to wa_it_disp-ZZPONO.
        move wa_po-DESCRIPTION to wa_it_disp-ZZPODESC.
        move wa_po-posting_date to wa_it_disp-ZZPODATE.
        move wa_po-created_by to wa_it_disp-ZZPOCREATOR.
        CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
          EXPORTING
            I_OBJECT_ID = wa_it_disp-zzpono
          IMPORTING
            E_HEADER    = wa_header.
        move wa_header-total_value to wa_it_disp-ZZPOVAL.
        move wa_header-currency to wa_it_disp-ZZPOCUR.
        append wa_it_disp to it_disp.
      endloop.
    *  write : wa_it_disp-zzpono.
    ENDFORM.                    " FETCH_PO_DET
    *&      Form  BUILD_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_FCAT .
      g_repid = sy-repid.
      g_title = 'LOI details'.
      g_print_alv-no_print_listinfos = 'X'.
      g_variant-report = sy-repid.
      g_variant-variant = sy-title.
      CLEAR g_layout.
      g_layout-f2code = ' '.
      wa_layout-zebra       = 'X'.
      g_layout-flexible_key = 'X'.
      g_layout-colwidth_optimize = 'X'.
      g_layout-detail_initial_lines = 'X'.
      g_layout-box_fieldname = 'ZZCHECK'.
    *g_layout-box_tabname = 'ITAB_REPORT'.
    *Check box
      wa_fcat-fieldname = 'ZZCHECK'.
      wa_fcat-checkbox = 'X'.
      wa_fcat-outputlen = '1'.
      wa_fcat-col_pos = '1'.
      wa_fcat-edit = '1'.
      wa_fcat-seltext_m = 'No'.
      append wa_fcat to it_fcat.
    *Po no
      clear wa_fcat.
      wa_fcat-fieldname = 'ZZPONO' .
    wa_fcat-tabname = 'IT_DISP'.
    *  wa_fcat-seltext = 'Purchase Order'.
      wa_fcat-seltext_m  = 'Purchase Order'.
    *wa_fcat-seltext_s = 'Purchase Order.
    wa_fcat-icon = 'X'.
      wa_fcat-col_pos = '2'.
      wa_fcat-outputlen = 10.
      append wa_fcat to it_fcat.
    *Desc
      wa_fcat-fieldname = 'ZZPODESC' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Description'.
      wa_fcat-seltext_m = 'Description'.
    *wa_fcat-seltext_s = 'Description'.
      wa_fcat-col_pos = '3'.
      wa_fcat-outputlen = 10.
      append wa_fcat to it_fcat.
    *Postign date
      wa_fcat-fieldname = 'ZZPODATE' .
    wa_fcat-tabname = 'IT_DISP'.
    wa_fcat-seltext_l = 'Posting Date'.
      wa_fcat-seltext_m = 'Posting Date'.
    *wa_fcat-seltext_s = 'Posting Date'.
      wa_fcat-col_pos = '4'.
      wa_fcat-outputlen = 8.
      append wa_fcat to it_fcat.
    *value
      wa_fcat-fieldname = 'ZZPOVAL' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO value'.
      wa_fcat-seltext_m = 'PO value'.
    *wa_fcat-seltext_s = 'PO value'.
      wa_fcat-col_pos = '5'.
      wa_fcat-outputlen = 15.
      append wa_fcat to it_fcat.
    *Currency
      wa_fcat-fieldname = 'ZZPOCUR' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO Currency'.
      wa_fcat-seltext_m = 'PO Currency'.
    *wa_fcat-seltext_s = 'PO Currency'.
      wa_fcat-col_pos = '6'.
      wa_fcat-outputlen = 5.
      append wa_fcat to it_fcat.
    *Creator
      wa_fcat-fieldname = 'ZZPOCREATOR' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Buyer'.
      wa_fcat-seltext_m = 'Buyer'.
    *wa_fcat-seltext_s = 'Buyer'.
      wa_fcat-col_pos = '7'.
      wa_fcat-outputlen = 12.
      append wa_fcat to it_fcat.
    ENDFORM.                    " BUILD_FCAT
    *&      Form  ALV_DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM ALV_DISPLAY .
      sort it_disp by ZZPONO.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = g_repid
         I_CALLBACK_PF_STATUS_SET          = g_set_pf_stat
         I_CALLBACK_USER_COMMAND           = g_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                      = g_title
    *   I_GRID_SETTINGS                   =
          IS_LAYOUT                         = g_layout
          IT_FIELDCAT                       = it_fcat[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
          IS_VARIANT                        = g_variant
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
          IS_PRINT                          = g_print_alv
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = it_disp[]
       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.                    " ALV_DISPLAY
    *&      Form  user_command
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.                             "#EC CALLED
      CASE R_UCOMM.
        WHEN 'PRINT'.
          READ TABLE IT_disp INTO WA_IT_DISP WITH KEY ZZCHECK = 'X'.
          IF SY-SUBRC EQ 0.
            loop at it_DISP INTO WA_IT_DISP.
              CALL FUNCTION 'POPUP_TO_CONFIRM'
                EXPORTING
                  TEXT_QUESTION = 'Print the LOI details?'
                  TEXT_BUTTON_1 = 'Yes'
                  TEXT_BUTTON_2 = 'No'.
    *      IMPORTING
    *        ANSWER        = w_answer.
              IF SY-SUBRC  0.
              ENDIF.
    *          PERFORM CALL_SF.
            endloop.
          ENDIF.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
      ENDCASE.
      rs_selfield-refresh = 'X'.
    ENDFORM.                    "user_command
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTANDARD' EXCLUDING rt_extab.
      SET TITLEBAR sy-tcode.
    ENDFORM.                    "set_pf_status
    Now in my ALV grid o/p i can  see the check box  but if i select one row and then try to slect another the first one gets deselected.
    Can anybody tell me what is missing?

    Hi,
    if you need just a check box for each line, try to get rid of this line from your layout.
    g_layout-box_fieldname = 'ZZCHECK'.
    SAP uses this field to store info about selected lines. Hence you click on the second check box, you select different line and the first line is erased. You can select more line by holding SHIFT + CTRL
    Cheers

  • How to handle check box click in ALV grid

    Hi Experts,
    I use ALV grid using FM.
    I have list of delivery note items with one custom field as check-box. When I check the checkbox, all other lines related to the same delivery note should be automaticaly checked.
    Is there any event or function code, where I can handle single click to checkbox?
    Thanks&regards, 
    Jirka

    HI
    you can use following code in user command function .
    DATA :BEGIN OF IT_MAINDATA OCCURS 0,
          MAINDATA(1),
          IT_RD1(1),
    END OF IT_MAINDATA.
    data: V_INDEX TYPE I.
    DESCRIBE TABLE itab LINES LINE.
      DO. " line times.
        READ LINE SY-INDEX FIELD VALUE Iitab-RD1.
        IF SY-SUBRC NE 0. EXIT. ENDIF.
        CHECK V_INDEX > 0.
        CHECK itab-RD1 = 'X'.
        MODIFY itab INDEX V_INDEX.
        IT_MAINDATA-IT_RD1 = Iitab-RD1.
      ENDDO.
    i think is work.
    regards,
    Abhi

Maybe you are looking for

  • Can`t get MacBook Pro game App`s in Brazil! Why?

    I`ve been trying to buy game app`s in Mac App Store but they are not available in Brazil`s Apple site. Why? Is it possible to do it through US or Canadian Mac App Stores?

  • Mapping issue in QA

    *Hai Experts!* *I am facing an issue in Quality server. The scenario is SOAP to JDBC. Which is working fine in Development server. But in QA the mapping is not happening and the Following error is displaying in the Trace view.* *Can any one help me i

  • ACH Payment

    Hi All, When I am running F110, I am facing problem when generating a spool. The Spool conists of errors. The Errors is as follows: F0417                    Warning: Check whether a duplicate payment medium has been created                           

  • Help on "java.lang.NoClassDefFoundError: oracle/jsp/runtimev2/JspReportUtil"

    Hi all, I encounted the following exception on a deployed project to ias 9.0.2: 500 Internal Server Error java.lang.NoClassDefFoundError: oracle/jsp/runtimev2/JspReportUtil     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:333)     at ja

  • Want help in Vioce transfer on a socket

    Dear Buddies Want help in Vioce transfer on a socket Tell me how should I start it. I am new to Java World. but good in C/C++ I knew much about sockects. I have to make application which transfere real time voice from both side.