FORM create_alv .
  IF go_splitter1 IS INITIAL.

    ls_stable-row 'X'.
    ls_stable-col 'X'.

    CREATE OBJECT go_splitter1
      EXPORTING
        parent  cl_gui_container=>default_screen
        rows    1
        columns 1.

    CALL METHOD go_splitter1->get_container
      EXPORTING
        row       1
        column    1
      RECEIVING
        container go_container1.


    CREATE OBJECT go_grid1
      EXPORTING
        i_parent go_container1.


    CALL METHOD go_splitter1->set_row_height
      EXPORTING
        id     1
        height 120.


    DATAlcl_alv_event1 TYPE REF TO lcl_event_receiver.
    DATA lt_fieldcat_slis TYPE slis_t_fieldcat_alv.

    CREATE OBJECT lcl_alv_event1.
    SET HANDLER lcl_alv_event1->handle_toolbar FOR go_grid1.
    SET HANDLER lcl_alv_event1->handle_user_command FOR go_grid1.
    SET HANDLER lcl_alv_event1->hotspot_click FOR go_grid1.




    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        i_program_name         sy-repid
        i_internal_tabname     'GT_DATA' 
        i_inclname             sy-repid
        i_bypassing_buffer     'X'
      CHANGING
        ct_fieldcat            lt_fieldcat_slis
      EXCEPTIONS
        inconsistent_interface 1
        program_error          2
        OTHERS                 3.

    CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
      EXPORTING
        it_fieldcat_alv lt_fieldcat_slis
      IMPORTING
        et_fieldcat_lvc i_fieldcat
      TABLES
        it_data         gt_data
      EXCEPTIONS
        it_data_missing 1
        OTHERS          2.


--Ekrana gelen alv'deki alanların baÅŸlıklarını deÄŸiÅŸtirmek için 

    LOOP AT i_fieldcat INTO gt_fieldcat.
      CASE gt_fieldcat-fieldname.
        WHEN 'LIFNR'.
          gt_fieldcat-reptext  
          gt_fieldcat-coltext  
        WHEN 'NAME1'.
          gt_fieldcat-reptext  
          gt_fieldcat-coltext  
      ENDCASE.
      MODIFY i_fieldcat FROM gt_fieldcat.
    ENDLOOP.




*Layout
    CLEAR gs_layout.
*    gs_layout-no_toolbar = 'X'.
    gs_layout-no_rowins  'X'.
    gs_layout-zebra      'X'.
    gs_layout-cwidth_opt 'X'.
*    gs_layout-box_fname  = 'CHK'.
*    gs_layout-stylefname = 'CELLTAB'. 
    gs_variant-report sy-repid.

    CALL METHOD go_grid1->set_table_for_first_display
      EXPORTING
        is_layout            gs_layout
        is_variant           gs_variant
        it_toolbar_excluding gt_excl
        i_save               'A'
      CHANGING
        it_fieldcatalog      i_fieldcat
        it_outtab            gt_data[]

    CALL METHOD go_grid1->set_ready_for_input
      EXPORTING
        i_ready_for_input 1.


  ELSE.
    CALL METHOD go_grid1->refresh_table_display
      EXPORTING
        i_soft_refresh 'X'
        is_stable      ls_stable.
  ENDIF.
ENDFORM.




CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS:
*     Add a toolbar
      handle_toolbar
      FOR EVENT toolbar OF cl_gui_alv_grid
      IMPORTING e_object e_interactive,

*     Add a toolbar
      toolbar
      FOR EVENT toolbar OF cl_gui_alv_grid
      IMPORTING e_object e_interactive,

*     Add a menu to this toolbar
      handle_menu_button
      FOR EVENT menu_button OF cl_gui_alv_grid
      IMPORTING e_object e_ucomm,
*     Deal with user action
      handle_user_command
      FOR EVENT user_command OF cl_gui_alv_grid
      IMPORTING e_ucomm,
*     Link click
      hotspot_click
      FOR EVENT hotspot_click OF cl_gui_alv_grid
      IMPORTING e_row_id e_column_id es_row_no ,
*     Double click
      handle_double_click
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row
      e_column
      es_row_no ,
*     Link click
      link_click
      FOR EVENT link_click OF cl_gui_alv_tree
      IMPORTING fieldname node_key,
*     Data change
      handle_data_changed
      FOR EVENT data_changed OF cl_gui_alv_grid
      IMPORTING er_data_changed,
*     Handle toolbar function
      on_function_selected
      FOR EVENT function_selected OF cl_gui_toolbar
      IMPORTING fcode,
*     Handle toolbar dropdown
      on_toolbar_dropdown
      FOR EVENT dropdown_clicked OF cl_gui_toolbar
      IMPORTING fcode
      posx
      posy,
