ALV grid using classes(displaying subtotals groupwise in ALV grid control)

Hello ,
  please can any body help me its urgent tome.
displaying subtotals groupwise ..say for ex..
cost group  costelement         amount     
10          101         100.00
10                            102          200.00
10                            103          300.00
20                            104          400.00
20                            105          500.00
20                            106          600.00
                101         100.00
                102         200.00
                103         300.00
10                          600.00
          104         400.00
          105         500.00
          106         600.00
20                         1500.00
In ALV grid control using classes.
Thanks in Advance

Hi alson,
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
ENDIF.
ENDMODULE. " PBO OUTPUT
keep the below code
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
here
IF pdel = 'X'.
*BEGIN OF CHANGES BY VINAY DASARI
PERFORM get_data.
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
ENDIF.

Similar Messages

  • Header in alv grid using class

    Hello All,
        I developed alv grid using class method.
    First I created CREATE OBJECT GR_CCONTAINER
    then  CREATE OBJECT GR_ALVGRID
    then  PERFORM FIELD_CATALOG TABLES GT_FIELDCAT----
    for field catalog
        PERFORM LAYOUT CHANGING GS_LAYOUT.----
    for header
        p_gs_layout-grid_title = 'class method'.
      p_gs_layout-sel_mode = 'D'.
      APPEND P_GS_LAYOUT TO IT_LAYOUT.
    and finally CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
    the report is cooming fine but in header it comes only "class method".
    but i need also
    1. reporting date
    2. reporting time.
       can any body tell me how i can i put 2 more heading line
    Thanks,
    Rakesh

    Hi Dude,
    Please refer the below link how to handle  the header in alv using abap oo
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer
    Hope it clears,..............
    Thanks & Regards
    Ramakrishna Pathi

  • Is it possbile to create ALV Grid using Class &  without using SE51

    Is it possible to create a alv grid using Class, with out using the screen painter(SE51).

    Hi Preethi,
    It is possible to creat ALV grid using class, provided u have to create a custom control in the screen dialog.
    Try with the foll code. This is an example for flight detail.
    DATA: container TYPE REF TO cl_gui_custom_container,
          alv_con TYPE REF TO cl_gui_alv_grid.
    data : it_sflight like table of wa with header line,
           g_fieldcat type lvc_t_fcat.
    /* Paste the code the PBO
        CREATE OBJECT container
          EXPORTING
            container_name              = 'C_SPFLI'. "Specify the container name which u created in the dialog screen.
        CREATE OBJECT alv_con
          EXPORTING
            i_parent          = container.
    /* Use the foll. to dislay the report
    CALL METHOD cl_grid->set_table_for_first_display
            EXPORTING
             I_STRUCTURE_NAME              = 'SFLIGHT'
            CHANGING
              it_outtab                     = it_sflight[]
              IT_FIELDCATALOG               = g_fieldcat.
    First create the container and then place the ALV in the container and for dislaying pass the necessary table.
    Hope this will useful for u.
    Get back if u r unable to do it.
    Regards
    Router

  • Editable ALV-Grid  Using Class

    Hi experts.....
    I like to know How to create Editable ALV Grid using Class...
    Also i like to to know how to add The contains to Z-Table...
    Whether we can delete ALV grid contents........
    ...Thanks
    ..Ashish

    Hello Ashish
    You may want to have a look at thread Select Row in OO-ALV programmatically
    Regards
      Uwe

  • ALV Reports using Class Methods

    Hi Experts,
    How can we generate ALV report using class and in that How can we define SLIS_EVENTS.
    Can I provide all the that functionality the way I used to by calling FM
    SLIS_ALV_REUSE_LIST_DISPLAY  ?
    - Like Header comment, event, data grouping , sort etc.
    You may please send any url or document or any example.
    Thanks in advance.
    Regards,
    Tushar Choksi

    Hi,
    The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
    a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
    programs as detailed below:
    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.
    some links.
    www.sapgenie.com
    www.abap4u.com
    http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
    download the PDF from following link.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    Regards,
    Satish

  • A simple ALV report using classes & methods ...

    i want a  simple ALV report using classes & methods ...
    my requirement : i have to use classes & methods instead  of calling a function module to display in grid or list format.
               plz send me with explanation ASAP...it's very urgent..
               Thanks in advance .

    Hi
    Please refer
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    U can use methods for vreating ALVs.
    There is a method named set_table_for_first_display in OOP Concepts.
    Use this Object Oriented Approach for ALV Creation
    Calling the method set_table_for_first_display
    CALL METHOD cust_alv->set_table_for_first_display
    EXPORTING
    is_layout = gst_layout
    CHANGING
    it_outtab = gt_list
    it_fieldcatalog = gt_fcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Object Creation and all
    Creation of Object for Container
    CREATE OBJECT cust_container
    EXPORTING
    container_name = 'ALV_CONTAINER'
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Creation of Object for ALV Grid
    CREATE OBJECT cust_alv
    EXPORTING
    i_parent = cust_container
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Layout settings
    gst_layout-zebra ='X'.
    gst_layout-cwidth_opt = 'X'.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_BUFFER_ACTIVE =
    I_STRUCTURE_NAME = 'ZCS_INACTV_CUST'
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_BYPASSING_BUFFER =
    CHANGING
    ct_fieldcat = gt_fcat
    EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Calling the method set_table_for_first_display
    CALL METHOD cust_alv->set_table_for_first_display
    EXPORTING
    is_layout = gst_layout
    CHANGING
    it_outtab = gt_list
    it_fieldcatalog = gt_fcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    For object oriented concepts refer this link https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
    Reaward if helpful

  • How to place header and footer  in OO-ALV program using class

    How to place header and footer  in OO-ALV program using class tell me wat r the class we shold use and their attributes as well

    Hi Venkatesh,
    Take a look at this how to [ABAP Objects - ALV Model - Using Header and Footer|https://wiki.sdn.sap.com/wiki/x/xdw]
    it's explaining how to define the classes and use it for display an ALV with Header and Footer.
    Regards,
    Marcelo Ramos

  • Adding new rows after displaying subtotals in an ALV report by using OOABAP

    Dear All,
    I am creating an ALV report, displaying subtotals and total by using Classes. I have used classes CL_SALV_AGGREGATIONS (Method : add_aggregation) and CL_SALV_AGGREGATIONS (Method : add_sort) for sorting and doing subtotals.
    Output of my report as follows :- (I have used * for displaying spaces between fields)
    Materia*******Quantity**SerialNo*Equipment**Value***WBS Element
    ISM-DBSVR****1********12363****31872565***2165***Q-0040358945.001010
    ISM-DBSVR****1********12364****31872566***2165***Q-0040358945.001010
    **************************************Subtotal***********4330
    -> If the value of "Quantity" is greater than 1 then the value of subtotal for the field "Value" is to be divided by the Quantity for that line item and needs to be displayed Quantity, SerialNo, Value details information after subtotal .
    -> Basically I need to add few more rows for displaying above additional information in the ALV grid after displaying subtotal .
    Q: Do we have any methods for change the layout for the above requirement.
    I Appreciate your early response.
    Thank you.
    RajaSekhar.

    Hi,
    For such type of requirement you need to use ALV hierchical table.
    You can have your main table in master table.
    For quantity greater than 1 you need to move the data into a seperate internal table....this internal table will have material as the key between the main table and the second table.
    *... §2 create an ALV hierseq table
      try.
          cl_salv_hierseq_table=>factory(
            exporting
              t_binding_level1_level2 = lt_binding
            importing
              r_hierseq               = gr_hierseq
            changing
              t_table_level1           = gt_master
              t_table_level2           = gt_slave ).
        catch cx_salv_data_error cx_salv_not_found.
      endtry.
    you can display both the tables together with the subtotals also.
    please refer to program SALV_DEMO_HIERSEQ_SIMPLE to see how to display the hierarchical display.
    Plr reward points if found helpful.
    Regards,
    Mayank

  • ALV Grid using classes

    Hi gurus,
               can anyone send me sample code to develop a repot using classes with all possibilities i.e, using events and interactive, pop-up.
    Best answers wil be rewarded.
    Regards,
    alson

    REPORT zex35 MESSAGE-ID zsmg NO STANDARD PAGE HEADING.
    INCLUDE <icon>.
    CLASS myclass DEFINITION DEFERRED.
    TABLES: vbak,kna1.
    TYPE-POOLS: slis,sdydo.
    DATA: BEGIN OF jtab OCCURS 0,
          ch(1),
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          styletable TYPE lvc_t_styl,
          rowcolor(4),
          cellcolor TYPE lvc_t_scol,
          ptype_dd_hndl TYPE int4 ,
          END OF jtab.
    DATA : ejtab LIKE jtab OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF vjtab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          END OF vjtab.
    DATA: alv TYPE scrfname VALUE 'ALV',
          obj_c_container_alv TYPE REF TO cl_gui_custom_container,
          obj_grid TYPE REF TO cl_gui_alv_grid,
          obj_myclass TYPE REF TO myclass,
          i_fieldcat TYPE lvc_t_fcat,
          wa_fieldcat LIKE LINE OF i_fieldcat,
          ei_fieldcat TYPE lvc_t_fcat,
          ewa_fieldcat LIKE LINE OF i_fieldcat,
          gs_layout   TYPE lvc_s_layo.
    DATA:   l_rows TYPE lvc_t_row.
    DATA :  modi TYPE  lvc_s_modi ,
            rowid TYPE i,
            ind TYPE i,
            wjtab LIKE jtab,
            it_exclude TYPE ui_functions,
            it_sort TYPE lvc_t_sort,
            it_filt TYPE lvc_t_filt,
            gi_index_rows TYPE lvc_t_row,
            g_selected_row LIKE lvc_s_row.
    DATA: ls_edit TYPE lvc_s_styl,
          lt_edit TYPE lvc_t_styl.
    DATA: ls_outtab LIKE LINE OF jtab.
    CALL SCREEN 100.
          CLASS MYCLASS DEFINITION
    CLASS myclass DEFINITION.
      PUBLIC SECTION.
        METHODS:
        toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object
                 e_interactive,
        user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING
                 e_ucomm.
       after_user_command FOR EVENT BEFORE_user_command OF cl_gui_alv_grid
             IMPORTING
                e_ucomm,
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
    ENDCLASS.
          CLASS MYCLASS IMPLEMENTATION
    CLASS myclass IMPLEMENTATION.
      METHOD toolbar.
        DATA: ls_toolbar  TYPE stb_button.
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'BACK' TO ls_toolbar-function.
       MOVE icon_previous_object TO ls_toolbar-icon.
        MOVE 'BACK' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CLEA' TO ls_toolbar-function.
       MOVE icon_refresh TO ls_toolbar-icon.
        MOVE 'CLEAR' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'TEXT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'READ' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'INSERT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'INSERT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'FCAT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'FCAT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.
    METHOD after_user_command.
       CASE e_ucomm.
         WHEN '&LOCAL&INSERT_ROW'.
           PERFORM insert_data.
       ENDCASE.
    ENDMETHOD.
      METHOD user_command.
        CASE e_ucomm.
          WHEN 'BACK'.
            LEAVE PROGRAM.
          WHEN 'INSERT'.
            PERFORM insert_data.
          WHEN 'FCAT'.
            PERFORM fcat_change.
        ENDCASE.
      ENDMETHOD.
    METHOD handle_change_click.
       LOOP AT er_data_changed->mt_mod_cells INTO modi.
         rowid = modi-row_id.
         READ TABLE jtab INTO wjtab INDEX rowid.
      WJTAB-VBELN = MODI-VALUE.
         MODIFY jtab FROM wjtab INDEX rowid.
       ENDLOOP.
    ENDMETHOD.
    ENDCLASS.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'DISPLAY'.
          SELECT  vbeln erdat kunnr ernam netwr knumv bstnk ktext
              FROM vbak INTO CORRESPONDING FIELDS OF TABLE vjtab
              WHERE vbeln LT  '0000000500'.
          PERFORM display1.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  display1
    FORM display1.
      CREATE OBJECT obj_c_container_alv
        EXPORTING
          container_name              = alv.
      IF obj_grid IS INITIAL.
        CREATE OBJECT obj_grid
              EXPORTING
                i_parent          = obj_c_container_alv.
        CREATE OBJECT obj_myclass.
        SET HANDLER obj_myclass->toolbar FOR obj_grid.
        SET HANDLER obj_myclass->user_command FOR obj_grid.
       SET HANDLER obj_myclass->handle_change_click FOR obj_grid.
       gs_layout-sel_mode = 'C'.
       gs_layout-cwidth_opt = 'X'.
       gs_layout-smalltitle = 'X'.
        gs_layout-grid_title = 'ALV TITLE'.
       gs_layout-no_headers = 'X'.
        gs_layout-stylefname = 'STYLETABLE'.
       gs_layout-no_hgridln = 'X'.
       gs_layout-no_vgridln = 'X'.
       gs_layout-NO_ROWMARK = 'X'.
       gs_layout-no_toolbar = 'X'.
        gs_layout-info_fname = 'ROWCOLOR'.
        gs_layout-ctab_fname = 'CELLCOLOR'.
        LOOP AT vjtab.
          jtab-vbeln = vjtab-vbeln.
          jtab-erdat = vjtab-erdat.
          jtab-kunnr = vjtab-kunnr.
          jtab-ernam = vjtab-ernam.
          jtab-netwr = vjtab-netwr.
          jtab-knumv = vjtab-knumv.
          jtab-bstnk = vjtab-bstnk.
          jtab-ktext = vjtab-ktext.
          APPEND jtab.
          CLEAR jtab.
        ENDLOOP.
        PERFORM build_fieldcat.
        PERFORM exclude_toolbaricons CHANGING it_exclude.
        PERFORM sort_table CHANGING it_sort.
        PERFORM filter_table CHANGING it_filt.
        PERFORM rowcolor.
        PERFORM colcolor.
        PERFORM drilldown_values.
        CALL METHOD obj_grid->set_table_for_first_display
          EXPORTING
            i_structure_name              = 'JTAB'
            is_layout                     = gs_layout
            it_toolbar_excluding          = it_exclude
          CHANGING
            it_outtab                     = jtab[]
           it_sort                       = it_sort
            it_filter                     = it_filt
            it_fieldcatalog               = i_fieldcat.
      ELSE .
        CALL METHOD obj_grid->refresh_table_display.
      ENDIF.
    ENDFORM.                                                    " display1
    *&      Form  SAVE_DATA
    FORM save_data.
    ENDFORM.                    " SAVE_DATA
    *&      Form  INSERT_DATA
    FORM insert_data.
      DATA:l_lines TYPE i.
      REFRESH gi_index_rows.
      CLEAR   g_selected_row.
      DATA ls_listrow LIKE LINE OF jtab .
      CALL METHOD obj_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      READ TABLE gi_index_rows INTO g_selected_row INDEX 1.
      ind = g_selected_row-index + 1.
      INSERT INITIAL LINE INTO jtab INDEX ind.
      READ TABLE jtab INDEX ind.
      CLEAR ls_edit.
      ls_edit-fieldname = 'VBELN'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'ERDAT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KUNNR'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'ERNAM'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'NETWR'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KNUMV'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'BSTNK'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'KTEXT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR : ls_outtab.
      INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
      MODIFY jtab INDEX ind FROM ls_outtab  TRANSPORTING
                                      styletable .
      CALL METHOD obj_grid->refresh_table_display.
    GS_LAYOUT-STYLEFNAME = 'STYLETABLE'.
      REFRESH : lt_edit.
    ENDFORM.                    " INSERT_DATA
    *&      Form  FCAT_CHANGE
    FORM fcat_change.
    DATA ls_fcat TYPE lvc_s_fcat .
    DATA lt_fcat TYPE lvc_t_fcat .
    DATA ls_layout TYPE lvc_s_layo .
    CALL METHOD obj_grid->get_frontend_fieldcatalog
    IMPORTING
    et_fieldcatalog = lt_fcat[] .
    LOOP AT lt_fcat INTO ls_fcat .
       IF ls_fcat-fieldname = 'ERNAM' .
         ls_fcat-coltext = 'MYNAME'.
         ls_fcat-no_out = 'X'.
         MODIFY lt_fcat FROM ls_fcat .
       ENDIF .
    ENDLOOP .
    CALL METHOD obj_grid->set_frontend_fieldcatalog
    EXPORTING
    it_fieldcatalog = lt_fcat[] .
    CALL METHOD obj_grid->get_frontend_layout
    IMPORTING
    es_layout = ls_layout .
    ls_layout-grid_title = 'Changed ALV Grid Title' .
    ls_layout-zebra = 'X' .
    CALL METHOD obj_grid->set_frontend_layout
    EXPORTING
    is_layout = ls_layout .
    LOOP AT jtab.
       IF jtab-netwr > '400.00'.
         CLEAR ls_edit.
         ls_edit-fieldname = 'ERDAT'.
         ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
         INSERT ls_edit INTO TABLE lt_edit.
         CLEAR : ls_outtab.
         INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
         MODIFY jtab INDEX sy-tabix FROM ls_outtab  TRANSPORTING
                                         styletable .
       ENDIF.
    ENDLOOP.
      LOOP AT jtab.
        IF jtab-netwr LE '400.00'.
          ejtab-vbeln = jtab-vbeln.
          ejtab-erdat = jtab-erdat.
          ejtab-kunnr = jtab-kunnr.
          ejtab-ernam = jtab-ernam.
          ejtab-netwr = jtab-netwr.
          ejtab-knumv = jtab-knumv.
          ejtab-bstnk = jtab-bstnk.
          ejtab-ktext = jtab-ktext.
          APPEND ejtab.
          CLEAR ejtab.
        ENDIF.
      ENDLOOP.
      PERFORM ebuild_fieldcat.
      CALL METHOD obj_grid->set_table_for_first_display
           EXPORTING
             i_structure_name              = 'EJTAB'
             is_layout                     = gs_layout
             it_toolbar_excluding          = it_exclude
           CHANGING
             it_outtab                     = ejtab[]
           it_sort                       = it_sort
             it_filter                     = it_filt
             it_fieldcatalog               = ei_fieldcat.
    ENDFORM.                    " FCAT_CHANGE
    *&      Form  exclude_toolbaricons
    FORM exclude_toolbaricons CHANGING   pt_exclude TYPE ui_functions.
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_find .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_average .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
      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_delete_row .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row .
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                    " exclude_toolbaricons
    *&      Form  sort_table
    FORM sort_table CHANGING pt_sort TYPE lvc_t_sort.
      DATA ls_sort TYPE lvc_s_sort .
      ls_sort-spos = '1' .
      ls_sort-fieldname = 'VBELN' .
      ls_sort-up = 'X' .
      ls_sort-down = space .
      APPEND ls_sort TO pt_sort .
      ls_sort-spos = '2' .
      ls_sort-fieldname = 'KUNNR' .
      ls_sort-up = space .
      ls_sort-down = 'X' .
      APPEND ls_sort TO pt_sort .
    ENDFORM.                    " sort_table
    *&      Form  filter_table
    FORM filter_table CHANGING pt_filt TYPE lvc_t_filt.
      DATA ls_filt TYPE lvc_s_filt .
      ls_filt-fieldname = 'VBELN' .
      ls_filt-sign = 'E' .
      ls_filt-option = 'BT' .
      ls_filt-low = '0000000010' .
      ls_filt-high = '0000000100' .
      APPEND ls_filt TO pt_filt .
    ENDFORM.                    " filter_table
    *&      Form  ROWCOLOR
    FORM rowcolor.
      CLEAR wjtab.
      LOOP AT jtab INTO wjtab.
        IF wjtab-netwr LE '400.00'.
          wjtab-rowcolor    = 'C611'.
        ENDIF.
        MODIFY jtab FROM wjtab.
      ENDLOOP.
    ENDFORM.                    " ROWCOLOR
    *&      Form  colcolor
    FORM colcolor.
      DATA ls_cellcolor TYPE lvc_s_scol .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 8 .
      ls_cellcolor-fname = 'KUNNR' .
      ls_cellcolor-color-col = '0' .
      ls_cellcolor-color-int = '0' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 8 .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 13 .
      ls_cellcolor-fname = 'NETWR' .
      ls_cellcolor-color-col = '5' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 13 .
    ENDFORM.                    " colcolor
    *&      Form  DRILLDOWN_VALUES
    FORM drilldown_values.
      DATA lt_ddval TYPE lvc_t_drop .
      DATA ls_ddval TYPE lvc_s_drop .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JFK-12' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JSF-44' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'KMDA-53' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'SS3O/N' .
      APPEND ls_ddval TO lt_ddval .
      CALL METHOD obj_grid->set_drop_down_table
      EXPORTING
      it_drop_down = lt_ddval .
    ENDFORM.                    " DRILLDOWN_VALUES
    *&      Form  BUILD_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat.
      CLEAR i_fieldcat[].
    *CLEAR wa_fieldcat.
    *wa_fieldcat-col_pos = 1.
    *wa_fieldcat-fieldname = 'CH'.
    **wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '2'.
    **wa_fieldcat-coltext = 'CHECKBOX'.
    *wa_fieldcat-checkbox = 'X'.
    *wa_fieldcat-edit        = 'X'.
    *APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'VBELN'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'SALES ORDER'.
    *wa_fieldcat-CHECKBOX = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 4.
      wa_fieldcat-fieldname = 'KUNNR'.
      wa_fieldcat-tabname = 'JTAB'.
      wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 3.
      wa_fieldcat-fieldname = 'ERDAT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '8'.
      wa_fieldcat-coltext = 'DATE'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 5.
      wa_fieldcat-fieldname = 'ERNAM'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '12'.
      wa_fieldcat-coltext = 'NAME'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 6.
      wa_fieldcat-fieldname = 'NETWR'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '15'.
      wa_fieldcat-coltext = 'NET WEIGHT'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 7.
      wa_fieldcat-fieldname = 'KNUMV'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'DOC COND'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 8.
      wa_fieldcat-fieldname = 'BSTNK'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUST PO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 9.
      wa_fieldcat-fieldname = 'KTEXT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '40'.
      wa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      wa_fieldcat-edit        = 'X'.
      wa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  ebuild_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM ebuild_fieldcat.
      CLEAR ei_fieldcat[].
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 1.
      ewa_fieldcat-fieldname = 'CH'.
    *ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '2'.
    *ewa_fieldcat-coltext = 'CHECKBOX'.
      ewa_fieldcat-checkbox = 'X'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 2.
      ewa_fieldcat-fieldname = 'VBELN'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'SALES ORDER'.
    *ewa_fieldcat-CHECKBOX = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 4.
      ewa_fieldcat-fieldname = 'KUNNR'.
      ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 3.
      ewa_fieldcat-fieldname = 'ERDAT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '8'.
      ewa_fieldcat-coltext = 'DATE'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 5.
      ewa_fieldcat-fieldname = 'ERNAM'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '12'.
      ewa_fieldcat-coltext = 'NAME'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 6.
      ewa_fieldcat-fieldname = 'NETWR'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '15'.
      ewa_fieldcat-coltext = 'NET WEIGHT'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 7.
      ewa_fieldcat-fieldname = 'KNUMV'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'DOC COND'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 8.
      ewa_fieldcat-fieldname = 'BSTNK'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUST PO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 9.
      ewa_fieldcat-fieldname = 'KTEXT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '40'.
      ewa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      ewa_fieldcat-edit        = 'X'.
      ewa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND ewa_fieldcat TO ei_fieldcat.
    ENDFORM.                    " ebuild_fieldcat

  • Selecting rows in ALV Grid using Classes

    I am displaying the output in ALV grid format.
    Now i am using cl_gui_alv_grid->Get_selected_ROWS to get the row index selected by User and on clicking a button it will take us to another screen which will hold the values of the selected row.
    Problem Faced: But when we again go back to the first screen and select another row  or same rows and click this button the selected rows index remains initial, that value is not getting captured.
    I cleared the parameters and refershed grid also.
    But the problem is not yet solved.
    Please Give me the solution.
    Regards,
    Balaji.

    Hi Lavanya,
    I did debugging also.
    First time Get_Selected_rows is working fine.
    But Second time it is failed.

  • Coulmn validation on ALV Grid (using Classes)

    Hi All,
       I'm creating a ALV Grid using calsses. I want to check the column value of Grid and raise some errror message. How to do this.
    Regards
    Jaker.

    have a look at sample report BCALV_EDIT_03

  • Regarding alv by using classes

    Hi Friends,
      Im Facing one problem. i.e my requirement is to display some fields by using alv grid.(using classes). here im displaying vbeln and exti1(truck Number) .when i click on vbeln it's need to be call the transaction VT02N .
    And other situation is when i click on exti1 then i need to call the some web browser to display GPS data.
    I searched a lot and i found some code in erp Genie but it's directly calling the web address but i need to call that based on hitspot or click on the particular field.
    Please help me in this Issue.
    Thanks,
    Srinivas.

    In ALV OO you need to register Events and then RAISE the event when hotspot is clicked. You can look at BCALV* programs that use OO approach.
    About opening the web browser with correct values, is this an internet (www) address that you want to go or is it a third party application to which SAP can pass data? You need to build the URL with the correct parameter and pass it to the web browser. There are a lot of WWW classes available in the Class Library, please have a look.
    Regards.

  • Doubt regarding editable ALV report using Classes

    I need to create an ALV report and make few fields editable
    and i need to update the changes  to the corresponding database tables
    for that please suggest me some idea or provide me sample code for that
    urgent

    Hi ramesh,
    Please check this example program. I think it will help for some extent.
    [code]&----
    *& Report  ZSUMA_INTERACTIVEREPORT                                     *
    report zsuma_interactivereport.
    tables: vbak.
    data :gr_alvgrid type ref to cl_gui_alv_grid,
          gr_cc_name type scrfname value 'CC_ALV',
          gr_ccontainer type ref to cl_gui_custom_container,
          gr_fieldcat type lvc_t_fcat,
          gr_layout type lvc_s_layo,
          gr_sort type lvc_t_sort,
          gr_get_cell type lvc_t_cell,
          gr_set_cell type lvc_t_cell,
          gr_hyper type lvc_t_hype,
          gr_drop_down type lvc_t_drop,
          is_variant type disvariant,
          line_number type lvc_s_roid-row_id,
          line(5) type c ,
          cell_value type lvc_value.
    data: begin of it_vbak occurs 0,
          vbeln type vbak-vbeln,
          erdat like vbak-erdat,
          erzet like vbak-erzet,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
    *Below field is useful for making the entire row with different colors.
    it must be a char of 4.and layout-info_fname should populate with
    *this field.
          rowcolor(4) type c,
    *Below field is useful for making the INDIVIDUAL CELL with different
    *colors.for this we have to include structure of type lvc_t_scol.
    *layout-ctab_fname should be populate with this field.
          cellcolor type lvc_t_scol,
    *below field is added for for providing the hyperlinks to perticular
    *field. at the time of field catalog , it_fcatalog-web_field should be
    *populate with this field.
          vbeln_hyper type int4,
    *For displaying one cell as button.we have to declare one styles
    *internal table .it has to be populate.at layout structure this table
    *name has to be populate at layout-stylename.
         cellstyle type lvc_t_styl,
          end of it_vbak.
    *&   SELECTION SCREEN
    selection-screen begin of block b1 with frame title text-001.
    select-options s_vbeln for vbak-vbeln.
    selection-screen end of block b1.
    start-of-selection.
    select vbeln
           erdat
           erzet
           netwr
           waerk
           from vbak
           into corresponding fields of table it_vbak
           where vbeln in s_vbeln.
    data: wa_cellcolor type lvc_s_scol,
          wa_style type lvc_s_styl.
    loop at it_vbak.
    FOR ROW COLORING
    if sy-tabix = 1.
    it_vbak-rowcolor = 'C511'.
    FOR PUTTING THE HYPERLINKS ON VBELN FIELD
    it_vbak-vbeln_hyper = '1'.
    modify it_vbak.
    endif.
    FOR CELL COLORING
    if sy-tabix = 2.
    wa_cellcolor-fname = 'ERZET'.
    wa_cellcolor-color-col = '6'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '1'.
    append wa_cellcolor to it_vbak-cellcolor.
    modify it_vbak index 2.
    endif.
    FOR DISPLAYING THE CELL AS A BUTTON
    clear it_vbak-cellstyle.
    at last.
    read table it_vbak index sy-tabix.
    wa_style-fieldname = 'NETWR'.
    wa_style-style = cl_gui_alv_grid=>mc_style_button.
    append wa_style to it_vbak-cellstyle .
    modify it_vbak .
    endat.
    endloop.
    if not it_vbak[] is initial.
      call screen 100.
    endif.
    *CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler definition.
    public section.
    methods:handle_hotspot_click
                  for event hotspot_click of cl_gui_alv_grid
                   importing e_row_id e_column_id es_row_no.
    endclass.
    *CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler implementation.
    method handle_hotspot_click.
    perform handle_hotspot_click using e_row_id e_column_id es_row_no.
    endmethod.
    endclass.
    *&      Form  BUILDING_FIELDCATALOG
          text
         <--P_GR_FIELDCAT  text
    form building_fieldcatalog  changing p_gr_fieldcat type lvc_t_fcat.
    data s_fieldcat type lvc_s_fcat.
    s_fieldcat-fieldname = 'VBELN'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '1'.
    s_fieldcat-coltext   = 'DOCCUMENT NO.'.
    s_fieldcat-key   = ' '.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-web_field = 'VBELN_HYPER'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERDAT'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '2'.
    s_fieldcat-coltext   = 'REC CREATE DATE.'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-hotspot = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERZET'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '3'.
    s_fieldcat-coltext   = 'TIME ENTRY.'.
    *S_FIELDCAT-EMPHASIZE = 'C311'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'NETWR'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '4'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-coltext   = 'NET WEIGHT.'.
    s_fieldcat-do_sum   = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'WAERK'.
    s_fieldcat-outputlen = '5'.
    s_fieldcat-col_pos   = '5'.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-coltext   = 'CURR.'.
    FOR PUTTING THE DROP DOWN BOX.
    s_fieldcat-drdn_hndl = '1'.
    s_fieldcat-edit = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    endform.                    " BUILDING_FIELDCATALOG
    *&      Form  CREATE_CCONTAINER_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_ccontainer_instance .
    create object gr_ccontainer
    exporting
    container_name              = gr_cc_name
    exceptions
    cntl_error                  = 1
    cntl_system_error           = 2
    create_error                = 3
    lifetime_error              = 4
    lifetime_dynpro_dynpro_link = 5
    others                      = 6
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endform.                    " CREATE_CCONTAINER_INSTANCE
    *&      Form  CREATE_ALVGRID_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_alvgrid_instance .
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        others            = 5
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform.                    " CREATE_ALVGRID_INSTANCE
    *&      Form  DISPLAYING_ALVGRID
          text
    -->  p1        text
    <--  p2        text
    form displaying_alvgrid .
    call method gr_alvgrid->set_table_for_first_display
      exporting
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
        is_variant                    = is_variant
        i_save                        = 'A'
       I_DEFAULT                     = 'X'
        is_layout                     = gr_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
        it_hyperlink                  = gr_hyper
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = it_vbak[]
        it_fieldcatalog               = gr_fieldcat
       it_sort                       = gr_sort
       IT_FILTER                     =
    EXCEPTIONS
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       others                        = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    *CALL METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
    IMPORTING
       ES_LAYOUT = GR_LAYOUT
    *GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
    *CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
    EXPORTING
       IS_LAYOUT = GR_LAYOUT
    endform.                    " DISPLAYING_ALVGRID
    *&      Form  REFRESH_DISPLAY_TABLE
          text
    -->  p1        text
    <--  p2        text
    form refresh_display_table .
    call method gr_alvgrid->refresh_table_display
    EXPORTING
       IS_STABLE      =
       I_SOFT_REFRESH =
      exceptions
        finished       = 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.                    " REFRESH_DISPLAY_TABLE
    *&      Form  SETTING_LAYOUT
          text
         <--P_GR_LAYOUT  text
    form setting_layout  changing p_gr_layout type lvc_s_layo.
    p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
    p_gr_layout-zebra = 'X'.
    p_gr_layout-no_toolbar = ''.
    p_gr_layout-sel_mode = 'D'.
    p_gr_layout-info_fname = 'ROWCOLOR'.
    p_gr_layout-ctab_fname = 'CELLCOLOR'.
    p_gr_layout-stylefname = 'CELLSTYLE'.
    endform.                    " SETTING_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    set pf-status 'MENU'.
    if gr_alvgrid is initial.
    *CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
    *TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
    perform create_ccontainer_instance.
    perform create_alvgrid_instance.
    *VARIANT POPULATION.
    perform setting_variants changing is_variant.
    *BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
    *TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
    perform setting_hyperlinks_field changing gr_hyper.
    *TO MAKE THE COLOUMN AS DROP DOWN.
    perform setting_dropdown_column changing gr_drop_down.
    perform building_fieldcatalog changing gr_fieldcat.
    perform setting_layout changing gr_layout.
    perform setting_sorting changing gr_sort.
    perform setting_cells changing gr_set_cell.
    perform displaying_alvgrid.
    *PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
                                                 FOR ME AND I HAVE DOUBT .
    perform creating_event_object.
    *PERFORM REFRESH_DISPLAY_TABLE.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'BACK'.
      leave to screen 000.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  SETTING_SORTING
          text
         <--P_GR_SORT  text
    form setting_sorting  changing p_gr_sort type lvc_t_sort.
    data: lr_sort type lvc_s_sort.
    lr_sort-spos = '1'.
    lr_sort-fieldname = 'VBELN'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    lr_sort-spos = '2'.
    lr_sort-fieldname = 'ERDAT'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    endform.                    " SETTING_SORTING
    *&      Form  GETTING_CELL_DETAILS
          text
         <--P_GR_GET_CELL  text
    form getting_cell_details  changing p_gr_get_cell.
    call method gr_alvgrid->get_selected_cells
      importing
        et_cell = p_gr_get_cell
    *CELL_VALUE = P_GR_GET_CELL-VALUE.
    endform.                    " GETTING_CELL_DETAILS
    *&      Form  SETTING_CELLS
          text
         <--P_GR_SET_CELL  text
    form setting_cells  changing p_gr_set_cell type lvc_t_cell.
    data:s_gr_set_cell type lvc_s_cell.
    s_gr_set_cell-col_id-fieldname = 'NETWR'.
    s_gr_set_cell-row_id-index = '3'.
    append s_gr_set_cell to p_gr_set_cell.
    call method gr_alvgrid->set_selected_cells
      exporting
        it_cells = p_gr_set_cell.
    endform.                    " SETTING_CELLS
    *&      Form  SETTING_HYPERLINKS_FIELD
          text
         <--P_GR_HYPER  text
    form setting_hyperlinks_field  changing p_gr_hyper type lvc_t_hype.
    data: is_hype type lvc_s_hype.
    is_hype-handle = '1'.
    is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
    append is_hype to p_gr_hyper.
    is_hype-handle = '2'.
    is_hype-href = 'HTTP://SDN.SAP.COM'.
    append is_hype to p_gr_hyper.
    endform.                    " SETTING_HYPERLINKS_FIELD
    *&      Form  SETTING_DROPDOWN_COLUMN
          text
         <--P_GR_DROP_DOWN  text
    form setting_dropdown_column  changing p_gr_drop_down type lvc_t_drop.
    data: wa_drop type lvc_s_drop.
    wa_drop-handle = '1'.
    wa_drop-value = '$'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'Rs'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'CUR'.
    append wa_drop to p_gr_drop_down.
    call method gr_alvgrid->set_drop_down_table
      exporting
        it_drop_down       = p_gr_drop_down
       IT_DROP_DOWN_ALIAS =
    endform.                    " SETTING_DROPDOWN_COLUMN
    *&      Form  SETTING_VARIANTS
          text
         <--P_IS_VARIANT  text
    form setting_variants  changing p_is_variant type disvariant.
    p_is_variant-report = sy-repid.
    endform.                    " SETTING_VARIANTS
    *&      Form  HANDLE_HOTSPOT_CLICK
          text
         -->P_E_ROW  text
         -->P_E_COLUMN  text
         -->P_E_ROW_NO  text
    form handle_hotspot_click  using    p_e_row_id type lvc_s_row
                                        p_e_column_id type lvc_s_col
                                        p_es_row_no type lvc_s_roid.
    read table it_vbak index p_es_row_no-row_id.
    if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
    line = p_es_row_no-row_id.
    line_number = p_es_row_no-row_id.
    leave to screen 200.
    endif.
    endform.                    " HANDLE_HOTSPOT_CLICK
    *&      Form  CREATING_EVENT_OBJECT
          text
    -->  p1        text
    <--  p2        text
    form creating_event_object .
    data event_handle type ref to gr_event_handler.
    create object event_handle.
    set handler event_handle->handle_hotspot_click for gr_alvgrid.
    endform.                    " CREATING_EVENT_OBJECT
    *&      Module  STATUS_0200  OUTPUT
          text
    module status_0200 output.
      set pf-status 'BB'.
    SET TITLEBAR 'xxx'.
    *LINE = LINE_NUMBER.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module user_command_0200 input.
    if sy-ucomm = 'BACK'.
    leave to screen 100.
    endif.
    endmodule.                 " USER_COMMAND_0200  INPUT[/code]
    Reward points if helpful
    Thanks,
    Suma.

  • ALV List using Classes

    I am using CL_GUI_ALV_GRID for displaying the report in ALV Grid.
    What are classes/methods used for displaying report in ALV List format.

    If you are running a release prior to NetWeaver 2004, then you must use the function module REUSE_ALV_LIST_DISPLAY. If you are on NetWeaver 2004 or 7.0, you can use the ALV object model  class which allows you to force the list display.
    REPORT zrich_0001.
    DATA: ispfli TYPE TABLE OF spfli.
    DATA: gr_table TYPE REF TO cl_salv_table.
    DATA: gr_functions TYPE REF TO cl_salv_functions.
    START-OF-SELECTION.
      SELECT * INTO TABLE ispfli FROM spfli.
      cl_salv_table=>factory(
        EXPORTING
          list_display   = if_salv_c_bool_sap=>true
        IMPORTING
          r_salv_table   = gr_table
        CHANGING
          t_table        = ispfli ).
      gr_functions = gr_table->get_functions( ).
      gr_functions->set_all( abap_true ).
      gr_table->display( ).
    Regards,
    Rich Heilman

  • Alv reports using class

    Hi
    I waana develop an alv report(OOPS) using 3 different tables. I waana know since i have to output fields from 3 different tables depending upon selection criteria. So can any body  tell me how to use field catalog or field catalog merge using class.... not function REUSE alv

    Hello Preet,
    For creating the Field catalog
    Internal table for Field Catalog
    DATA: G_T_FIELDCAT_C TYPE LVC_T_FCAT,
          G_R_FIELDCAT   TYPE LVC_S_FCAT.
    FORM BUILD_FIELD_CATALOG .
      DATA: L_F_COUNT TYPE I VALUE '0'.
    */ Add properties values to ALV Catalog
      ADD 1 TO L_F_COUNT.
      PERFORM ADD_CATALOG USING 'MTART' 'C'  SPACE  L_F_COUNT    "Sales Org
                                TEXT-005 4   SPACE SPACE SPACE.
      ADD 1 TO L_F_COUNT.
      PERFORM ADD_CATALOG USING 'VKORG' 'C'  SPACE  L_F_COUNT    "Sales Org
                                TEXT-001 4   SPACE SPACE SPACE.
      ADD 1 TO L_F_COUNT.
      PERFORM ADD_CATALOG USING 'MATNR' 'C'  SPACE  L_F_COUNT
                                TEXT-002 18  'MATN1' SPACE SPACE.
      ADD 1 TO L_F_COUNT.
      PERFORM ADD_CATALOG USING 'STAWN' 'C'  SPACE  L_F_COUNT
                                TEXT-004 13  SPACE SPACE SPACE.
    ENDFORM.                    " build_field_catalog
    FORM ADD_CATALOG USING   P_FNAME
                             P_INTTYPE
                             P_KEY
                             P_COL_POS
                             P_COL_TEXT
                             P_INTLEN
                             P_CONV
                             P_EDIT
                             P_HOTSPOT.
      CLEAR G_R_FIELDCAT.
      G_R_FIELDCAT-FIELDNAME  = P_FNAME.
      G_R_FIELDCAT-INTTYPE    = P_INTTYPE.
      G_R_FIELDCAT-KEY        = P_KEY.
      G_R_FIELDCAT-COL_POS    = P_COL_POS.
      G_R_FIELDCAT-COLTEXT    = P_COL_TEXT.
      G_R_FIELDCAT-OUTPUTLEN  = P_INTLEN.
      G_R_FIELDCAT-CONVEXIT   = P_CONV.
      G_R_FIELDCAT-EDIT       =  P_EDIT.
      G_R_FIELDCAT-HOTSPOT    = P_HOTSPOT.
      APPEND G_R_FIELDCAT TO G_T_FIELDCAT_C.
    ENDFORM.                    " add_catalog
    If useful reward.
    Vasanth

