메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT z18_023

sapjoy 2008.04.22 05:26 조회 수 : 2256

REPORT  z18_023                                                     .
TABLES : sflight.


DATA : con1_ref TYPE REF TO cl_gui_custom_container.


 


TYPES : t_sflight TYPE sflight.


*DATA : GT_SFLIGHT TYPE TABLE OF T_SFLIGHT.
*DATA : gt_sflight LIKE sflight OCCURS 0 WITH HEADER LINE.
*
DATA : BEGIN OF  gt_sflight OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA:   linecolor(4) TYPE c.
DATA : END OF gt_sflight.


DATA : grid1  TYPE REF TO cl_gui_alv_grid,
       gs_variant     LIKE disvariant,
       gs_cs_variant  LIKE disvariant,
       gs_layout     TYPE lvc_s_layo,
       gs_toolbar    TYPE ui_functions,
       gt_sort       TYPE lvc_t_sort,
       gt_fieldcat   TYPE lvc_t_fcat.
*       gt_sflight    TYPE TABLE OF sflight.


TYPE-POOLS: icon.


*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.


  PUBLIC SECTION.
    METHODS:


    handle_double_click
        FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING e_row e_column.


    METHODS : handle_toolbar
                 FOR EVENT toolbar OF cl_gui_alv_grid
                 IMPORTING e_object e_interactive.



    METHODS : handle_command
                 FOR EVENT user_command OF cl_gui_alv_grid
                 IMPORTING e_ucomm.


  PRIVATE SECTION.


ENDCLASS.                    "lcl_event_receiver DEFINITION


*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.


  METHOD handle_double_click.
    LEAVE TO SCREEN 0.
  ENDMETHOD.                           "handle_double_click


*-- Add ToolBar
  METHOD handle_toolbar.


    DATA: ls_toolbar  TYPE stb_button.


    CLEAR ls_toolbar.
    ls_toolbar-butn_type = 3.
    APPEND ls_toolbar    TO e_object->mt_toolbar.


    CLEAR ls_toolbar.
    ls_toolbar-function  = 'RESH'.
    ls_toolbar-icon      = icon_refresh.
    ls_toolbar-quickinfo = 'Refresh'.
    ls_toolbar-text      = ' '.
    ls_toolbar-disabled  = ' '.
    APPEND ls_toolbar    TO e_object->mt_toolbar.


  ENDMETHOD.                    "handle_toolbar



  METHOD handle_command.
    DATA : l_scroll TYPE lvc_s_stbl.


    CASE e_ucomm.
*-  REFRESH
      WHEN 'RESH'.


        SELECT * FROM sflight
        INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
        l_scroll-row = 'X'.
        l_scroll-col = 'X'.
        CALL METHOD grid1->refresh_table_display
          EXPORTING
            i_soft_refresh = ''
            is_stable      = l_scroll.
    ENDCASE.
  ENDMETHOD.                    "handle_user_command



ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
*


DATA :     event_receiver TYPE REF TO lcl_event_receiver.



START-OF-SELECTION.
  SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.


  LOOP AT gt_sflight.
      CASE gt_sflight-carrid.
      WHEN 'AA'.
       gt_sflight-linecolor = 'C100'.
      WHEN 'AZ'.
       gt_sflight-linecolor = 'C300'.
      WHEN 'DL'.
       gt_sflight-linecolor = 'C500'.
      ENDCASE.
     MODIFY gt_sflight INDEX sy-tabix.
     ENDLOOP.



    CALL SCREEN 100.


 


 


*---------------------------------------------------------------------*
*  MODULE init_con OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE init_con OUTPUT.


  IF con1_ref IS INITIAL.
    CREATE OBJECT con1_ref
    EXPORTING container_name = 'CON1'.



    CREATE OBJECT grid1
           EXPORTING
                i_parent = con1_ref.


    PERFORM setting_layout.
    PERFORM getting_catalog.
    PERFORM setting_catalog.
    PERFORM setting_toolbar.
    PERFORM setting_sort.
    PERFORM setting_event.


    CALL METHOD grid1->set_table_for_first_display
      EXPORTING
*        i_structure_name     = 'SFLIGHT'
        i_save               = 'A'
        is_variant           = gs_variant  " variant display
        i_default            = ' '
        is_layout            = gs_layout
        it_toolbar_excluding = gs_toolbar
      CHANGING
        it_outtab            = gt_sflight[]
        it_fieldcatalog      = gt_fieldcat[]
        it_sort              = gt_sort.


 



  ENDIF.
ENDMODULE.                 " init_con  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'G100'.
*  SET TITLEBAR 'xxx'.


ENDMODULE.                 " STATUS_0100  OUTPUT


*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.


  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CANC'.
      LEAVE TO SCREEN 0.
  ENDCASE.


ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  setting_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GS_LAYOCAT  text
*----------------------------------------------------------------------*
FORM setting_layout .
*- General display options
  gs_layout-cwidth_opt = 'X'.