*     Handle F4
*      onf4
*                    FOR EVENT onf4 OF cl_gui_alv_grid
*        IMPORTING e_fieldname es_row_no.
      onf4 FOR EVENT onf4 OF cl_gui_alv_grid
      IMPORTING sender
      e_fieldname
      e_fieldvalue
      es_row_no
      er_event_data
      et_bad_cells
      e_display.

  PRIVATE SECTION.
*    TYPES: ddshretval_table TYPE TABLE OF ddshretval.
*    DATA : lr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
*    METHODS: my_f4
*      IMPORTING sender        TYPE REF TO cl_gui_alv_grid
*                et_bad_cells  TYPE lvc_t_modi
*                es_row_no     TYPE lvc_s_roid
*                er_event_data TYPE REF TO cl_alv_event_data
*                e_display     TYPE c
*                e_fieldname   TYPE lvc_fname
*      EXPORTING lt_f4         TYPE ddshretval_table.

ENDCLASS.                    "lcl_event_receiver DEFINITION

**************************************************************
* LOCAL CLASS implementation for data changed in fieldcatalog ALV
**************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.

*  METHOD handle_data_changed.
*  ENDMETHOD.                    "handle_data_changed
*
*  METHOD handle_double_click.             " DOUBLE_CLICK
**    DATA: ls_out LIKE LINE OF gt_out.
**    CLEAR ls_out.
**    READ TABLE gt_out
**          INTO ls_out INDEX es_row_no-row_id.
**    gt_out2[] = gt_all[].
**    DELETE gt_out2 WHERE kunnr NE ls_out-kunnr.
**    PERFORM write_detay_data.
*  ENDMETHOD.                    "handle_double_click
*

* Add toolbar
  METHOD handle_toolbar.
*    PERFORM handle_toolbar USING e_object.
  ENDMETHOD.                    "handle_toolbar

* Add toolbar
  METHOD toolbar.
*    PERFORM toolbar USING e_object.
  ENDMETHOD.                    "handle_toolbar

  METHOD handle_user_command.
*    PERFORM  handle_user_command USING e_ucomm.
  ENDMETHOD.                    "handle_user_commands

* When click toolbar display a menu to user
  METHOD handle_menu_button.
* e_object e_ucomm
  ENDMETHOD.                    "handle_menu_button

  METHOD hotspot_click.
*    PERFORM  hotspot_click USING e_row_id e_column_id.
* e_row_id e_column_id es_row_no
  ENDMETHOD.                    "hotspot_click

  METHOD handle_double_click.
*    PERFORM double_click USING e_row e_column.
* e_rowe_column es_row_no
  ENDMETHOD.

  METHOD link_click.
* fieldname node_key
  ENDMETHOD.                    "link_click

  METHOD  handle_data_changed.
*    PERFORM handle_data_changed USING er_data_changed.
  ENDMETHOD.                    "handle_data_changed

  METHOD on_function_selected.
*  fcode
  ENDMETHOD.                    "on_function_selected

  METHOD on_toolbar_dropdown.
* fcode posx posy
  ENDMETHOD.                    "on_toolbar_dropdown

  METHOD onf4.
*  sender
*                    e_fieldname
*                    e_fieldvalue
*                    es_row_no
*                    er_event_data
*                    et_bad_cells
*                    e_display


  ENDMETHOD.


ENDCLASS.






MODULE pbo_2000 OUTPUT.
  PERFORM pbo_2000.
ENDMODULE.






MODULE pai_2000 INPUT.
  PERFORM pai_2000.
ENDMODULE.





DATA  gt_toolbar        TYPE stb_button.
DATA  gt_fcat1          TYPE lvc_t_fcat.
DATA  go_grid1          TYPE REF TO cl_gui_alv_grid.
DATA  go_container1     TYPE REF TO cl_gui_container.
DATA  go_splitter1      TYPE REF TO cl_gui_splitter_container.

DATAi_fieldcat  TYPE STANDARD TABLE OF lvc_s_fcat,
      gt_fieldcat TYPE lvc_s_fcat"Field catalog
      gs_fieldcat TYPE lvc_t_fcat"Field catalog
      gs_layout   TYPE lvc_s_layo,
      gs_variant  LIKE disvariant.

DATAgt_excl TYPE  ui_functions,
      gv_excl TYPE  ui_func.

* Refresh table
DATABEGIN OF ls_stable,
        row TYPE c,
        col TYPE c,
      END OF ls_stable.



Serkan AKKAVAK

Computer Engineer

SAP Department Deputy Manager

Contact : serkurumsal@yandex.com