Maybe you are looking for

  • Facing prolem  in Dashboard 4.1, while fetching data from Bex Query

    Hi Exports, I am facing an error message  " Failed to (de-)serialise data. (Xsl 000004)"  while fetching data in Dashboard from Bex Query. The query is getting connect. while drag n drop some dimensions and measures then going for Refesh or Run Query

  • Download and installing oracle odbc driver alone

    Hi all, I wanted to find out if I can download just the oracle odbc driver and install in without actually installing oracle database or client version on windows PC. thank you

  • Burn issues

    IDvd finds errors in the burn of my dvd everytime. I redid the entire movie and layout many times with no help. This is especially wierd because it only does it with this one file. Help.

  • Zattoo + FP11 none IE + 16:10 fullscreen = thick black borders

    Hello there seems to be still problems with 16:10 monitors and www.Zattoo.com (germany) with Flash Player 11 (none IE) in fullscreen mode. As you can see there are thick black borders around the video: Tested today with Firefox Nightly 20110923 32&64

  • Conky BAT0 problem [SOLVED]

    Hello. When I start conky I get this: Conky: can't open /sys/class/power_supply/BAT0p/uevents: no such file or directory Conky: can't open /proc/acpi/battery/BAT0p/state: no su........ Isn't it a p that shouldn't be there. The dir BAT0 does exist. La