Table with Linktoaction cell editor VS ALV with Link to action cell editor

Hi,
i am replacing table UI with ALV, i am encountering series of problems one of them is below.
when i click on linktoaction cell in table i can see wdevent has context_element which is element reference, which is being used in action handler to perform some logic...
however when i replace with alv where i displayed one column with link to action cells using CL_SALV_WD_UIE_LINK_TO_ACTION class, however when i click on any particular cell i only get information related to that cell like column name, attribute name, value and position.
however as i said i need context element reference to work with which is not coming with alv.
please suggest.

yes, that is right, you have to get the context element from the node based on the Index you get.

Similar Messages

  • How to list a table field as a checkbox on ALV with button to update tbl

    The requirement of my report transaction is to display rows of the z_table
    where one of the fields (revision complete? y/n) is to be displayed as a
    checkbox.
    This checkbox is editable for the user to check or uncheck.
    When the user edits the checkbox, there is to be a clickbutton on the ALV Grid
    that says UPDATE TABLE
    When the clickbutton is pressed a status screen or message should be displayed
    telling the user that X number of rows were updated.
    The output of the ALV grid should be refreshed to display the output but with
    the edited rows gray'ed out.
    Can anyone help me with an example of how to do this?  I am new to ABAP so as
    much detail you can give the better.  Hopefully that will help others as well
    Thanks!!
    Corey

    Hi,
    The following steps might be useful .
    In the final internal table for display,in the data definition define a field of character 1,
    eg: mark(1) .
    This must be first field for display.
    Then, while populating fieldcat,make options checkbox as 'X' AND edit  as 'X'.
    example code:
      READ TABLE IT_FIELDCAT INTO WA_FIELDCAT INDEX 1.
      WA_FIELDCAT-CHECKBOX = 'X'.
      WA_FIELDCAT-EDIT = 'X'.
      MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
    Now, copy the status of the standard alv program(STANDARD_FULLSCREEN) to your program.
    In the application tool bar add button for update with function code (eg:upd).
    Also, in the export parameters of the fm (reuse_alv_grid_display),  give form name.
    Eg:
         I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    In this form, write the coding for updating ur Z-table .
    Note:
    1) After selecting the entries , user must save the data, so that the data selected wil be reflected in the final internal tabe say,it_final. (the mark field wil be 'X'.)
    2)While updating ur Z-table, make sure u update only the entries selected(eg: loop at it_final where mark = 'X'.)
    3)Once the updation is done, pop up a message & call the form for alv display ( in the form alv fieldcat used must be refreshed & make the field edit = ' '  for all the fields that is updated) .
    eg: 
      READ TABLE IT_FIELDCAT INTO WA_FIELDCAT INDEX 1.
      WA_FIELDCAT-EDIT =  ' ' .
      MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
    Hope this info is useful to you.
    Regards,
    Viji

  • Heirarchical ALV with OOPS

    Can anyone help me with the code of Heirarchical ALV with OOPS in module pool programming.

    hi,
    <i>link</i>
    http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm
    <i>Check this example report :</i> BALVHD01
    <i>chk a sample code.</i>
    REPORT  ZTEST_HIER LINE-COUNT 65
                                 LINE-SIZE 200
                                 NO STANDARD PAGE HEADING
                                 MESSAGE-ID ZZ.
    TYPE-POOLS: SLIS.
    TYPES: BEGIN OF TY_HEAD,
          VBELN LIKE VBAK-VBELN,
          KUNNR LIKE VBAK-KUNNR,
          NAME  LIKE KNA1-NAME1,
          END OF TY_HEAD.
    TYPES: BEGIN OF TY_ITEM,
           VBELN LIKE VBAP-VBELN,
           POSNR LIKE VBAP-POSNR,
           MATNR LIKE VBAP-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           CHECK(1),
           END OF TY_ITEM.
    DATA: IT_ITEM TYPE TABLE OF TY_ITEM.
    DATA: IT_HEADER TYPE TABLE OF TY_HEAD,
           IT_EVENTS TYPE SLIS_T_EVENT,          "Events.
           IT_FIELDCAT      TYPE SLIS_T_FIELDCAT_ALV.
    DATA: X_LAYOUT         TYPE SLIS_LAYOUT_ALV,
          X_FIELDCAT       TYPE SLIS_FIELDCAT_ALV,
          X_KEY           TYPE SLIS_KEYINFO_ALV,
          X_EVENTS TYPE SLIS_ALV_EVENT,      "Event
          X_VBELN LIKE VBAK-VBELN,
          X_ITEM TYPE TY_ITEM.
    CONSTANTS: C_S(1) VALUE '/'.
    DATA: V_FLAG.
    *                   SELECTION-SCREEN                                  *
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR X_VBELN.      "Sales order Number
    SELECTION-SCREEN END OF BLOCK BLK.
    AT SELECTION-SCREEN.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT SINGLE VBELN
               INTO X_VBELN
               FROM VBAK
               WHERE VBELN IN S_VBELN.
        IF SY-SUBRC <> 0.
          MESSAGE E002 WITH 'Please enter valid Sales Order'(020).
        ENDIF.
      ENDIF.
    *       CLASS lcl_bill_complete DEFINITION
    CLASS LCL_BILL_COMPLETE DEFINITION.
      PUBLIC SECTION.
        METHODS:GET_HEADER_DATA,
                GET_ITEM_DATA,
                SHOW_DATA,
                FILL_FIELDCAT,
                FILL_EVENTS,
                TOP_OF_PAGE.
    ENDCLASS.                    "lcl_bill_complete DEFINITION
    *       CLASS lcl_bill_complete IMPLEMENTATION
    CLASS LCL_BILL_COMPLETE IMPLEMENTATION.
      METHOD GET_HEADER_DATA.
        DATA:X_HEADER LIKE LINE OF IT_HEADER.
        X_HEADER-VBELN = '12345'.
        X_HEADER-KUNNR = '1234'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12346'.
        X_HEADER-KUNNR = '1236'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12347'.
        X_HEADER-KUNNR = '1235'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
      ENDMETHOD.                    "get_header_data
      METHOD GET_ITEM_DATA.
        DATA:X_ITEM LIKE LINE OF IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
      ENDMETHOD.                    "get_item_data
      METHOD SHOW_DATA.
        X_KEY-HEADER01 = 'VBELN'.
        X_KEY-ITEM01   = 'VBELN'.
        X_KEY-ITEM02   = 'POSNR'.
        CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = X_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT[]
            I_TABNAME_HEADER   = 'IT_HEADER'
            I_TABNAME_ITEM     = 'IT_ITEM'
            IS_KEYINFO         = X_KEY
            IT_EVENTS          = IT_EVENTS
          TABLES
            T_OUTTAB_HEADER    = IT_HEADER
            T_OUTTAB_ITEM      = IT_ITEM
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.
      ENDMETHOD.                    "show_data
      METHOD FILL_FIELDCAT.
        DATA: L_POS TYPE I.
        X_LAYOUT-HEADER_TEXT      = 'HEADER'.
        X_LAYOUT-ITEM_TEXT        = 'ITEM'.
        X_LAYOUT-DEFAULT_ITEM     = ' '.
        X_LAYOUT-NO_KEYFIX        = 'X'.
        X_LAYOUT-BOX_TABNAME      = 'IT_ITEM'.
        L_POS = L_POS + 1.
    *- Sales Order Number
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'KUNNR'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to Party'(010).
        X_FIELDCAT-OUTPUTLEN  = 13.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'NAME'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-OUTPUTLEN  = 15.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to name'(011).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'CHECK'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-CHECKBOX   = 'X'.
        X_FIELDCAT-INPUT  = 'X'.
        X_FIELDCAT-EDIT  = 'X'.
        X_FIELDCAT-SELTEXT_M   = ' '.
        X_FIELDCAT-OUTPUTLEN  = 2.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-TECH = 'X'.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
    *- Sales Order Item
        X_FIELDCAT-FIELDNAME   = 'POSNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'SO Item'(018).
        X_FIELDCAT-OUTPUTLEN  = 7.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MATNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 18.
        X_FIELDCAT-SELTEXT_M   = 'Material number'(012).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MAKTX'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 40.
        X_FIELDCAT-SELTEXT_M   = 'Material Description'(013).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
      ENDMETHOD.                    "fill_fieldcat
    *--Fill the events table
      METHOD FILL_EVENTS.
    *-  Top of page
        X_EVENTS-NAME =  'TOP_OF_PAGE'.
        X_EVENTS-FORM =  'TOP_OF_PAGE'.
        APPEND X_EVENTS TO IT_EVENTS.
      ENDMETHOD.                    "fill_events
      "fill_events
      METHOD TOP_OF_PAGE.
    *-  Call Steelcase Standard Header
        WRITE 'top_of_page here'.
      ENDMETHOD.                    "top_of_page
    ENDCLASS.                    "lcl_bill_complete IMPLEMENTATION
    START-OF-SELECTION.
      DATA: OBJ TYPE REF TO LCL_BILL_COMPLETE.
      CREATE OBJECT OBJ.
      CALL METHOD OBJ->GET_HEADER_DATA.
      CALL METHOD OBJ->GET_ITEM_DATA.
      CALL METHOD OBJ->FILL_FIELDCAT.
      CALL METHOD OBJ->FILL_EVENTS.
      CALL METHOD OBJ->SHOW_DATA.
    *&      Form  top_of_page
    *      TOP_OF_PAGE
    FORM TOP_OF_PAGE.
    *-To show the top of page
      CALL METHOD OBJ->TOP_OF_PAGE.
    ENDFORM.                    "top_of_page
    if hlped plsmark points.
    rgds
    Anver

  • ALV table with two dimensions and a link in each cell to a document

    Hi,
    I want to create an ALV output for a 2-dimension table. The table should look like:
    ---  |  Col1  |  Col2  | ...
    L1 | Cell11 | Cell12 | ...
    L2 | Cell21 | Cell22 | ...
    Do you have any hints how I could implement such a two dimensional ALV with different links when clicking on Cell11, Cell12, Cell21, ....
    Thanks for your help!
    Caroline

    if u use OO ALV,
    1.on clicking CELL1, CELL2 etc, to get different links,
    u can put hotspot for the fields in fieldcat
    and u can handle method
    button_click event of cl_gui_alv_grid.
          CLASS LCL_EVENT_RECEIVER DEFINITION
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
        METHODS HANDLE_CLICK_ROW_COL
        FOR EVENT CLICK_ROW_COL OF CL_GUI_ALV_GRID
        IMPORTING ROW_ID COL_ID.
    ENDCLASS.                    "cl_event_receiver DEFINITION
          CLASS CL_EVENT_RECEIVER IMPLEMENTATION
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_BUTTON_CLICK.
        perform button_click using ROW_ID COL_ID.
      ENDMETHOD .                    "handle_top_of_page
    ENDCLASS .                    "cl_event_receiver
    2.
    FOR GETTING TWO DIMENSIONS, HANDLE PRINT_TOP_OF_PAGE
    and using write statements, build a row at the top of grid.
    or else
    IN THE LAYOUT , U CAN PLACE BUTTONS JUST ABOVE THE CUSTOM CONTAINER

  • Access table cells using tab key with iterators

    Hi,
    I use a tableview with iterator and allow users to mouseclick certain column cells. I capture these user interactions using server event "onCellClick". But I cannot access these cells using tab key instead of mouse click. But tab key is a must for visibly challenged users.      Is there any way to access table cells using tab keys (with iterators)?
    I use icons in those cells to replace  check box and change the icons to differentiate checked/unchecked status.

    Hi Craig,
    Thanks for your effort.
    But I was able to solve my problem. I don't think I gave all the information to simulate my problem in your environment. I used images in certain table cells and was not able to access those cells using tab key or access key. Tag <b><img></b> doesn't have the attributes <b>tabindex</b> and <b>access key</b>.
    I solved the problem by surrounding the <b><img></b> by anchor tag <<b>A>,</b> which has both attributes. I did these changes within the iterator method <b>RENDER_CELL_START</b> using CL_BSP_BEE_TABLE.
    In the event handling, I had to do separate processing for  mouse click event and key press event for those cells.
    For visibly challenged users:
    They can access those cells by tab key or access key and the key press event is used to capture when they hit enter key.
    So this problem is irrelevant to service packages (SP38,..).

  • ALV with dropdown in column and other questions

    hi,
    I created an editable alv with configuration model via external context mapping.
    now I have a column which contains strings and my aim is to show this whole column as a dropdownlist. the possible values of this dropdown are fetched in a database table at  runtime and each cell in this column got its own selected value in this dropdownlist.
    changes of the selected values should be written in the database table in a later step.
    1. what changes do I have to do?
    should I remove my external mapping concerning the alv and use the setData method? or what is the easiest way to get my dropdownlist in this column instead of normal text (string) ?
    2. should I choose dropdownbykey or by index?
       I suppose I have to change the context when changing the selected value in the dropdownlist and the read out the changed context element and update my database table?
    3. how could I access rows (= tuples) in an alv?
    4. how can I avoid that a row could be deleted, inserted or added with the normal functions of the alv?

    Hi Thorsten,
    If the possible list of values in the dropdown is different for each row, you need a drop down by index. Else this can be done using a dropdown by key itself.
    The only change that you need to do is create a cell editor of type dropdown for that particular column and configure your ALV model.
    The sample code for changing the cell editor would be:
        l_alv_model = l_ref_interfacecontroller->get_model( ).
      DATA:
         lr_column_settings TYPE REF TO if_salv_wd_column_settings,
         lr_column type ref to CL_SALV_WD_COLUMN.
         lr_dropdown TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
      lr_column_settings ?= l_alv_model.
      lr_column = lr_column_settings->get_column( <column name> ).
      CREATE OBJECT lr_dropdown EXPORTING 
      SELECTED_KEY_FIELDNAME= '<fieldname>'
      lr_column->set_cell_editor( lr_dropdown ).
    Here, you can substitute the field name with your field name that has to be displayed as a dropdown.
    The dropdown list can be populated in the wddoinit method by attaching a value set to the attribute in the context node info. Everything else will be like you do in a normal table. You can so a get_static_attributes of your elements and persist in tables. Whenever you change the selected value, the context will be updated immediately. You can have a user defined function like 'Save' or something where you can just read the context and process the data.
    If you do not want to display any of the normal functions, you can do the following:
    data: lt_functions type SALV_WD_T_FUNCTION_STD_REF,
            ls_function type SALV_WD_s_FUNCTION_STD_REF.
    lt_functions = l_alv_model->if_salv_wd_function_settings~get_functions_std( ).
    loop at lt_functions into ls_function.
    ls_function-r_function->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ).
    endloop.
    The above code will hide all the standard functions. If you want to hide specific ones, do a get_function(id) and set_visible.
    Hope this helps.
    Regards
    Nithya

  • ALV with dynamic columns and description labels in header titles

    Hi everybody,
    I have to implement an ALV whose columns are not defined until runtime. Is it possible to do that in some simple way? Is it necessary to use objects to define this kind of ALV's?
    And another one query, is it possible to add description labels to column headers so that when the user points with the cursor in them he/she gets a little explanation about the detail of the column (for example, description name of the product hierarchy when pointing to the column named with one of the existing hierarchies, i.e 010102102)
    Thanks in advance,

    for your first question check this
    Just check this sample from one of the SAP site
    ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
    Applies To:
    ABAP / ALV Grid
    Article Summary
    ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
    Code Sample
    REPORT zcdf_dynamic_table.
    * Dynamic ALV Grid with Cell Coloring.
    * Build a field catalog dynamically and provide the ability to color
    * the cells.
    * To test, copy this code to any program name and create screen 100
    * as described in the comments. After the screen is displayed, hit
    * enter to exit the screen.
    * Tested in 4.6C and 6.20
    * Charles Folwell - [email protected] - Feb 2, 2005
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    START-OF-SELECTION.
    * Build field catalog based on your criteria.
    wa_fieldcat-fieldname = 'FIELD1'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 1'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    wa_fieldcat-fieldname = 'FIELD2'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 2'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Before adding cell color table, save fieldcatalog to pass
    * to ALV call. The ALV call needs a fieldcatalog without
    * the internal table for cell coloring.
    t_fieldcat2[] = t_fieldcat1[].
    * Add cell color table.
    * CALENDAR_TYPE is a structure in the dictionary with a
    * field called COLTAB of type LVC_T_SCOL. You can use
    * any structure and field that has the type LVC_T_SCOL.
    wa_fieldcat-fieldname = 'T_CELLCOLORS'.
    wa_fieldcat-ref_field = 'COLTAB'.
    wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Create dynamic table including the internal table
    * for cell coloring.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fieldcat1
    IMPORTING
    ep_table = r_dyn_table
    EXCEPTIONS
    generate_subpool_dir_full = 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.
    * Get access to new table using field symbol.
    ASSIGN r_dyn_table->* TO <t_dyn_table>.
    * Create work area for new table.
    CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
    * Get access to new work area using field symbol.
    ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    * Get data into table from somewhere. Field names are
    * known at this point because field catalog is already
    * built. Read field names from the field catalog or use
    * COMPONENT <number> in a DO loop to access the fields. A
    * simpler hard coded approach is used here.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'ABC'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'XYZ'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'TUV'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'DEF'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    * Color cells based on your criteria. In this example, a test on
    * FIELD2 is used to decide on color.
    LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    * Get access to internal table used to color cells.
    ASSIGN COMPONENT 'T_CELLCOLORS'
    OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
    CLEAR wa_cellcolors.
    wa_cellcolors-fname = 'FIELD2'.
    IF <w_field> = 'DEF'.
    wa_cellcolors-color-col = '7'.
    ELSE.
    wa_cellcolors-color-col = '5'.
    ENDIF.
    APPEND wa_cellcolors TO <t_cellcolors>.
    MODIFY <t_dyn_table> FROM <wa_dyn_table>.
    ENDLOOP.
    * Display screen. Define screen 100 as empty, with next screen
    * set to 0 and flow logic of:
    * PROCESS BEFORE OUTPUT.
    * MODULE initialization.
    * PROCESS AFTER INPUT.
    CALL SCREEN 100.
    * MODULE initialization OUTPUT
    MODULE initialization OUTPUT.
    * Set up for ALV display.
    IF r_dock_ctnr IS INITIAL.
    CREATE OBJECT r_dock_ctnr
    EXPORTING
    side = cl_gui_docking_container=>dock_at_left
    ratio = '90'.
    CREATE OBJECT r_alv_grid
    EXPORTING i_parent = r_dock_ctnr.
    * Set ALV controls for cell coloring table.
    wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
    * Display.
    CALL METHOD r_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = wa_is_layout
    CHANGING
    it_outtab = <t_dyn_table>
    it_fieldcatalog = t_fieldcat2.
    ELSE. "grid already prepared
    * Refresh display.
    CALL METHOD r_alv_grid->refresh_table_display
    EXPORTING
    i_soft_refresh = ' '
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    ENDIF.
    ENDMODULE. " initialization OUTPUT

  • 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

  • OOP's ALV with top of page

    Hi,
    Does any one have code or pointers for creating a ALV with top of page using OOPS.
    I need to create a top of page with variables like :
    Report Name : ZABC
    User Name : Z234ASD
    Date : System Date
    Time : System Time
    Transaction : ZXYZ
    Thanks
    Khan.

    The code i used to implement top of page for OO ALV is as below but when you proceed to print out the report, it doesn't print out the header as the list output doesn't show the header.
    codeREPORT ZTEST1234_ALV_TOP MESSAGE-ID ZZ .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
    V_FLAG,
    V_DATA_CHANGE,
    V_ROW TYPE LVC_S_ROW,
    V_COLUMN TYPE LVC_S_COL,
    V_ROW_NUM TYPE LVC_S_ROID.
    "The Below Definitions Must.....
    DATA:
    Reference to document
    DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
    Reference to split container
    DG_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    Reference to grid container
    DG_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
    Reference to html container
    DG_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER,
    Reference to html container
    DG_PARENT_HTML TYPE REF TO CL_GUI_CONTAINER.
    "up to here
    CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
    PUBLIC SECTION .
    METHODS:
    **Hot spot Handler
    HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
    IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
    HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
    IMPORTING E_ROW E_COLUMN ES_ROW_NO,
    TOP_OF_PAGE FOR EVENT TOP_OF_PAGE "event handler
    OF CL_GUI_ALV_GRID
    IMPORTING E_DYNDOC_ID.
    ENDCLASS. "lcl_event_handler DEFINITION
    CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
    METHOD HANDLE_HOTSPOT_CLICK .
    CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
    V_ROW = E_ROW_ID.
    V_COLUMN = E_COLUMN_ID.
    V_ROW_NUM = ES_ROW_NO.
    MESSAGE I000 WITH V_ROW 'clicked'.
    ENDMETHOD. "lcl_event_handler
    *Handle Double Click
    METHOD HANDLE_DOUBLE_CLICK.
    ENDMETHOD. "handle_double_click
    METHOD TOP_OF_PAGE. "implementation
    Top-of-page event
    PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
    ENDMETHOD. "top_of_page
    ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
    *& Global Definitions
    DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
    G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
    SAVE_OK LIKE SY-UCOMM,
    G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
    GS_LAYOUT TYPE LVC_S_LAYO.
    Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
    X_FIELDCAT TYPE LVC_S_FCAT,
    LS_VARI TYPE DISVARIANT.
    START-OF_SELECTION
    START-OF-SELECTION.
    DATA:BEGIN OF ITAB OCCURS 0,
    VBELN LIKE LIKP-VBELN,
    POSNR LIKE LIPS-POSNR,
    CELLCOLOR TYPE LVC_T_SCOL, "required for color
    DROP(10),
    END OF ITAB.
    SELECT VBELN
    POSNR
    FROM LIPS
    UP TO 20 ROWS
    INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
    IF NOT ITAB[] IS INITIAL.
    CALL SCREEN 100.
    ELSE.
    MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
    ENDIF.
    *& Form CREATE_AND_INIT_ALV
    text
    FORM CREATE_AND_INIT_ALV .
    DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
    "attention.....from here
    "split your container here...into two parts
    "create the container
    CREATE OBJECT G_CUSTOM_CONTAINER
    EXPORTING CONTAINER_NAME = G_CONTAINER1.
    "this is for top of page
    Create TOP-Document
    CREATE OBJECT DG_DYNDOC_ID
    EXPORTING STYLE = 'ALV_GRID'.
    Create Splitter for custom_container
    CREATE OBJECT DG_SPLITTER
    EXPORTING PARENT = G_CUSTOM_CONTAINER
    ROWS = 2
    COLUMNS = 1.
    Split the custom_container to two containers and move the reference
    to receiving containers g_parent_html and g_parent_grid
    "i am allocating the space for grid and top of page
    CALL METHOD DG_SPLITTER->GET_CONTAINER
    EXPORTING
    ROW = 1
    COLUMN = 1
    RECEIVING
    CONTAINER = DG_PARENT_HTML.
    CALL METHOD DG_SPLITTER->GET_CONTAINER
    EXPORTING
    ROW = 2
    COLUMN = 1
    RECEIVING
    CONTAINER = DG_PARENT_GRID.
    "you can set the height of it
    Set height for g_parent_html
    CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
    EXPORTING
    ID = 1
    HEIGHT = 5.
    "from here as usual..you need to specify parent as splitter part
    "which we alloted for grid
    CREATE OBJECT G_GRID
    EXPORTING I_PARENT = DG_PARENT_GRID.
    Set a titlebar for the grid control
    CLEAR GS_LAYOUT.
    GS_LAYOUT-GRID_TITLE = TEXT-003.
    GS_LAYOUT-ZEBRA = SPACE.
    GS_LAYOUT-CWIDTH_OPT = 'X'.
    GS_LAYOUT-NO_ROWMARK = 'X'.
    GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
    CALL METHOD G_GRID->REGISTER_EDIT_EVENT
    EXPORTING
    I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
    CREATE OBJECT G_HANDLER.
    SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
    SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
    DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
    DATA: L_INDEX TYPE SY-TABIX.
    "Here i am changing the color of line 1,5,10...
    "so you can change the color of font conditionally
    LOOP AT ITAB.
    L_INDEX = SY-TABIX.
    IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
    LS_CELLCOLOR-FNAME = 'VBELN'.
    LS_CELLCOLOR-COLOR-COL = '6'.
    LS_CELLCOLOR-COLOR-INT = '0'.
    LS_CELLCOLOR-COLOR-INV = '1'.
    APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
    MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
    LS_CELLCOLOR-FNAME = 'POSNR'.
    LS_CELLCOLOR-COLOR-COL = '6'.
    LS_CELLCOLOR-COLOR-INT = '0'.
    LS_CELLCOLOR-COLOR-INV = '1'.
    APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
    MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
    ENDIF.
    ENDLOOP.
    setting focus for created grid control
    CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
    EXPORTING
    CONTROL = G_GRID.
    Build fieldcat and set editable for date and reason code
    edit enabled. Assign a handle for the dropdown listbox.
    PERFORM BUILD_FIELDCAT.
    PERFORM SET_DRDN_TABLE.
    Optionally restrict generic functions to 'change only'.
    (The user shall not be able to add new lines).
    PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
    LS_VARI-REPORT = SY-REPID.
    LS_VARI-HANDLE = SPACE.
    LS_VARI-LOG_GROUP = SPACE.
    LS_VARI-USERNAME = SPACE.
    LS_VARI-VARIANT = SPACE.
    LS_VARI-TEXT = SPACE.
    LS_VARI-DEPENDVARS = SPACE.
    **Calling the Method for ALV output
    CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
    IS_VARIANT = LS_VARI
    IS_LAYOUT = GS_LAYOUT
    I_SAVE = 'A'
    CHANGING
    IT_FIELDCATALOG = IT_FIELDCAT
    IT_OUTTAB = ITAB[].
    "do these..{
    Initializing document
    CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
    Processing events
    CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
    EXPORTING
    I_EVENT_NAME = 'TOP_OF_PAGE'
    I_DYNDOC_ID = DG_DYNDOC_ID.
    "end }
    Set editable cells to ready for input initially
    CALL METHOD G_GRID->SET_READY_FOR_INPUT
    EXPORTING
    I_READY_FOR_INPUT = 1.
    ENDFORM. "CREATE_AND_INIT_ALV
    *& Form EXCLUDE_TB_FUNCTIONS
    text
    -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    Only allow to change data not to create new entries (exclude
    generic functions).
    DATA LS_EXCLUDE TYPE UI_FUNC.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM. " EXCLUDE_TB_FUNCTIONS
    *& Form build_fieldcat
    Fieldcatalog
    FORM BUILD_FIELDCAT .
    DATA: L_POS TYPE I.
    L_POS = L_POS + 1.
    X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-NO_ZERO = 'X'.
    X_FIELDCAT-OUTPUTLEN = '10'.
    X_FIELDCAT-HOTSPOT = 'X'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SCRTEXT_M = 'Item'(025).
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-OUTPUTLEN = '5'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
    X_FIELDCAT-FIELDNAME = 'DROP'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-OUTPUTLEN = '5'.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-DRDN_HNDL = '1'.
    X_FIELDCAT-DRDN_ALIAS = 'X'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    ENDFORM. " build_fieldcat
    *& Module STATUS_0100 OUTPUT
    text
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS 'MAIN100'.
    SET TITLEBAR 'MAIN100'.
    IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
    PERFORM CREATE_AND_INIT_ALV.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    text
    MODULE USER_COMMAND_0100 INPUT.
    CASE SY-UCOMM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Form SET_DRDN_TABLE
    text
    FORM SET_DRDN_TABLE.
    DATA:LT_DRAL TYPE LVC_T_DRAL,
    LS_DRAL TYPE LVC_S_DRAL.
    LOOP AT ITAB .
    First listbox (handle '1').
    IF SY-INDEX = 1.
    LS_DRAL-HANDLE = '1'.
    LS_DRAL-VALUE = ' '.
    LS_DRAL-INT_VALUE = ' '.
    ELSE.
    LS_DRAL-HANDLE = '1'.
    LS_DRAL-VALUE = ITAB-POSNR.
    LS_DRAL-INT_VALUE = ITAB-POSNR.
    ENDIF.
    APPEND LS_DRAL TO LT_DRAL.
    ENDLOOP.
    **Setting the Drop down table for Reason Code
    CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
    EXPORTING
    IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM. " set_drdn_table
    *& Form EVENT_TOP_OF_PAGE
    text
    -->DG_DYNDOC_ID text
    FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
    "this is more clear.....check it
    "first add text, then pass it to comentry write fm
    DATA : DL_TEXT(255) TYPE C. "Text
    Populating header to top-of-page
    CALL METHOD DG_DYNDOC_ID->ADD_TEXT
    EXPORTING
    TEXT = 'Test Report'
    SAP_STYLE = CL_DD_AREA=>HEADING.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Move program ID
    CONCATENATE 'Program Name :' SY-REPID
    INTO DL_TEXT SEPARATED BY SPACE.
    Add Program Name to Document
    PERFORM ADD_TEXT USING DL_TEXT.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Move User ID
    CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE
    Add User ID to Document
    PERFORM ADD_TEXT USING DL_TEXT.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Move Client
    CONCATENATE 'Client :' SY-MANDT INTO DL_TEXT SEPARATED BY SPACE.
    Add Client to Document
    PERFORM ADD_TEXT USING DL_TEXT.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Move date
    WRITE SY-DATUM TO DL_TEXT.
    CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    Add Date to Document
    PERFORM ADD_TEXT USING DL_TEXT.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Move time
    WRITE SY-UZEIT TO DL_TEXT.
    CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    Add Time to Document
    PERFORM ADD_TEXT USING DL_TEXT.
    Add new-line
    CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    Populating data to html control
    PERFORM HTML.
    ENDFORM. " EVENT_TOP_OF_PAGE
    *& Form ADD_TEXT
    To add Text
    FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.
    Adding text
    CALL METHOD DG_DYNDOC_ID->ADD_TEXT
    EXPORTING
    TEXT = P_TEXT
    SAP_EMPHASIS = CL_DD_AREA=>HEADING.
    ENDFORM. " ADD_TEXT
    *& Form HTML
    text
    FORM HTML.
    DATA : DL_LENGTH TYPE I, " Length
    DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id
    Creating html control
    IF DG_HTML_CNTRL IS INITIAL.
    CREATE OBJECT DG_HTML_CNTRL
    EXPORTING
    PARENT = DG_PARENT_HTML.
    ENDIF.
    Reuse_alv_grid_commentary_set
    CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
    EXPORTING
    DOCUMENT = DG_DYNDOC_ID
    BOTTOM = SPACE
    IMPORTING
    LENGTH = DL_LENGTH.
    Get TOP->HTML_TABLE ready
    CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.
    Set wallpaper
    CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND
    EXPORTING
    PICTURE_ID = DL_BACKGROUND_ID.
    Connect TOP document to HTML-Control
    DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.
    Display TOP document
    CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT
    EXPORTING
    REUSE_CONTROL = 'X'
    PARENT = DG_PARENT_HTML
    EXCEPTIONS
    HTML_DISPLAY_ERROR = 1.
    IF SY-SUBRC NE 0.
    MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
    ENDIF.
    ENDFORM. " HTML
    [/code]

  • How Highlight a CELL on an ALV table

    Hi all!
    I'm trying to do some checks on an input field of an ALV table component. But using REPORT_ATTRIBUTE_T100_MESSAGE it doesn't highlight the CELL of the row if the check hasn't been passed succesfully.
    I've used this source code but nothing appears on the screen, no message and no cell highlighted. I put my source code for more information:
    LOOP AT lt_data_mod INTO ls_data_mod.
    alternative access via index
    lo_el_n_empleado = lo_nd_n_empleado->get_element( index = ls_data_mod-index ).
    CHECK VALUE
    report message
    CALL METHOD wd_comp_controller->go_message->report_attribute_t100_message
    EXPORTING
    msg = ls_msg
    element = lo_el_n_empleado
    attribute_name = ls_data_mod-attribute. " The name of input field that it is being modified
    All that source code is in ON_DATA_CHECK event of ALV component.
    Can anyone help me ?
    Thanks!

    Hello,
    I put my source code:
    ON_DATA_CHECK event of ALV:
      lt_data_mod[] = lr_data->t_modified_cells[].
      LOOP AT lt_data_mod INTO ls_data_mod.
    alternative access  via index
    lo_el_n_empleado = lo_nd_n_empleado->get_element( index = ls_data_mod-index ).
    get all declared attributes
        lo_el_n_empleado->get_static_attributes(
          IMPORTING
            static_attributes = ls_n_empleado ).
    Leemos la información inicial para hacer posteriormente los recalculos.
        READ TABLE wd_this->gt_empleados_inicial INTO ls_empleados_inicial WITH KEY pernr = ls_n_empleado-pernr.
        ASSIGN ls_data_mod-r_value->* TO .
    Fijamos el valor del campo INCIN o PERIN en función de si el usuario ha modificado el valor en pantalla
        IF ls_data_mod-r_value NE ls_data_mod-r_old_value AND
            GE ls_n_empleado-incsu.
          IF ls_data_mod-attribute = 'INCPA'.
            ls_n_empleado-incin = abap_true.
          ELSEIF ls_data_mod-attribute = 'PERVC'.
            ls_n_empleado-perin = abap_true.
          ENDIF.
    ELSEIF <fs_data> LT ls_n_empleado-incsu. " Check if user entry is less than incsu value then throw message...
          wd_comp_controller->show_message_2( imp_element = lo_el_n_empleado
                                                                               imp_msgno   = '622'
                                                                               imp_attr    = ls_data_mod-attribute ). " El valor introducido es menor que el "                 incremento sugerido
        ENDIF.
    METHOD show_message_2 .
      DATA lv_message_id TYPE string.
      DATA ls_msg TYPE symsg.
      ls_msg-msgty = 'E'.
      ls_msg-msgid = 'ZHR_CM'.
      ls_msg-msgno = imp_msgno.
    report message
      CALL METHOD wd_this->go_message->report_attribute_t100_message
        EXPORTING
          msg            = ls_msg
          element        = imp_element
          attribute_name = imp_attr.
    ENDMETHOD.
    Also I've tried with report_element_t100_message method but nothing happens.
    Thank you.
    Edited by: vanbelal on Mar 22, 2010 4:54 PM

  • Show link in ALV with blue background

    I have an ALV with three columns. The first shown an input field, the second a dropdown, and the third a link (linkToUrl).
    The first to columns are either editble or not, depending on a display/edit mode that the user can set. The third column  shall always be not editable.
    This all works fine, now my problem:
    The column with the links has a white background, but I want it to have the same background than the not-editable columns (light blue).
    I tried SET_CELL_DESIGN, but none of the colors there seems to fit. I also tried link->set_editable( false ), which shows the right color, but then, the link is not clickable anymore.
    How can I display a link in an ALV column that has the same background than a non-editable, disabled input field?

    Hi,
    Having concatenatedvalue into once column and showing link to part of cell is not possible. Try to have salesorder and lineitem in 2 columns, and provide the link for salesorder.
    Let your cleint know that the above case(original post) is not possible.
    One more thing, POPINS are  not possible for ALV. Youcan use TABLE UI element for popins.
    Regards,
    Lekha.

  • How to make column headers in table in PDF report appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp

    Hi my name is vishal
    For past 10 days i have been breaking my head on how to make column headers in table appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp.
    Given below is my code in c# on how i export datas from different tables in sql server to PDF report using iTextSharp:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using System.Diagnostics;
    using System.IO;
    namespace DRRS_CSharp
    public partial class frmPDF : Form
    public frmPDF()
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    Document doc = new Document(PageSize.A4.Rotate());
    var writer = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
    doc.SetMargins(50, 50, 50, 50);
    doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
    doc.Open();
    PdfPTable table = new PdfPTable(6);
    table.TotalWidth =530f;
    table.LockedWidth = true;
    PdfPCell cell = new PdfPCell(new Phrase("Institute/Hospital:AIIMS,NEW DELHI", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK)));
    cell.Colspan = 6;
    cell.HorizontalAlignment = 0;
    table.AddCell(cell);
    Paragraph para=new Paragraph("DCS Clinical Record-Assigned Dialyzer",FontFactory.GetFont("Arial",16,iTextSharp.text.Font.BOLD,BaseColor.BLACK));
    para.Alignment = Element.ALIGN_CENTER;
    iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
    png.ScaleToFit(105f, 105f);
    png.Alignment = Element.ALIGN_RIGHT;
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
    SqlCommand cmd = new SqlCommand("Select d.dialyserID,r.errorCode,r.dialysis_date,pn.patient_first_name,pn.patient_last_name,d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.Technician_first_name,t.Technician_last_name from dialyser d,patient_name pn,reprocessor r,Techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=0 and d.closed_status=0 and pn.status=1 and r.errorCode<106 and r.reprocessor_id in (Select max(reprocessor_id) from reprocessor where dialyzer_id=d.dialyserID) order by pn.patient_first_name,pn.patient_last_name", conn);
    conn.Open();
    SqlDataReader dr;
    dr = cmd.ExecuteReader();
    table.AddCell("Reprocessing Date");
    table.AddCell("Patient Name");
    table.AddCell("Dialyzer(Manufacturer,Size)");
    table.AddCell("No.of Reuse");
    table.AddCell("Verification");
    table.AddCell("DialyzerID");
    while (dr.Read())
    table.AddCell(dr[2].ToString());
    table.AddCell(dr[3].ToString() +"_"+ dr[4].ToString());
    table.AddCell(dr[5].ToString() + "-" + dr[6].ToString());
    table.AddCell("@count".ToString());
    table.AddCell(dr[12].ToString() + "-" + dr[13].ToString());
    table.AddCell(dr[0].ToString());
    dr.Close();
    table.SpacingBefore = 15f;
    doc.Add(para);
    doc.Add(png);
    doc.Add(table);
    doc.Close();
    System.Diagnostics.Process.Start("AssignedDialyzer.pdf");
    if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.Yes)
    var writer2 = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
    else if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.No)
    this.Close();
    The above code executes well with no problem at all!
    As you can see the file to which i create and save and open my pdf report is
    AssignedDialyzer.pdf.
    The column headers of table in pdf report from c# windows forms using iTextSharp are
    "Reprocessing Date","Patient Name","Dialyzer(Manufacturer,Size)","No.of Reuse","Verification" and
    "DialyzerID".
    However the problem i am facing is after execution and opening of document is my
    column headers in table in pdf report from
    c# and datas in it all appear in bold.
    I have browsed through net regarding to solve this problem but with no success.
    What i want is my pdf report from c# should be similar to following format which i was able to accomplish in vb6,adodb with MS access using iTextSharp.:
    Given below is report which i have achieved from vb6,adodb with MS access using iTextSharp
    I know that there has to be another way to solve my problem.I have browsed many articles in net regarding exporting sql datas to above format but with no success!
    Is there is any another way to solve to my problem on exporting sql datas from c# windows forms using iTextSharp to above format given in the picture/image above?!
    If so Then Can anyone tell me what modifications must i do in my c# code given above so that my pdf report from c# windows forms using iTextSharp will look similar to image/picture(pdf report) which i was able to accomplish from
    vb6,adodb with ms access using iTextSharp?
    I have approached Sound Forge.Net for help but with no success.
    I hope anyone/someone truly understands what i am trying to ask!
    I know i have to do lot of modifications in my c# code to achieve this level of perfection but i dont know how to do it.
    Can anyone help me please! Any help/guidance in solving this problem would be greatly appreciated.
    I hope i get a reply in terms of solving this problem.
    vishal

    Hi,
    About iTextSharp component issue , I think this case is off-topic in here.
    I suggest you consulting to compenent provider.
    http://sourceforge.net/projects/itextsharp/
    Regards,
    Marvin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • ALV WITH VARIENTS

    hi experts, i have some doubts in  alv grid report.
    1.how to create varients for an ALV  report.
    2.all the varients of that report should be available as search help( F4 help).

    HI,
    See the Program ...
    REPORT  ZBC_ALV_EXAMPLE.
    *                 D-A-T-A  D-E-C-L-A-R-A-T-I-O-N-S                     *
    tables:  sflight.
    **-- TYPE-POOLS Definition
    **Includes the types and constants of a type group. Since the types and
    *constants specified in a type group have global validity, you cannot
    *use the statement within a FORM or FUNCTION.
    type-pools: slis.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
    **-- ALV variables
    *****- Field Catalog structure
    data: ls_fieldcat     type slis_fieldcat_alv,    "Field Catalog list
    **--- Field Catalog table
          gt_fieldcat     type slis_t_fieldcat_alv,  "Field Catalog
    **--- Layout ( How you would like to see the output )
          gs_layout       type slis_layout_alv,       "List Layout
    **--  Report name
          g_repid         like sy-repid,
           g_save(1)           type c,
          g_exit(1)           type c,
          g_variant           like disvariant,
          gx_variant          like disvariant.
    **-- Flight Info Internal table
    data: lt_sflight like sflight occurs 0 with header line.
    *                 C-O-N-S-T-A-N-T-S                                    *
    *                 S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                       *
    selection-screen begin of block a with frame title text-100.
    select-options: s_carrid  for  sflight-carrid,
                    s_connid  for  sflight-connid,
                    s_fldate  for  sflight-fldate default sy-datum.
    selection-screen end of block a .
    *                 I-N-I-T-I-A-L-I-Z-A-T-I-O-N                          *
    initialization.
      g_repid = sy-repid.
    **-- Fill ALV field catalog
      perform initialize_fieldcat using gt_fieldcat[].
    ***-- Build Events
    *  perform build_eventtab using gt_events[].
    **-- Read the default variant
      perform initialize_variant.
    *                 A-T  S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                  *
    at selection-screen on value-request for p_vari.
    **-- Display all existing variants
    <b><b>  call function 'REUSE_ALV_VARIANT_F4'
           exporting
                is_variant = g_variant
                i_save     = g_save
           importing
                e_exit     = g_exit
                es_variant = gx_variant
           exceptions
                not_found  = 2.</b></b>
      if sy-subrc = 2.
        message id sy-msgid type 'S'      number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        if g_exit = space.
          p_vari = gx_variant-variant.
        endif.
      endif.
    *                 S-T-A-R-T  O-F  S-E-L-E-C-T-I-O-N                    *
    start-of-selection.
    **-- Read Flight information.
    perform read_flight_info.
    **-- Fill ALV field catalog and display report.
      if not lt_sflight[] is initial.
        perform dislay_alv_report.
      endif.
    *======================================================================*
    *                 FORMS / SUB ROUTINES                                 *
    *======================================================================
    *&      Form  initialize_fieldcat
    *       text
    *      -->P_GT_FIELDCAT[]  text
    form initialize_fieldcat using l_fieldcat type slis_t_fieldcat_alv.
      clear ls_fieldcat.
    * Air line
      ls_fieldcat-fieldname   = 'CARRID'.
      ls_fieldcat-key         = 'X'.
      ls_fieldcat-col_pos     = 1.
      ls_fieldcat-seltext_s   = 'Airline'.
      ls_fieldcat-seltext_l   = 'Airline'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Flight Number
      ls_fieldcat-fieldname   = 'CONNID'.
      ls_fieldcat-key         = 'X'.
      ls_fieldcat-col_pos     = 2.
      ls_fieldcat-seltext_s   = 'Flight Number'.
      ls_fieldcat-seltext_l   = 'Flight Number'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Flight date
      ls_fieldcat-fieldname   = 'FLDATE'.
      ls_fieldcat-key         = 'X'.
      ls_fieldcat-col_pos     = 3.
      ls_fieldcat-seltext_s   = 'Flight date'.
      ls_fieldcat-seltext_l   = 'Flight date'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Airfare
      ls_fieldcat-fieldname   = 'PRICE'.
      ls_fieldcat-col_pos     = 4.
      ls_fieldcat-do_sum      = 'X'.
      ls_fieldcat-seltext_s   = 'Airfare'.
      ls_fieldcat-seltext_l   = 'Airfare'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Local Currency
      ls_fieldcat-fieldname   = 'CURRENCY'.
      ls_fieldcat-col_pos     = 5.
      ls_fieldcat-seltext_s   = 'Local Currency'.
      ls_fieldcat-seltext_l   = 'Local Currency'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Plane Type
      ls_fieldcat-fieldname   = 'PLANETYPE'.
      ls_fieldcat-col_pos     = 6.
      ls_fieldcat-seltext_s   = 'Plane type'.
      ls_fieldcat-seltext_l   = 'Plane type'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Maximum capacity
      ls_fieldcat-fieldname   = 'SEATSMAX'.
      ls_fieldcat-col_pos     = 7.
      ls_fieldcat-seltext_s   = 'Max. seats'.
      ls_fieldcat-seltext_l   = 'Max. seats'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Occupied seats
      ls_fieldcat-fieldname   = 'SEATSOCC'.
      ls_fieldcat-col_pos     = 8.
      ls_fieldcat-seltext_s   = 'Seats occupied'.
      ls_fieldcat-seltext_l   = 'Seats occupied'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Total
      ls_fieldcat-fieldname   = 'PAYMENTSUM'.
      ls_fieldcat-col_pos     = 9.
      ls_fieldcat-do_sum     = 'X'.
      ls_fieldcat-seltext_s   = 'Total amount'.
      ls_fieldcat-seltext_l   = 'Total amount'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Total
      ls_fieldcat-fieldname   = 'PAYMENTSUM'.
      ls_fieldcat-col_pos     = 9.
      ls_fieldcat-do_sum     = 'X'.
      ls_fieldcat-seltext_s   = 'Total amount'.
      ls_fieldcat-seltext_l   = 'Total amount'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Max. Capacity, Buss. Class
      ls_fieldcat-fieldname   = 'SEATSMAX_B'.
      ls_fieldcat-col_pos     = 10.
      ls_fieldcat-seltext_s   = 'Max.Buss.class cap.'.
      ls_fieldcat-seltext_l   = 'Max.Buss.class cap.'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Max. occupancy, Buss. Class
      ls_fieldcat-fieldname   = 'SEATSOCC_B'.
      ls_fieldcat-col_pos     = 11.
      ls_fieldcat-seltext_s   = 'Max.Bus.CL.occupied'.
      ls_fieldcat-seltext_l   = 'Max.Bus.CL.occupied'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Max. Capacity, First. Class
      ls_fieldcat-fieldname   = 'SEATSMAX_F'.
      ls_fieldcat-col_pos     = 12.
      ls_fieldcat-seltext_s   = 'Max.Buss.class cap.'.
      ls_fieldcat-seltext_l   = 'Max.Buss.class cap.'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    * Max. occupancy, First. Class
      ls_fieldcat-fieldname   = 'SEATSOCC_F'.
      ls_fieldcat-col_pos     = 13.
      ls_fieldcat-seltext_s   = 'Max.Bus.CL.occupied'.
      ls_fieldcat-seltext_l   = 'Max.Bus.CL.occupied'.
      append ls_fieldcat to l_fieldcat.
      clear ls_fieldcat.
    ENDFORM.                    " initialize_fieldcat
    *&      Form  read_flight_info
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM read_flight_info .
    refresh lt_sflight.
    clear   lt_sflight.
    **-- Read data from SFLIGHT table
      select *
        from SFLIGHT
        into table lt_sflight
        where carrid in s_carrid
         and  connid in s_connid
         and  fldate in s_fldate.
    if sy-subrc <> 0.
       message e208(00) with text-101.
    endif.
    ENDFORM.                    " read_flight_info
    *&      Form  dislay_alv_report
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM dislay_alv_report .
    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       = ' '
    *   I_CALLBACK_USER_COMMAND        = ' '
       I_STRUCTURE_NAME                =  'sflight'
    *   IS_LAYOUT                      =
       IT_FIELDCAT                     =  gt_fieldcat
    *   IT_EXCLUDING                   =
    *   IT_SPECIAL_GROUPS              =
    *   IT_SORT                        =
    *   IT_FILTER                      =
    *   IS_SEL_HIDE                    =
       I_DEFAULT                      = 'X'
       I_SAVE                         = 'A'
    <b><b>  IS_VARIANT                     = GX_VARIANT</b></b>
    *   IT_EVENTS                      =
    *   IT_EVENT_EXIT                  =
    *   IS_PRINT                       =
    *   IS_REPREP_ID                   =
    *   I_SCREEN_START_COLUMN          = 0
    *   I_SCREEN_START_LINE            = 0
    *   I_SCREEN_END_COLUMN            = 0
    *   I_SCREEN_END_LINE              = 0
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER        =
    *   ES_EXIT_CAUSED_BY_USER         =
      TABLES
        T_OUTTAB                       = lt_sflight
    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.                    " dislay_alv_report
    *&      Form  initialize_variant
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM initialize_variant .
    g_save = 'A'.
      clear g_variant.
      g_variant-report = g_repid.
      gx_variant = g_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
           exporting
                i_save     = g_save
           changing
                cs_variant = gx_variant
           exceptions
                not_found  = 2.
      if sy-subrc = 0.
        p_vari = gx_variant-variant.
      endif.
    ENDFORM.                    " initialize_variant

  • Int-ALV with OOPS

    when i am going from 1st detail list to basic list and choosing another sales order number i am geting the previous data instead of data according to new sales order number.
    i have tried in ECC5.0 and also in 4.7EE.Plz Help me.
    The code is as follows
    *& Report  ZAP_OOPS_ALV_2
    *& Interactive alv with oops.
    REPORT  zap_oops_alv_2 MESSAGE-ID zapmsg.
    *& Structure Declaration
    Structure Declaration for sales order header data
    TYPES: BEGIN OF ty_vbak,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           END OF ty_vbak,
    Structure Declaration for sales order item data
           BEGIN OF ty_vbap,
           vbeln TYPE vbeln_va, "Sales Ord Num
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
           END OF ty_vbap,
    Structure Declaration for customer data
           BEGIN OF ty_kna1,
           kunnr TYPE kunnr, "Customer
           name1 TYPE name1, "Name
           ort01 TYPE ort01, "City
           pstlz TYPE pstlz, "Postal code
           regio TYPE regio, "State
           END OF ty_kna1,
    Structure declaration for final output
          BEGIN OF ty_output,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           name1 TYPE name1,    "Name
           ort01 TYPE ort01,    "City
           pstlz TYPE pstlz,    "Postal code
           regio TYPE regio,    "State
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
          END OF ty_output.
    *& Internal table Declaration
    DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak INITIAL SIZE 0,
          t_vbap TYPE STANDARD TABLE OF ty_vbap INITIAL SIZE 0,
          t_kna1 TYPE STANDARD TABLE OF ty_kna1 INITIAL SIZE 0,
          t_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
          t_vbep TYPE STANDARD TABLE OF vbep INITIAL SIZE 0,
    *& Work Area Declaration
      w_vbak TYPE ty_vbak,
      w_vbap TYPE ty_vbap,
      w_kna1 TYPE ty_kna1,
      w_output TYPE ty_output,
      w_vbep TYPE vbep,
      g_flag TYPE char1,
    g_vbeln TYPE vbak-vbeln.
    Alv Declarations
    DATA:g_custom_container1 TYPE REF TO cl_gui_custom_container,
         g_custom_container2 TYPE REF TO cl_gui_custom_container,
         g_grid1 TYPE REF TO cl_gui_alv_grid,
         g_grid2 TYPE REF TO cl_gui_alv_grid,
         w_fieldcat TYPE lvc_s_fcat,
         t_fieldcat TYPE lvc_t_fcat.
    *& Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:s_vbeln FOR g_vbeln.
    SELECTION-SCREEN END OF BLOCK b1.
          CLASS handle DEFINITION
    CLASS handle DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:click FOR EVENT double_click OF cl_gui_alv_grid
                                      IMPORTING e_row.
    ENDCLASS.                    "handle DEFINITION
          CLASS handle IMPLEMENTATION
    CLASS handle IMPLEMENTATION.
      METHOD click.
        CLEAR w_output.
        READ TABLE t_output INTO w_output INDEX e_row.
        CLEAR e_row.
        REFRESH t_vbep.
        SELECT *
         FROM vbep
         INTO TABLE t_vbep
         WHERE vbeln = w_output-vbeln.
        CREATE OBJECT g_custom_container2
                       EXPORTING
                        container_name = 'GRID2'.
        CREATE OBJECT g_grid2
                       EXPORTING
                        i_parent = g_custom_container2.
        CALL SCREEN 200.
      ENDMETHOD.                    "click
    ENDCLASS.                    "handle IMPLEMENTATION
    DATA:   g_handle TYPE REF TO handle.
          CLASS main DEFINITION
    CLASS main DEFINITION.
      PUBLIC SECTION.
        METHODS:get_vbak,
                get_vbap,
                get_kna1,
                disp_output,
                validate_vbeln,
                display_alv.
    ENDCLASS.                    "main DEFINITION
          CLASS main IMPLEMENTATION
    CLASS main IMPLEMENTATION.
    Method declaration for getting vbak data
      METHOD get_vbak.
        SELECT vbeln
               vkorg
               vkgrp
               kunnr
               FROM vbak
               INTO TABLE t_vbak
               WHERE vbeln IN s_vbeln.
      ENDMETHOD.                    "get_vbak
    Method Declaration for getting VBAP data
      METHOD get_vbap.
        SELECT vbeln
               posnr
               matnr
               matkl
               netwr
               FROM vbap
               INTO TABLE t_vbap
               FOR ALL ENTRIES IN t_vbak
               WHERE vbeln = t_vbak-vbeln.
      ENDMETHOD.                    "get_vbap
    Method Declaration for getting KNA1 data
      METHOD get_kna1.
        SELECT kunnr
               name1
               ort01
               pstlz
               regio
               FROM kna1
               INTO TABLE t_kna1
               FOR ALL ENTRIES IN t_vbak
               WHERE kunnr = t_vbak-kunnr.
      ENDMETHOD.                                                "get_kna1
    Method Declaration for displaying the output
      METHOD disp_output.
        LOOP AT t_vbap INTO w_vbap.
          w_output-vbeln = w_vbap-vbeln.
          w_output-posnr = w_vbap-posnr.
          w_output-matnr = w_vbap-matnr.
          w_output-matkl = w_vbap-matkl.
          w_output-netwr = w_vbap-netwr.
          CLEAR w_vbak.
          READ TABLE t_vbak INTO w_vbak WITH KEY vbeln = w_vbap-vbeln.
          IF sy-subrc = 0.
            w_output-vkorg = w_vbak-vkorg.
            w_output-vkgrp = w_vbak-vkgrp.
            w_output-kunnr = w_vbak-kunnr.
          ENDIF.
          CLEAR w_kna1.
          READ TABLE t_kna1 INTO w_kna1 WITH KEY kunnr = w_vbak-kunnr.
          IF sy-subrc = 0.
            w_output-name1 = w_kna1-name1.
            w_output-ort01 = w_kna1-ort01.
            w_output-pstlz = w_kna1-pstlz.
            w_output-regio = w_kna1-regio.
          ENDIF.
          APPEND w_output TO t_output.
          CLEAR w_output.
        ENDLOOP.
      ENDMETHOD.                    "disp_output
      METHOD validate_vbeln.
        DATA:l_vbeln TYPE vbeln_va.
        SELECT SINGLE vbeln
                FROM vbak
                INTO l_vbeln
                WHERE vbeln IN s_vbeln.
        IF sy-subrc <> 0.
          MESSAGE e001.
        ENDIF.
      ENDMETHOD.                    "validate_vbeln
      METHOD display_alv.
        CREATE OBJECT g_custom_container1
                       EXPORTING
                        container_name = 'GRID1'.
        CREATE OBJECT g_grid1
                       EXPORTING
                        i_parent = g_custom_container1.
        SET HANDLER g_handle->click  FOR g_grid1.
        w_fieldcat-col_pos = 1.
        w_fieldcat-fieldname = 'VBELN'.
        w_fieldcat-scrtext_m = 'Sales Ord'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 2.
        w_fieldcat-fieldname = 'POSNR'.
        w_fieldcat-scrtext_m = 'Sales Item'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 3.
        w_fieldcat-fieldname = 'MATNR'.
        w_fieldcat-scrtext_m = 'Material'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 4.
        w_fieldcat-fieldname = 'VKORG'.
        w_fieldcat-scrtext_m = 'Sale Org'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 5.
        w_fieldcat-fieldname = 'KUNNR'.
        w_fieldcat-scrtext_m = 'Customer'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        CALL SCREEN 100.
      ENDMETHOD.                    "display_alv
    ENDCLASS.                    "main IMPLEMENTATION
    DATA:g_main TYPE REF TO main.
    Selection SELECTION EVENT
    AT SELECTION-SCREEN.
    *Create the object
      CREATE OBJECT g_main.
      CALL METHOD g_main->validate_vbeln.
    Start of selection EVENT
    START-OF-SELECTION.
      CALL METHOD g_main->get_vbak .
      CALL METHOD g_main->get_vbap.
      CALL METHOD g_main->get_kna1.
      CALL METHOD g_main->disp_output.
      CALL METHOD g_main->display_alv.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = t_output
          it_fieldcatalog = t_fieldcat.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  STATUS_0200  OUTPUT
          text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'MENU1'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name              = 'VBEP'
        CHANGING
          it_outtab                     = t_vbep.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    MODULE user_command_0200 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
         g_flag = 'X'.
         REFRESH t_vbep.
         SET HANDLER g_handle->click  FOR g_grid1.
         CALL METHOD g_main->display_alv.
         CALL SCREEN 100.
         LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 100.
          LEAVE TO SCREEN 0 .
         SET SCREEN 100. LEAVE SCREEN.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT

    Hi Srikar,
       In OOPS ALV, we first define screen then we define container on screen. Container means area on screen where you'll be placing your ALV.
      CREATE OBJECT r_cont
        EXPORTING
          container_name              = 'CONTAINER_1'  " Container name
        EXCEPTIONS
          OTHERS                      = 6
    Now you assign reference of container to your grid. grid defines structure of your ALV.
      CREATE OBJECT r_grid
        EXPORTING
          i_parent          = r_cont
        EXCEPTIONS
          OTHERS            = 5
    Now you call the method set_table_for_first_display of class cl_gui_alv_grid to define fieldcatalog, internal table etc. to display ALV. The reason behind using MODULE is that screen logic is always defined in MODULES. If the user is interacting with screen then screen logic will be defined in PAI of screen.
    One more thing is that in normal ALV you don't define screen and container. That means ALV will always be displayed at system defined place, but in OOP ALV, you define container(area) to define the place for your ALV.
    The advantage which I found in OOP ALV is that it is more flexible to use.
    Regards
    Abhijeet

  • I want to create an ALV  with two row fields name

    Hi
    I want to create an ALV  with two row fields name. please suggest how to do it or send some sample code
    thanks

    Hi,
    see this link
    http://****************/Tutorials/ALV/ALVMainPage.htm
    http://www.alvrobot.com.ar/tutorial.php
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b09ac4d5-e3ad-2910-6a81-96d1b861928c
    http://abapprogramming.blogspot.com/2007/11/alv-check-boxes-sample-code.html
    REPORT zalv5 NO STANDARD PAGE HEADING.
    Description----
    TOPICS INTRODUCED:
    1. Learn about the u2018Standardu2019 PF-Status that comes as default.
    2. Exclude function codes from u2018Standardu2019 PF-Status and customize it.
    TYPE-POOLS: slis.
    DATA: BEGIN OF i_data OCCURS 0,
    qmnum LIKE qmel-qmnum,
    qmart LIKE qmel-qmart,
    qmtxt LIKE qmel-qmtxt,
    ws_row TYPE i,
    ws_char(5) TYPE c,
    chk,
    END OF i_data.
    DATA: report_id LIKE sy-repid.
    DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
    DATA: i_layout TYPE slis_layout_alv.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: i_events TYPE slis_t_event.
    DATA: i_header TYPE slis_t_listheader.
    DATA: i_extab TYPE slis_t_extab.
    SELECT qmnum
    qmart
    qmtxt
    INTO TABLE i_data
    FROM qmel
    WHERE qmnum <= '00030000010'. LOOP AT i_data. i_data-ws_row = sy-tabix. i_data-ws_char = 'AAAAA'. MODIFY i_data. ENDLOOP. report_id = sy-repid. PERFORM f1000_layout_init CHANGING i_layout. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. PERFORM f3000_build_header CHANGING i_header. PERFORM f4000_events_init CHANGING i_events. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2 . IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *& Form F1000_Layout_Init
    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
    CLEAR i_layout.
    i_layout-colwidth_optimize = 'X'.
    i_layout-edit = 'X'.
    ENDFORM. " F1000_Layout_Init
    *& Form f2000_fieldcat_init
    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: line_fieldcat TYPE slis_fieldcat_alv.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
    line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
    line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
    line_fieldcat-seltext_m = 'Notification No.'. " Column Header
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMART'.
    line_fieldcat-ref_tabname = 'I_DATA'.
    line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
    line_fieldcat-seltext_m = 'Notif Type'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMTXT'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Description'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_ROW'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Row Number'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_CHAR'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Test Character Field'.
    line_fieldcat-datatype = 'CHAR'.
    line_fieldcat-outputlen = '15'. " You can specify the width of a
    APPEND line_fieldcat TO i_fieldcat. " column.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'CHK'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Checkbox'.
    line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
    line_fieldcat-edit = 'X'. " This option ensures that you can
    " edit the checkbox. Else it will
    " be protected.
    APPEND line_fieldcat TO i_fieldcat.
    ENDFORM. " f2000_fieldcat_init
    *& Form f3000_build_header
    FORM f3000_build_header USING i_header TYPE slis_t_listheader.
    DATA: gs_line TYPE slis_listheader.
    CLEAR gs_line.
    gs_line-typ = 'H'.
    gs_line-info = 'This is line of type HEADER'.
    APPEND gs_line TO i_header.
    CLEAR gs_line.
    gs_line-typ = 'S'.
    gs_line-key = 'STATUS 1'.
    gs_line-info = 'This is line of type STATUS'.
    APPEND gs_line TO i_header.
    gs_line-key = 'STATUS 2'.
    gs_line-info = 'This is also line of type STATUS'.
    APPEND gs_line TO i_header.
    CLEAR gs_line.
    gs_line-typ = 'A'.
    gs_line-info = 'This is line of type ACTION'.
    APPEND gs_line TO i_header.
    ENDFORM. " f3000_build_header
    *& Form f4000_events_init
    FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
    DATA: line_event TYPE slis_alv_event.
    CLEAR line_event.
    line_event-name = 'TOP_OF_PAGE'.
    line_event-form = 'F4100_TOP_OF_PAGE'.
    APPEND line_event TO i_events.
    CLEAR line_event.
    line_event-name = 'PF_STATUS_SET'.
    line_event-form = 'F4200_PF_STATUS_SET'.
    APPEND line_event TO i_events.
    ENDFORM. " f3000_events_init
    FORM F4100_TOP_OF_PAGE *
    FORM f4100_top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_header.
    ENDFORM.
    FORM F4200_PF_STATUS_SET *
    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
    REFRESH i_extab.
    PERFORM f4210_exclude_fcodes CHANGING i_extab.
    SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.
    ENDFORM.
    *& Form f4210_exclude_fcodes
    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
    DATA: ws_fcode TYPE slis_extab.
    CLEAR ws_fcode.
    ws_fcode = '&EB9'. " Call up Report.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&ABC'. " ABC Analysis.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&NFO'. " Info Select.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&LFO'. " Information.
    APPEND ws_fcode TO i_extab.
    ENDFORM. " f4210_exclude_fcodes
    thanks
    karthik
    reward me if usefull

Maybe you are looking for