ALV FCODE in Method HANDLE_ITEM_CHANGED

I'm calling the following method from my ALV grid to handle editable fields
      HANDLE_ITEM_CHANGED
            FOR EVENT DATA_CHANGED_FINISHED
                            OF CL_GUI_ALV_GRID
                     IMPORTING E_MODIFIED
                               ET_GOOD_CELLS,
I only want to check these changes when a new SAVE button is pushed on the tool bar. How do I check the FCODE for when this button is pressed so the method is only invoked at this button push?
Thanks Mart

Hi Mart,
On the push of save button call the following method of the class cl_gui_alv_grid.
  CALL METHOD g_grid->check_changed_data
    IMPORTING
      e_valid   = w_valid
   CHANGING
     c_refresh = c_x
Other than that you can suppress the log message from coming by calling following method inside the handler of event DATA_CHANGED.
   CALL METHOD us_data_changed->refresh_protocol .
I have tried this and this had worked for me.
Regards
Avinash

Similar Messages

  • How to add a new button in an ALV using factory method

    im using factory method to creat an ALV
    The reason why I'm doing this is because I want the ALV and the selection screen in the same screen like exemplified here http://help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html
    CALL METHOD cl_salv_table=>factory
                EXPORTING
                  list_display   = if_salv_c_bool_sap=>false
                  r_container    = lo_cont
                  container_name = 'DOCK_CONT'
                IMPORTING
                  r_salv_table   = lo_alv
                CHANGING
                  t_table        = me->t_data.
    The above code already uses every parameter that method as to offer.
    Is it possible to add extra buttons to an ALV using that method?

    Hi Ann,
    The reason you are not able to see any of the new columns as a option to select in your web service block is because when you have published that block, they were not present. Add these two new objects in your block and publish it again. You will be prompted for duplication content. Select the highlighted block for duplicate and now you can see the new added objects in the filter option. Update and this will overwrite your published block. Please note, web services do appear to behave weirdly when used with dashboards so I request you to please try it in a separate test report first.
    Hope that helps.
    Regards,
    Tanisha

  • Possible to have vertical scroll bar for a cell in ALV Grid (using methods)

    Hi All,
    I have a field with length 100 characters on a ALV Grid (using methods)..User doesn't want to scroll all the 100 characters horizontally to see the whole text rather he wants to have a vertical scroll bar for the cell so that he can scroll vertically.
    Is it possible to have split the cell text into lines and have a vertical scroll bar for a cell in ALV Grid?
    Regards
    Jaker.

    Thanks for the suggestion Balu.I tried this , but while scrolling,headers also getting scrolled.
    Becoz of this , if i scroll down to the last row,headers are getting hidden.
    Headers should always be static.only the data should scroll.
    Since h:datatable is being rendered as one table , i can div tag for this table alone.
    If i have seperate datatable for headers alone i can do this .But i should not use two datatables.

  • Coloring an single field of an ALV using factory method

    how can we color just a single field in ALV using factory method.

    Hello Regi you may want to check this sample code, basically what you need is to use the lvc_s_colo structure and the  set_color method of the class cl_salv_column_table.
    METHOD set_colors.
    *.....Color for COLUMN.....
        DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
              lo_col_tab  TYPE REF TO cl_salv_column_table.
        DATA: ls_color TYPE lvc_s_colo.    " Colors strucutre
    *   get Columns object
        lo_cols_tab = co_alv->get_columns( ).
        INCLUDE <color>.
    *   Get ERDAT column & set the yellow Color fot it
        TRY.
            lo_col_tab ?= lo_cols_tab->get_column( 'ERDAT' ).
            ls_color-col = col_total.
            lo_col_tab->set_color( ls_color ).
          CATCH cx_salv_not_found.
        ENDTRY.
    *.......Color for Specific Cell & Rows.................
    *   Applying color on the 3rd Row and Column AUART
    *   Applying color on the Entire 5th Row
        DATA: lt_s_color TYPE lvc_t_scol,
              ls_s_color TYPE lvc_s_scol,
              la_vbak    LIKE LINE OF ct_vbak,
              l_count    TYPE i.
        LOOP AT ct_vbak INTO la_vbak.
          l_count = l_count + 1.
          CASE l_count.
    *       Apply RED color to the AUART Cell of the 3rd Column
            WHEN 3.
              ls_s_color-fname     = 'AUART'.
              ls_s_color-color-col = col_negative.
              ls_s_color-color-int = 0.
              ls_s_color-color-inv = 0.
              APPEND ls_s_color TO lt_s_color.
              CLEAR  ls_s_color.
    *       Apply GREEN color to the entire row # 5
    *         For entire row, we don't pass the Fieldname
            WHEN 5.
              ls_s_color-color-col = col_positive.
              ls_s_color-color-int = 0.
              ls_s_color-color-inv = 0.
              APPEND ls_s_color TO lt_s_color.
              CLEAR  ls_s_color.
          ENDCASE.
    *     Modify that data back to the output table
          la_vbak-t_color = lt_s_color.
          MODIFY ct_vbak FROM la_vbak.
          CLEAR  la_vbak.
          CLEAR  lt_s_color.
        ENDLOOP.
    *   We will set this COLOR table field name of the internal table to
    *   COLUMNS tab reference for the specific colors
        TRY.
            lo_cols_tab->set_color_column( 'T_COLOR' ).
          CATCH cx_salv_data_error.                         "#EC NO_HANDLER
        ENDTRY.
      ENDMETHOD.                    "set_colors

  • ALV grid using methods: how to get modified cells

    Hi all,
    IAM USING alv grid using methods,
    i have few fields as editable
    if the user edits any of those fields how can i know which cell is modified and what is the new value.
    i tried to use method get_modified_cells
    but iam getting a msg saying protected method and u can  not use.
    please advise.
    thanks
    JAfar

    Jafar,
    You need to Take the Help of DATA_CHANGED event, when ever there is a change in the Grid, it will trigger, here you can capture the Cells which are modified.
    in your PAI call the method check changed data
    CL_GUI_ALV_GRID-->CHECK_CHANGED_DATA
    You need to set the handler for datachanged.
    set the handler for this, and register the event modified or enter.
    **Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER,
    **Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
    DATA: X_CHANGE TYPE LVC_S_MODI.  "modified cells
        LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
        ENDLOOP.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED
    Regards
    Vijay

  • ALV Grid Using Methods-handle_top_of_page

    riends please explain how to resolve the below issue.
      I am working on ALV Grid using methods & trying to display
    page heading using handle_top_of_page event.
      I have defined & implemented the above method and in the implementation I have
    given a write statement, which has to be displayed on the top of page.
      I have also set the handler for top of page.
    The program does not have any errors, but top of page event is not triggered, what might be the problem.
    Regards,
    Usha

    Hi,
    Check this code
    Class definition :
          CLASS v_lcl_event_receiver DEFINITION
    CLASS v_lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_print_top_of_page FOR EVENT print_top_of_page OF
                                           cl_gui_alv_grid,
        handle_top_of_page FOR EVENT top_of_page OF
                                     cl_gui_alv_grid.
    ENDCLASS.
          CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION
    CLASS v_lcl_event_receiver IMPLEMENTATION.
      METHOD handle_print_top_of_page.
        IF sy-pagno = 1.
            PERFORM top_of_page.
        ENDIF.
      ENDMETHOD.
      METHOD handle_top_of_page.
          PERFORM top_of_page.
      ENDMETHOD.
    ENDCLASS.
    DATA:        v_event_receiver      TYPE REF TO v_lcl_event_receiver.
    FORM top_of_page.
      WRITE: text-020,
    ENDFORM.                    " top_of_page
    In PBo of the screen
       DATA: v_split            TYPE REF TO cl_gui_easy_splitter_container,
             v_contnr_top       TYPE REF TO cl_gui_container,
             v_contnr_bot       TYPE REF TO cl_gui_container,
             v_grid_02          TYPE REF TO cl_gui_alv_grid,
             v_html             TYPE REF TO cl_dd_document,
             v_text20(255)      TYPE c,
             v_text16(255)      TYPE c,
    FORM f9000_objects_create.
      IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    Create a container
        CREATE OBJECT o_dockingcontainer
          EXPORTING
            ratio                       = '95'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            others                      = 6.
        IF sy-subrc NE 0.
          MESSAGE i000 WITH text-e01."Error in creating Docking container
          LEAVE LIST-PROCESSING.
        ENDIF.
        CREATE OBJECT v_split
             EXPORTING
               parent            = o_dockingcontainer
             ORIENTATION       = 0
               sash_position     = 25
               with_border       = 0
             EXCEPTIONS
               cntl_error        = 1
               cntl_system_error = 2
               others            = 3.
        IF sy-subrc NE 0.
          MESSAGE i000 WITH text-e01."Error in creating Docking container
          LEAVE LIST-PROCESSING.
        ENDIF.
      Get the containers of the splitter control
        v_contnr_top = v_split->top_left_container.
        v_contnr_bot = v_split->bottom_right_container.
        CREATE OBJECT o_alvgrid
       EXPORTING
         i_parent = o_dockingcontainer.
      Create an instance of alv control
        CREATE OBJECT o_alvgrid
             EXPORTING i_parent = v_contnr_bot.
      Object for display of selection parameters in HTML top container
        CREATE OBJECT v_html
             EXPORTING
               style = 'ALV_GRID'.
      Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
        CALL METHOD o_alvgrid->list_processing_events
                         EXPORTING i_event_name = 'TOP_OF_PAGE'
                                   i_dyndoc_id  = v_html.
        v_text20 = text-020(summary Record counts)Any text.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 120.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text20.
        CALL METHOD v_html->new_line.
    Display Text-016
        v_text16 = text-016.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 1.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text16.
        v_text16 = v_sap_recon.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 1.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text16.
        CALL METHOD v_html->new_line.
    Display the data
        CALL METHOD v_html->display_document
          EXPORTING
             parent             = v_contnr_top.
      Handle the event
        CALL METHOD o_alvgrid->list_processing_events
                            EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.
    IN PBO while populating in the output table
    FORM f9004_display_data TABLES   p_report_tab
                                     p_fieldcat.
      CALL METHOD o_alvgrid->set_table_for_first_display
        EXPORTING
           is_variant                    = w_variant
           i_save                        = c_a
           is_layout                     = w_layout
        CHANGING
           it_outtab                     = p_report_tab[]
           it_fieldcatalog               = p_fieldcat[]
        EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
    Create object
      IF v_event_receiver IS INITIAL.
        CREATE OBJECT v_event_receiver.
      ENDIF.
      SET HANDLER v_event_receiver->handle_print_top_of_page FOR o_alvgrid.
      SET HANDLER v_event_receiver->handle_top_of_page FOR o_alvgrid.
    Hope this helps.

  • Call ALV gid inside Method using class

    Hi all,
    I have created one method in my ZClass, in that i need to write code for display a pop-up(ALV) that should contain the internal table records. Also if i double click a cell in that popup then a transaction(say ztest) should be called..
    How to do this inside the method?
    Thanks,
    Ranjith C.

    Hi,
    You can call screen in you class and assign the custum container to the screen, using cl_gui_alv_grid class assing created object to container and create fields catlog and internal table with data to display in alv. call the method set_table_for_first_display to display data.
    You can also used the method get_selected_rows to read current selected line data can use call transaction.
    For more details you can used the pakage slis there are may program are avaible to resolve your problem.

  • How to add button in ALV report (Class method )?

    Hello experts,
    I have developed one ALV report using classes.
    I want to add one more  button on the report like already is there named DISPLQUA
    How ca i do that here?
    Following the code of CLASS definition & implimentation
    CLASS lcl_handle_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_on_user_command FOR EVENT added_function OF cl_salv_events
            IMPORTING e_salv_function.
    ENDCLASS.                    "lcl_handle_events DEFINITION
          CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD handle_on_user_command.
        CASE e_salv_function.
          WHEN 'DISPLQUA'.
            PERFORM show_quant_record.
         WHEN 'DISPQM03'.                                " Here i want to add button
           PERFORM display_quality_notification.
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.                    "handle_on_user_command
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

    HI Ronny.
    Code snippet for reference.
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION.
        METHODS :
    *--Toolbar control
          HANDLE_TOOLBAR FOR EVENT TOOLBAR
            OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
                                         E_INTERACTIVE,
    ENDCLASS
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *--handle toolbar
      METHOD HANDLE_TOOLBAR.
    * append a separator to normal toolbar
        CLEAR G_TOOLBAR.
        G_TOOLBAR-BUTN_TYPE = 3.
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
        CLEAR G_TOOLBAR.
        G_TOOLBAR-FUNCTION = 'SAVE'.
        G_TOOLBAR-ICON = ICON_SYSTEM_SAVE.
        G_TOOLBAR-BUTN_TYPE = 0.
        G_TOOLBAR-QUICKINFO = 'Save the Customer'(203).
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
      ENDMETHOD.                    "HANDLE_TOOLBAR
    Hope this helps.
    Gary.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 7, 2008 5:41 PM

  • How to make a field manadatory within ALV Grid using methods and classes

    Hi,
    I am using ALV Grid using set_table_for_first_display
    inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
    I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
    Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
    Is there any other way, i can accomplish this within the ALV grid?

    from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
    i dont know anthing in fieldcat, but u can try the following logic.
    FORM DATA_CHANGED  USING P_ER_DATA_CHANGED TYPE REF TO
    CL_ALV_CHANGED_DATA_PROTOCOL .
      DATA: L_VALUE TYPE LVC_VALUE,
        ls_mod_cell type lvc_s_modi.
      READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
    if sy-subrc = 0.
        CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = LS_MOD_CELL-row_id
            I_FIELDNAME = LS_MOD_CELL-fieldname
          IMPORTING
            E_VALUE     = L_VALUE.
    IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.
    ELSE.
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.

  • Calling Transaction from ALV using OO Method

    Hi,
    My requirement is as follows....
    I have an ALV grid with columns such as month wise Total of a GL account  say JAN, feb etc...
    When I double click on any of these cells it should take me to the respective Transaction (say FBL3n for the GL account and the company code) . I am able to track the GL account for which the total is displayed and company code is one of my selection criteria. In the main screen of the FBL3N we have to enter the posting date and i also want the Radio button against "all items', presently default is against 'Open Items'. So how can i proceed.
    Thanks and Regards,
    Namit

    DATA gr_event_handler TYPE REF TO lcl_event_handler . .. ..
    *--Creating an instance for the event handler
    CREATE OBJECT gr_event_handler .
    *--Registering handler methods to handle ALV Grid events
    SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
    CLASS lcl_event_handler IMPLEMENTATION .
    *Handle Double Click
    METHOD handle_double_click .
    PERFORM handle_double_click USING e_row e_column es_row_no .
    ENDMETHOD .
    CLASS lcl_event_handler DEFINITION
    *Double-click control
    Methods:
    handle_double_click
          FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING e_row e_column
               i_fieldrows      TYPE lvc_t_row.
               w_fieldrows LIKE LINE OF i_fieldrows,
      CALL METHOD o_alvgrid->get_selected_rows
                 IMPORTING
                 et_index_rows = i_fieldrows.
      LOOP AT i_fieldrows INTO w_fieldrows.
        READ TABLE i_batch INTO w_block INDEX w_fieldrows-index.
    if sy-subrc = 0.
    *       CLASS LCL_EVENT_RECEIVER DEFINITION
    CLASS LCL_EVENT_RECEIVER DEFINITION.
    * Event receiver definitions for ALV actions
      PUBLIC SECTION.
        CLASS-METHODS:
    * Row Double click for dirll down.
           HANDLE_DOUBLE_CLICK
             FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                IMPORTING E_ROW
                          E_COLUMN
                          ES_ROW_NO.
    ENDCLASS.
    * Implementation
    * Every event handler that is specified below should also be set after
    * the object has been created.  This is done in the PBO processing.
    * with the following command
    * SET HANDLER oEventreceiver->handle_toolbar FOR o_Alvgrid.
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
    *&      Method handle_double_click
    * This method is called when the user double clicks on a line to drill
    * down.
    * The following are exported from the ALV
    * LVC_S_ROW
    * LVC_S_COL
    * LVC_S_ROID
      METHOD HANDLE_DOUBLE_CLICK.
    * The double click drill down processing should be
    * coded in the form below.
       PERFORM F9007_HANDLE_DOUBLE_CLICK USING E_ROW
                                               E_COLUMN
                                               ES_ROW_NO.
      ENDMETHOD.
    ENDCLASS.
    *&      Form  F9007_HANDLE_DOUBLE_CLICK
    * This form is called when the user double clicks on a line to drill
    * down.
    *      -->P_E_ROW_ID    - Row ID  text
    *      -->P_E_COLUMN_ID - Column ID
    *      -->P_ES_ROW_NO   - Row number
    FORM f9007_handle_double_click USING p_row
                                         p_column
                                         p_row_no.
      DATA: lw_output LIKE LINE OF i_output.
    * RG:16/11/2004 - Start of Changes
    * Need to check that a subtotal or grand total line has not been
    * double-clicked, otherwise the report will produce a short dump!
      check p_row+0(1) is initial.
    * RG:16/11/2004 - End of Changes
      READ TABLE i_output INDEX p_row INTO lw_output.
      CASE p_column.
        WHEN 'KNUMA'.
          IF NOT lw_output-knuma IS INITIAL.
            SET PARAMETER ID 'VBO' FIELD lw_output-knuma.
            CALL TRANSACTION 'VBO3' AND SKIP FIRST SCREEN.
          ENDIF.
        WHEN 'VBAK_VBELN'.
         IF NOT lw_output-vbak_vbeln IS INITIAL.
          SET PARAMETER ID 'AUN' FIELD lw_output-vbak_vbeln.
            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
          ENDIF.
        WHEN 'VBRK_VBELN'.
          IF NOT lw_output-vbrk_vbeln IS INITIAL.
            SET PARAMETER ID 'VF' FIELD lw_output-vbrk_vbeln.
            CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.                    " F9007_HANDLE_DOUBLE_CLICK

  • Back button issue in ALV Grid(Factory method)

    Hi All,
    I have displayed a report using factory method(CL_SALV_TABLE).In that i have added buttons in application bar too.So when clicking on refresh button ALV should display again with latest number of records,that is working fine but when clicking on back button it should go to selection screen instead of that it is going a step back and displaying previous list of grid and then back and then selection screen.
    Can any one help me how to directly go to input selection screen instead of going step back...
    Regards,
    Ram

    HI,
    Use this syntax (CALL SELECTION-SCREEN 1000)...Try this one
    regards,
    balaji

  • Problem in Checkbox on/off in ALV using OO method

    Hi,
    I am working on an ALV display using OO method.The first field is check box in the display.
    I declared the internal table type  as
    TYPES: BEGIN OF ty_output,
             chk_box(1) TYPE c,
             id_rech    TYPE yyeft1200-id_rech,
             bprefnr    TYPE yyeft1201-bprefnr,
             lfdat      TYPE yyeft1201-lfdat,
             artnr_bp   TYPE yyeft1201-artnr_bp,
               end of ty_output.
    and in fieldcatalog i have used
    Check Box
            CLEAR ls_fcat.
            ls_fcat-fieldname  = 'CHK_BOX'.
            ls_fcat-datatype   = 'CHAR'.
            ls_fcat-intlen     = '1'.
            ls_fcat-edit       = kc_x.
            ls_fcat-coltext    = text-014.
            ls_fcat-checkbox   = kc_x.
            ls_fcat-outputlen  = '5'.
            APPEND ls_fcat TO pit_fieldcat. 
    All the check boxes are in editable mode.
    Now the requirement is that for some records of the internal table it should be editable and for some records it should be non-editable.
    can you please help me how to do it.

    Hi,
              You might want to look at the example programs. Any program which begins with <b>BCALV_EDIT*</b>
    You can find the code in this program 'BCALV_FIELDCAT_TEST'
    *& Report  BCALV_FIELDCAT_TEST                                         *
    This report allows to modify the fieldcatalog of a corresponding
    output table and to view the effects of your changes directly.
    Note that for some changes you need to newly display the whole
    ALV Grid Control, e.g., DDIC-Fields are read only the first time
    you call SET_READY_FOR_FIRST_DISPLAY.
    Note also that not all scenarios can be tested since the output
    table does not comprise all fields to test available features
    of the fieldcatalog. Copy this program and extend the output
    table accordingly if you want to test such a special feature.
    (The field CARRNAME in 'gt_sflight' was added to test field REF_FIELD
    and TXT_FIELD of the fieldcatalog - see what happens if you
    calculate subtotals by carrier-id).
    report  bcalvt_fieldcatalog           .
    data: ok_code               type sy-ucomm,
          save_ok_code          type sy-ucomm,
    fieldcatalog for output table
          gt_fieldcat           type lvc_t_fcat,
    fieldcatalog for fieldcatalog itself:
          gt_fcatfcat           type lvc_t_fcat,
          gs_fcatlayo           type lvc_s_layo.
    Output table
    data: begin of gt_sflight occurs 0.
    data: carrname type s_carrname.
            include structure sflight.
    data: end of gt_sflight.
    data: g_max type i value 100.
    data: g_all type c value SPACE.
    Controls to display gt_sflight and corresponding fieldcatalog
    data: g_docking type ref to cl_gui_docking_container,
          g_alv     type ref to cl_gui_alv_grid.
    data: g_custom_container type ref to cl_gui_custom_container,
          g_editable_alv     type ref to cl_gui_alv_grid.
    LOCAL CLASS Definition
    class lcl_event_receiver definition.
      public section.
        methods handle_data_changed
          for event data_changed of cl_gui_alv_grid
          importing er_data_changed.
    endclass.
    class lcl_event_receiver implementation.
      method handle_data_changed.
    at the time being, no checks are made...
      endmethod.
    endclass.
    data: event_receiver type ref to lcl_event_receiver.
    end-of-selection.
      set screen 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
      set pf-status 'BASIC'.
      set titlebar 'BASICTITLE'.
    create ALV Grid Control in the first run
      if g_docking is initial.
        perform create_and_init_controls.
      endif.
    endmodule.                             " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
      save_ok_code = ok_code.
      clear ok_code.
      case save_ok_code.
        when 'SUBMIT'.
    set the frontend fieldcatalog
    ATTENTION: DDIC-Fields are not updated using this method!
    (see 'RESTART')
          call method g_alv->set_frontend_fieldcatalog
               exporting
                 it_fieldcatalog = gt_fieldcat.
          call method g_alv->refresh_table_display.
          call method cl_gui_cfw=>flush.
        when 'RESTART'.
    Destroy the control currently visible and display it again
    using the changed fieldcatalog.
          perform restart_sflight.
        when '&ALL'.
          perform switch_visibility.
      endcase.
    endmodule.                             " USER_COMMAND_0100  INPUT
    *&      Form  CREATE_AND_INIT_CONTROLS
          text
    -->  p1        text
    <--  p2        text
    form create_and_init_controls.
      create object g_docking
          exporting
               dynnr = '100'
               extension = 150
               side = cl_gui_docking_container=>dock_at_bottom.
      create object g_alv
          exporting
               i_parent = g_docking.
      create object g_custom_container
          exporting
               container_name = 'CC_0100_FIELDCAT'.
      create object g_editable_alv
          exporting
               i_parent = g_custom_container.
    register events
      create object event_receiver.
      set handler event_receiver->handle_data_changed for g_editable_alv.
      call method g_editable_alv->register_edit_event
                    exporting
                       i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      perform build_fieldcatalogs changing gt_fieldcat gt_fcatfcat.
      perform modify_fieldcatalog changing gt_fcatfcat.
      perform select_data.                 "CHANGING gt_sflight
      call method g_alv->set_table_for_first_display
              changing
                   it_outtab       = gt_sflight[]
                   it_fieldcatalog = gt_fieldcat[].
    optimize column width of grid displaying fieldcatalog
      gs_fcatlayo-cwidth_opt = 'X'.
    Get fieldcatalog of table sflight - alv might have
    modified it after passing.
      call method g_alv->get_frontend_fieldcatalog
                importing et_fieldcatalog = gt_fieldcat[].
      call method cl_gui_cfw=>flush.
    Display fieldcatalog of table sflight:
      call method g_editable_alv->set_table_for_first_display
              exporting
                   is_layout       = gs_fcatlayo
              changing
                   it_outtab       = gt_fieldcat[]
                   it_fieldcatalog = gt_fcatfcat[].
    register events
      create object event_receiver.
      set handler event_receiver->handle_data_changed for g_editable_alv.
    endform.                               " CREATE_AND_INIT_CONTROLS
    *&      Form  restart_sflight
          text
    -->  p1        text
    <--  p2        text
    form restart_sflight.
      data: ls_fieldcat type lvc_s_fcat.
    free g_docking and thus g_alv
      call method g_docking->free.
      clear g_docking.
      clear g_alv.
    create new instances
      create object g_docking
          exporting
               dynnr = '100'
               extension = 150
               side = cl_gui_docking_container=>dock_at_bottom.
      create object g_alv
          exporting
               i_parent = g_docking.
    This is an internal method to invalidate all fields in the fieldcat
      loop at gt_fieldcat into ls_fieldcat.
        clear ls_fieldcat-tech_comp.
        modify gt_fieldcat from ls_fieldcat.
      endloop.
    Newly display the list with current fieldcatalog.
      call method g_alv->set_table_for_first_display
              changing
                   it_outtab       = gt_sflight[]
                   it_fieldcatalog = gt_fieldcat.
    Get fieldcatalog - it might be changed by ALV in the last call
      call method g_alv->get_frontend_fieldcatalog
              importing
                   et_fieldcatalog = gt_fieldcat[].
      call method g_editable_alv->refresh_table_display.
      call method cl_gui_cfw=>flush.
    endform.                               " restart_sflight
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    form select_data.
      data: lt_sflight type table of sflight with header line,
            ls_scarr type scarr.
    select data of sflight
      select * from sflight into table lt_sflight up to g_max rows.
    copy data to gt_sflight and update CARRNAME
      loop at lt_sflight.
        move-corresponding lt_sflight to gt_sflight.
        select single * from scarr into ls_scarr
           where carrid = gt_sflight-carrid.
        gt_sflight-carrname = ls_scarr-carrname.
        append gt_sflight.
      endloop.
    endform.                               " select_data
    *&      Form  BUILD_FIELDCATALOGS
          text
         <--P_GT_FIELDCAT  text
         <--P_GT_FCATFCAT  text
    form build_fieldcatalogs changing p_fieldcat type lvc_t_fcat
                                      p_fcatfcat type lvc_t_fcat.
      data: ls_fcat     type lvc_s_fcat.
    Fieldcatalog for table SFLIGHT: p_fieldcat
    generate fieldcatalog automatically
      call function 'LVC_FIELDCATALOG_MERGE'
          exporting
               i_structure_name       = 'SFLIGHT'
            I_CLIENT_NEVER_DISPLAY = 'X'
           changing
                ct_fieldcat            = p_fieldcat[]
       EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    shift all column positions to the right except for MANDT
      loop at p_fieldcat into ls_fcat.
        if ls_fcat-fieldname ne 'MANDT'.
          add 1 to ls_fcat-col_pos.
          if ls_fcat-fieldname = 'CARRID'.
            ls_fcat-txt_field = 'CARRNAME'."link CARRNAME to CARRID
          endif.
          modify p_fieldcat from ls_fcat.
        endif.
      endloop.
    create a new line for CARRNAME in p_fieldcat
      clear ls_fcat.
      ls_fcat-fieldname = 'CARRNAME'.
      ls_fcat-ref_table = 'SCARR'.
      ls_fcat-col_pos = 1.
    insert new line before CARRID (do not forget MANDT!).
      insert ls_fcat into p_fieldcat index 1.
    Fieldcatalog for table LVC_T_FCAT:p_fcatfcat
    Generate fieldcatalog of fieldcatalog structure.
    This fieldcatalog is used to display fieldcatalog 'p_fieldcat'
    on the top of the screen.
      call function 'LVC_FIELDCATALOG_MERGE'
          exporting
               i_structure_name       = 'LVC_S_FCAT'
            I_CLIENT_NEVER_DISPLAY = 'X'
           changing
                ct_fieldcat            = p_fcatfcat[]
       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.
    Hide all fields that are not documented (valid for release 4.6A)
      perform hide_fields changing p_fcatfcat.
    endform.                               " BUILD_FIELDCATALOGS
    *&      Module  EXIT_PROGRAM  INPUT
          text
    module exit_program input.
      leave program.
    endmodule.                             " EXIT_PROGRAM  INPUT
    *&      Form  MODIFY_FIELDCATALOG
          text
         <--P_GT_FCATFCAT  text
    form modify_fieldcatalog changing p_fcatfcat type lvc_t_fcat.
      data ls_fcat type lvc_s_fcat.
      loop at p_fcatfcat into ls_fcat.
        ls_fcat-coltext = ls_fcat-fieldname.
        ls_fcat-edit = 'X'.
        if ls_fcat-fieldname = 'COL_POS' or ls_fcat-fieldname = 'FIELDNAME'.
          ls_fcat-key = 'X'.
        endif.
        modify p_fcatfcat from ls_fcat.
      endloop.
    endform.                               " MODIFY_FIELDCATALOG
    form hide_fields changing p_fieldcat type lvc_t_fcat.
      data: ls_fcat type lvc_s_fcat.
    Only show documented fields of fieldcatalog.
    For a documentation choose "Help->Application Help" in the menu.
      loop at p_fieldcat into ls_fcat.
        if not (
             ls_fcat-fieldname eq 'CFIELDNAME'
        or   ls_fcat-fieldname eq 'COL_POS'
        or   ls_fcat-fieldname eq 'COLDDICTXT'
        or   ls_fcat-fieldname eq 'COLTEXT'
        or   ls_fcat-fieldname eq 'CURRENCY'
        or   ls_fcat-fieldname eq 'DD_OUTLEN'
        or   ls_fcat-fieldname eq 'DECIMALS_O'
        or   ls_fcat-fieldname eq 'DECMLFIELD'
        or   ls_fcat-fieldname eq 'DO_SUM'
        or   ls_fcat-fieldname eq 'DRAGDROPID'
        or   ls_fcat-fieldname eq 'EDIT_MASK'
        or   ls_fcat-fieldname eq 'EMPHASIZE'
        or   ls_fcat-fieldname eq 'EXPONENT'
        or   ls_fcat-fieldname eq 'FIELDNAME'
        or   ls_fcat-fieldname eq 'HOTSPOT'
        or   ls_fcat-fieldname eq 'ICON'
        or   ls_fcat-fieldname eq 'INTLEN'
        or   ls_fcat-fieldname eq 'INTTYPE'
        or   ls_fcat-fieldname eq 'JUST'
        or   ls_fcat-fieldname eq 'KEY'
        or   ls_fcat-fieldname eq 'LOWERCASE'
        or   ls_fcat-fieldname eq 'LZERO'
        or   ls_fcat-fieldname eq 'NO_OUT'
        or   ls_fcat-fieldname eq 'NO_SIGN'
        or   ls_fcat-fieldname eq 'NO_SUM'
        or   ls_fcat-fieldname eq 'NO_ZERO'
        or   ls_fcat-fieldname eq 'OUTPUTLEN'
        or   ls_fcat-fieldname eq 'QFIELDNAME'
        or   ls_fcat-fieldname eq 'QUANTITY'
        or   ls_fcat-fieldname eq 'REF_FIELD'
        or   ls_fcat-fieldname eq 'REF_TABLE'
        or   ls_fcat-fieldname eq 'REPREP'
        or   ls_fcat-fieldname eq 'REPTEXT'
        or   ls_fcat-fieldname eq 'ROLLNAME'
        or   ls_fcat-fieldname eq 'ROUND'
        or   ls_fcat-fieldname eq 'ROUNDFIELD'
        or   ls_fcat-fieldname eq 'SCRTEXT_L'
        or   ls_fcat-fieldname eq 'SCRTEXT_M'
        or   ls_fcat-fieldname eq 'SCRTEXT_S'
        or   ls_fcat-fieldname eq 'SELDDICTXT'
        or   ls_fcat-fieldname eq 'SELTEXT'
        or   ls_fcat-fieldname eq 'SP_GROUP'
        or   ls_fcat-fieldname eq 'SYMBOL'
        or   ls_fcat-fieldname eq 'TECH'
        or   ls_fcat-fieldname eq 'TIPDDICTXT'
        or   ls_fcat-fieldname eq 'TOOLTIP'
        or   ls_fcat-fieldname eq 'TXT_FIELD' ).
          ls_fcat-tech = 'X'.
        endif.
        modify p_fieldcat from ls_fcat.
      endloop.
    endform.
    form switch_visibility.
    data:  lt_fcatfcat type lvc_t_fcat,
            ls_fcat type lvc_s_fcat.
    call method g_editable_alv->get_frontend_fieldcatalog
                 importing ET_FIELDCATALOG = lt_fcatfcat.
    if not g_all is initial.
         perform hide_fields changing lt_fcatfcat.
         g_all = SPACE.
    else.
        loop at lt_fcatfcat into ls_fcat.
           if ls_fcat-tech eq 'X'.
               ls_fcat-tech = SPACE.
               ls_fcat-no_out = 'X'.
               modify lt_fcatfcat from ls_fcat.
           endif.
        endloop.
        g_all = 'X'.
    endif.
    call method g_editable_alv->set_frontend_fieldcatalog
                exporting it_fieldcatalog = lt_fcatfcat.
    call method g_editable_alv->refresh_table_display.
    endform.
    <b>Reward points</b>
    Regards

  • ALV subtotals using methods

    Hi
    Please provide me sample code for subtotals using methods.
    The code is
    DATA: ls_sort TYPE lvc_s_sort.
    ls_sort-spos = '1' .
    ls_sort-fieldname = 'BWART'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    *ls_sort-group = 'UL'.
    APPEND ls_sort TO p_gt_sort.
    endform
    but it is not working
    Please help me

    Hi,
    this is how you should do...
    CLASS lcl_event_handler DEFINITION DEFERRED.
    DATA: dg_events_receiver TYPE REF
                                TO lcl_event_handler.  "event receiver
    *       CLASS lcl_event_handler DEFINITION
    *       For Event handling                                             *
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
           subtotal_text        FOR EVENT subtotal_text
                             OF cl_gui_alv_grid
                             IMPORTING es_subtottxt_info
                                       ep_subtot_line
                                       e_event_data.
    ENDCLASS.                    "VERIFY_EVENT_HANDLER DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    *       Implementation of event handler method                        *
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD subtotal_text.
        PERFORM d0100_event_subtotal_text USING es_subtottxt_info
                                                ep_subtot_line
                                                e_event_data.
      ENDMETHOD.                    "subtotal_text
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    *--set event handler
      PERFORM set_event_handler.
      CALL METHOD dg_grid->set_table_for_first_display
        EXPORTING
          is_layout                     = ds_layout
        CHANGING
          it_outtab                     = <fs_f>
          it_fieldcatalog               = dt_alv_cat
          it_sort                       = dt_sort
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH
             'Error in calling SET_TABLE_FOR_FIRST_DISPLAY'(026).
      ENDIF.
    *&      Form  set_event_handler
    *       event handler
    *  -->  p1        text
    *  <--  p2        text
    FORM set_event_handler .
      CREATE OBJECT dg_events_receiver.
      SET HANDLER dg_events_receiver->subtotal_text
                  FOR dg_grid.
    ENDFORM.                    " set_event_handler
    *&      Form  d0100_event_subtotal_text
    *       To handle subtotal text event
    *      -->P_ES_SUBTOTTXT_INFO  text
    *      -->P_EP_SUBTOT_LINE  text
    *      -->P_E_EVENT_DATA  text
    FORM d0100_event_subtotal_text  USING
                            p_es_subtottxt_info TYPE lvc_s_stxt
                           p_ep_subtot_line TYPE REF TO data
                           p_e_event_data TYPE REF TO cl_alv_event_data .
      FIELD-SYMBOLS: <fs> TYPE ANY.
      ASSIGN p_e_event_data->m_data->* TO <fs>.
      <fs> = 'TOTAL'(027).
    ENDFORM.                    " d0100_event_subtotal_text
    Regards
    vijay

  • Sub Total Text in an ALV using FACTORY Method

    Hi Gurus,
    My requirement is simple, but I couldn't find any answers under SDN or any other forums. Some of you may ask me to check for the SCN posts, but I almost checked everything.
    My requirement is - When I get the Sub-total in my ALV, it should print a text other than the field which has got sub-total value.
    My ALV Schema:
    Field1  |  Field2 |  Field 3 |
    ____   |______ |______ |
               |             |             |
               |             |             |
              Tot. Qty  | 1000.00|
    I have sorted and added the subtotal = 'X' for the field which I need the Subtotal. Added Aggregations to Field3. But where and how to the field 'Tot. Qty', so that it should appear at the Sub-Total Level.
    Please guide me if I've missed any of the forums. Again my requirement is to print the Field Name.
    Regards,
    -Wahid Hussain Syed.

    Hi,
    You can view this thread for example Display constant text in intermediate results column of SALV as it says that this is a limitation in SALV that "The output of totals and subtotals is handled solely by ALV. You can neither pass the results to your application nor manipulate them in any way.". But you can see a work around done for this problem, to be frank that I have not done that and I am only providing this link for your reference.

  • ALV using  OO method is giving problem

    Hello Experts,
    I am populating button in one ALV column conditionally. that button is coming fine... but i see the text on button taken from the previous column value...  i want it blank otherwise... my custom text... how can I achieve that ?
    pls help..
    thanks

    Hello Clemens,
    Thanks for your inputs.
    Would you please let me know which text field?
    I believe I have cleared the fields before populating the internal table displayed in output. Also I have cleared fields while populating field catalog for the button column.
    Kumail

Maybe you are looking for

  • Aging Report with Customer/Vendor Ref. No. should allow backdate

    Aging Reports for Suppliers and Customers. The current printing of the aging reports using Sales Document tab or the Purchase Document tab does not tie with the GL balances when the dates are backdated. It is important that the detail aging report to

  • Macbook keyboard and trackpad/crashing/time date reset

    A few days ago my 2011 macbook pro running Mountian Lion (fully up to date) started crashing. Nature of crash : Screen freezes, If audio was playing it would stutter for about 4 seconds, then the computer would switch off. When turned back on I would

  • Changing the notification status

    How to change the status of the notification programatically? I mean based on some scenario if i want to change the status of the notification of a person to "Closed" or "Open" or "Cancelled", how is this possible? Thanks

  • ESSO-Provisioning Gateway

    Hi All, I'm trying to test 'delegation' option in ESSO-LM Agent. I have configured PG and LM-Admin console as per the documentation, LM-Client is working fine and also i'm able to provision user logons for account in AD using Provisioning Gateway...

  • Report Variants

    Hallo, Does anybody know how to create & load report variants from abap? Thanks in advance...