SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Refresh button



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Jan 26, 2008 5:02 pm    Post subject: Refresh button Reply with quote

Code:
REPORT z_alv_grid_ctrl_refresh.
***********************************************************************
* ALV Grid Control - Refresh button                                   *
*---------------------------------------------------------------------*
* Steps :                                                             *
* - Create the report Z_ALV_GRID_CTRL_REFRESH                         *
* - Create the Dynpro 0100 (size 27x120)                              *
* - Add OKCODE (type OK) in the element list                          *
* - Modify the flow logic of dynpro 0100 :                            *
*   * PROCESS BEFORE OUTPUT.                                          *
*       MODULE status_0100.                                           *
*   * PROCESS AFTER INPUT.                                            *
*       MODULE user_command_0100.                                     *
* - Create a status named 'MAIN'                                      *
*   with the buttons : REFRESH BACK and EXIT                          *
*---------------------------------------------------------------------*
* Author : Michel PIOUD                                               *
* Email : [email protected]  HomePage : http://www.geocities.com/mpioud *
***********************************************************************
TYPES:
  BEGIN OF ty_mara,
    ernam TYPE mara-ernam,
    matnr TYPE mara-matnr,
    ersda TYPE mara-ersda,
    brgew TYPE mara-brgew,
  END OF ty_mara.

DATA:
  gt_mara TYPE STANDARD TABLE OF ty_mara.

DATA :
  go_container TYPE REF TO cl_gui_docking_container,
  go_alv_grid  TYPE REF TO cl_gui_alv_grid,

  okcode    TYPE syucomm,
  gv_okcode TYPE syucomm.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

  CALL SCREEN 100.

*---------------------------------------------------------------------*
*       Module  status_0100  OUTPUT
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  SET PF-STATUS 'MAIN'.

  IF go_container IS INITIAL.
    PERFORM create_and_init_alv.
  ENDIF.

ENDMODULE.                             " STATUS_0100  OUTPUT
*---------------------------------------------------------------------*
*       Module  user_command_0100  INPUT
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  gv_okcode = okcode.
  CLEAR okcode.

  CASE gv_okcode.
    WHEN 'BACK'.
      SET SCREEN 0.
    WHEN 'REFRESH'.
      PERFORM f_refresh_table.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.

ENDMODULE.                             " USER_COMMAND_0100  INPUT
*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

  STATICS :
    l_rows TYPE i.

  ADD 1 TO l_rows.
  SELECT ernam matnr ersda brgew INTO TABLE gt_mara FROM mara
                                   UP TO l_rows ROWS.

  MESSAGE s208(00) WITH 'Reading data ...'.

ENDFORM.                               " F_READ_DATA
*---------------------------------------------------------------------*
*       Form  create_and_init_alv
*---------------------------------------------------------------------*
FORM create_and_init_alv.

* Macro definition
  DEFINE m_fieldcat.
    add 1 to ls_alv_cat-col_pos.
    ls_alv_cat-fieldname = &1.
    ls_alv_cat-ref_table = 'MARA'.
    append ls_alv_cat to lt_alv_cat.
  END-OF-DEFINITION.

  DATA:
    ls_variant TYPE disvariant,
    lt_alv_cat TYPE lvc_t_fcat,
    ls_alv_cat TYPE lvc_s_fcat,
    ls_alv_lay TYPE lvc_s_layo,
    l_offline  TYPE char1.

  CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
      e_offline = l_offline.

  IF l_offline EQ 0.
    CREATE OBJECT go_container
        EXPORTING
            extension = 2000
        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 e208(00) WITH 'The control could not be created'.
    ENDIF.
  ENDIF.

* Create an instance of alv control
  CREATE OBJECT go_alv_grid
      EXPORTING i_parent = go_container.

* Build field catalog
  m_fieldcat 'ERNAM'.
  m_fieldcat 'MATNR'.
  m_fieldcat 'ERSDA'.
  m_fieldcat 'BRGEW'.

* Layout
  CLEAR ls_alv_lay.
  ls_alv_lay-zebra      = 'X'.
  ls_alv_lay-cwidth_opt = 'X'.

  ls_variant-report = sy-cprog.

* Display
  CALL METHOD go_alv_grid->set_table_for_first_display
    EXPORTING
      is_variant      = ls_variant
      is_layout       = ls_alv_lay
      i_save          = 'A'
    CHANGING
      it_outtab       = gt_mara[]
      it_fieldcatalog = lt_alv_cat.

ENDFORM.                               " CREATE_AND_INIT_ALV
*---------------------------------------------------------------------*
*      Form  F_REFRESH_TABLE
*---------------------------------------------------------------------*
FORM f_refresh_table.

  DATA: ls_layout TYPE lvc_s_layo.

  PERFORM f_read_data.

  CALL METHOD go_alv_grid->get_frontend_layout
    IMPORTING
      es_layout = ls_layout.

  ls_layout-cwidth_opt = 'X'.

  CALL METHOD go_alv_grid->set_frontend_layout
    EXPORTING
      is_layout = ls_layout.

  CALL METHOD go_alv_grid->refresh_table_display.

ENDFORM.                               " F_REFRESH_TABLE
********** END OF PROGRAM Z_ALV_GRID_CTRL_REFRESH *********************
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.