* TITLE BAR


  gs_layout-grid_title = 'Coloring Row Test'.
* Selection modes for SEL_MODE
  gs_layout-sel_mode = 'D'.
* Grid pattern
  gs_layout-zebra      = 'X'.
  gs_layout-info_fname = 'LINECOLOR'.
ENDFORM.                    " setting_layout
*&---------------------------------------------------------------------*
*&      Form  setting_toolbar
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GS_TOOLBAR  text
*----------------------------------------------------------------------*
FORM setting_toolbar.
  DATA: l_exclude TYPE ui_func.


  l_exclude = cl_gui_alv_grid=>mc_fc_save_variant.
  APPEND l_exclude TO gs_toolbar.


  l_exclude = cl_gui_alv_grid=>mc_fc_maintain_variant.
  APPEND l_exclude TO gs_toolbar.


ENDFORM.                    " setting_toolbar
*&---------------------------------------------------------------------*
*&      Form  setting_sort
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM setting_sort .


  DATA : ls_sort TYPE lvc_s_sort.


  ls_sort-spos = '1'.
  ls_sort-fieldname = 'CARRID'.
  ls_sort-up = 'X'.
  ls_sort-subtot = 'X'.
  APPEND ls_sort TO gt_sort.


 



ENDFORM.                    " setting_sort
*&---------------------------------------------------------------------*
*&      Form  setting_event
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM setting_event .
  CREATE OBJECT event_receiver.
  SET HANDLER event_receiver->handle_double_click FOR grid1.
  SET HANDLER event_receiver->handle_toolbar       FOR grid1.
  SET HANDLER event_receiver->handle_command       FOR grid1.


ENDFORM.                    " setting_event
*&---------------------------------------------------------------------*
*&      Form  setting_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM setting_catalog .
  FIELD-SYMBOLS: <ls_fcat> TYPE lvc_s_fcat.


   LOOP AT gt_fieldcat ASSIGNING <ls_fcat>.


    IF <ls_fcat>-fieldname EQ 'FLDATE'.
     <ls_fcat>-edit_mask = '____/__/__'.
    ENDIF.


    IF <ls_fcat>-fieldname EQ 'CURRENCY'.
     <ls_fcat>-just = 'R'.
    ENDIF.



   ENDLOOP.


ENDFORM.                    " setting_catalog
*&---------------------------------------------------------------------*
*&      Form  getting_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM getting_catalog .
  DATA : lt_fieldcat TYPE kkblo_t_fieldcat.
  CALL FUNCTION 'K_KKB_FIELDCAT_MERGE'
    EXPORTING
      i_callback_program     = sy-repid
      i_tabname              = 'GT_SFLIGHT'
*      i_strucname            = i_structure
      i_inclname             = sy-repid
    CHANGING
      ct_fieldcat            = lt_fieldcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      OTHERS                 = 2.
  IF sy-subrc EQ 0.
    CALL FUNCTION 'LVC_TRANSFER_FROM_KKBLO'
      EXPORTING
        it_fieldcat_kkblo = lt_fieldcat[]
      IMPORTING
        et_fieldcat_lvc   = gt_fieldcat[].
  ENDIF.


ENDFORM.                    " getting_catalog

번호 제목 글쓴이 날짜 조회 수
251 REPORT Z07_016 sapjoy 2008.04.15 2804
250 REPORT Z15_007 eabap 2007.01.24 2680
249 REPORT Z05_025 sapjoy 2007.05.28 2564
248 REPORT Z05_013 [3] sapjoy 2008.04.15 2653
247 REPORT Z02_005 . sapjoy 2006.12.03 2376
246 REPORT Z04_005 . sapjoy 2006.12.03 2595
245 REPORT Z06_001 MESSAGE-ID ZTEST . [1] sapjoy 2006.12.05 3207
244 REPORT Z07_002 . sapjoy 2006.12.07 2757
243 REPORT Z07_008 sapjoy 2006.12.07 2462
242 INCLUDE Z16_001O01 [1] sapjoy 2007.04.27 2595
241 REPORT z18_017 sapjoy 2007.03.12 2672
240 REPORT z18_036 sapjoy 2007.03.14 2631
239 REPORT z18_032 sapjoy 2008.04.22 2712
238 REPORT z18_031 sapjoy 2008.04.22 2527
237 REPORT z18_025 sapjoy 2007.03.17 2598
236 REPORT z18_024 sapjoy 2008.04.22 2310
» REPORT z18_023 sapjoy 2008.04.22 2256
234 REPORT z18_022 sapjoy 2008.04.22 2258
233 REPORT z18_021 sapjoy 2008.04.22 2252
232 REPORT z18_020 sapjoy 2008.04.22 1835