Programcılar için altın değerindeki örnek kodlar , bilgiler. Bunları başka yerlerde bulamazsınız...
10 Şubat 2011 Perşembe
Alv Örnek 3
REPORT zmus_alv01.
TABLES : zv_equipment .
TYPE-POOLS : icon .
*--------------------------------------------------------------------
* G L O B A L C L A S S
*--------------------------------------------------------------------
INCLUDE zmus_alv02_alv_class.
*--------------------------------------------------------------------
* G L O B A L I N T E R N A L T A B L E S
*--------------------------------------------------------------------
DATA: gt_xtab TYPE STANDARD TABLE OF zv_equipment.
*--------------------------------------------------------------------
* G L O B A L D A T A
*--------------------------------------------------------------------
DATA: ok_code LIKE sy-ucomm,
gwa_xtab LIKE zv_equipment.
* Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
*--------------------------------------------------------------------
* S T A R T - O F - S E L E C T I O N.
*--------------------------------------------------------------------
START-OF-SELECTION.
SET SCREEN '100'.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'DENEME'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Bilgi'
txt2 = 'text2'
txt1 = 'Text1'(510).
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
DATA: o_event_receiver TYPE REF TO lcl_event_receiver.
SET PF-STATUS 'MAIN'.
* Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form load_data_into_grid
*&---------------------------------------------------------------------*
FORM load_data_into_grid.
DATA:
* For parameter IS_VARIANT
l_layout TYPE disvariant,
* ALV control: Layout structure
gs_layout TYPE lvc_s_layo,
ls_layout TYPE lvc_t_fcat,
ws_layout TYPE LINE OF lvc_t_fcat.
* Read data from table SFLIGHT
SELECT *
FROM zv_equipment
INTO TABLE gt_xtab.
* Load data into the grid and display them
l_layout-report = sy-repid.
* Set grid title
gs_layout-grid_title = 'Prim Hakediþ Hesabý'.
gs_layout-sel_mode = 'A'.
gs_layout-zebra = 'X'.
* gs_layout-edit = 'X'.
* gs_layout-edit_mode = 'X'.
gs_layout-no_keyfix = 'X'.
gs_layout-no_f4 = 'X'.
gs_layout-no_rowins = 'X'.
* U Only user specific layouts can be saved
* X Only global layouts can be saved
* A Both user specific and global layouts can be saved
* Space Layouts can not be saved
* Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZV_EQUIPMENT'
is_variant = l_layout
is_layout = gs_layout
i_save = 'A'
CHANGING
it_outtab = gt_xtab.
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = ls_layout.
LOOP AT ls_layout INTO ws_layout.
CASE ws_layout-fieldname.
* WHEN 'EQUNR'.
* ws_layout-edit = 'X'.
* MODIFY ls_layout FROM ws_layout.
ENDCASE.
ENDLOOP.
CALL METHOD go_grid->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = ls_layout.
CALL METHOD go_grid->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
CALL METHOD go_grid->set_toolbar_interactive.
ENDFORM. " load_data_into_grid
*&---------------------------------------------------------------------*
*& Form read_selected_rows
*&---------------------------------------------------------------------*
FORM read_selected_rows .
DATA:
* Internal table for indexes of selected rows
gi_index_rows TYPE lvc_t_row,
* Information about 1 row
g_selected_row LIKE lvc_s_row,
l_lines TYPE i.
CALL METHOD go_grid->get_selected_rows
IMPORTING
et_index_rows = gi_index_rows.
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'Hakediþleri iþleyebilmek için önce'
textline2 = 'iþlenecek satýrlarý seçmelisiniz.'.
EXIT.
ENDIF.
SORT gi_index_rows DESCENDING .
LOOP AT gi_index_rows INTO g_selected_row.
READ TABLE gt_xtab INDEX g_selected_row-index INTO gwa_xtab.
DELETE gt_xtab INDEX g_selected_row-index.
ENDLOOP.
CALL METHOD go_grid->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM. " read_selected_rows
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder