메뉴 건너뛰기

SAP 한국 커뮤니티

report zsalv_045 .

sapjoy 2010.08.20 20:01 조회 수 : 4264

 

report  zsalv_045                                 .


*----------------------------------------------------------------------*
*       CLASS lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
class lcl_handle_events definition.
  public section.
    methods:
      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 on_user_command.
    perform handle_user_command using e_salv_function.
  endmethod.                    "on_user_command
endclass.                    "lcl_handle_events IMPLEMENTATION

class lcl_report definition.

  public section.

    types: ty_t_sflights type standard table of sflights.

    data: t_data type ty_t_sflights.

    data: o_salv       type ref to cl_salv_table.
    data: o_salv_model type ref to lcl_salv_model.


    methods:
      get_data,

      generate_output.

endclass.                    "lcl_report DEFINITION



data gt_itab       type table of sflight.
data gr_table      type ref to cl_salv_table.
data gr_event   type ref to lcl_handle_events.
data gr_functions  type ref to cl_salv_functions_list.
data gr_container  type ref to cl_gui_custom_container.
data ok_code type syucomm.


start-of-selection.

  select * from sflight into table gt_itab
  up to 25 rows.

  call screen 100.
*&---------------------------------------------------------------------*
*&      Module  0100_PBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module 0100_pbo output.

  set pf-status '0100'.
  if gr_container is not bound.
*1. 컨테이너 생성
    create object gr_container
      exporting
        container_name = 'CONTAINER'.

*2. ALV 테이블 및 데이터 전달
    cl_salv_table=>factory(
      exporting
        r_container    = gr_container
        container_name = 'CONTAINER'
      importing
        r_salv_table   = gr_table
      changing
        t_table        = gt_itab ).


*3. ALV 기본 기능 버튼 설정
    gr_functions = gr_table->get_functions( ).
*    gr_functions->set_default( ).
    gr_functions->set_all( abap_true ).


    include <icon>.
    data : l_icon type string.

    l_icon = icon_refresh.

    gr_functions->add_function(
        name     = 'REFRESH'
        icon     = l_icon
        text     = 'REFRESH'
        tooltip  = 'REFRESH'
        position = if_salv_c_function_position=>right_of_salv_functions
        ).

*4. 이벤트 등록
    data lr_event type ref to cl_salv_events_table.
    lr_event = gr_table->get_event( ).

    create object gr_event.
    set handler gr_event->on_user_command for lr_event.



*5. ALV 호출
    gr_table->display( ).
  endif.

endmodule.                 " 0100_PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  0100_PAI  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module 0100_pai input.

  case ok_code.
    when 'BACK' or 'EXIT' or 'CANC'.
      set screen 0.
      leave screen.
  endcase.

endmodule.                 " 0100_PAI  INPUT
*&---------------------------------------------------------------------*
*&      Form  HANDLE_USER_COMMAND
*&---------------------------------------------------------------------*
form handle_user_command using p_function type salv_de_function.


  data: lo_grid type ref to cl_gui_alv_grid,
       lo_full_adap type ref to cl_salv_fullscreen_adapter.
  data: ls_layout type lvc_s_layo.

  data: lo_report type ref to lcl_report.

  case p_function.
    when 'REFRESH'.

*       Contorller
      call method lo_report->o_salv_model->grabe_controller.

*       Adapter
      call method lo_report->o_salv_model->grabe_adapter.

*       Fullscreen Adapter (Down Casting)
      lo_full_adap ?= lo_report->o_salv_model->o_adapter.

*       Get the Grid
      lo_grid = lo_full_adap->get_grid( ).

*       Got the Grid .. ?
      if lo_grid is bound.

*         Editable ALV
        ls_layout-edit = 'X'.

*         Set the front layout of ALV
        call method lo_grid->set_frontend_layout
          exporting
            is_layout = ls_layout.

*         refresh the table
        call method lo_grid->refresh_table_display.

      endif.



    when others.
  endcase.

endform.                    "handle_user_command
*&---------------------------------------------------------------------*
*&      Form  REFRESH
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form refresh .

  select * from sflight
  into corresponding fields of table gt_itab
        up to 10 rows.

  gr_table->refresh( ).


endform.                    " REFRESH
번호 제목 글쓴이 날짜 조회 수
391 report zsaptip_009 [1] sapjoy 2010.12.10 3852
390 REPORT Z_3DGRAPH. [1] sapjoy 2010.10.18 3666
389 REPORT zsmw0010 sapjoy 2010.10.12 4315
388 z_exception_test sapjoy 2010.10.11 3521
387 REPORT zmacro_01. sapjoy 2010.10.10 2582
386 REPORT ZTEST_ABAPTPDF sapjoy 2010.10.10 3693
385 REPORT ZALVCOLOR sapjoy 2010.10.10 3212
384 REPORT ZTABLE_UTIL sapjoy 2010.10.10 4012
383 REPORT Z_DYNAMIC_SCREEN [1] sapjoy 2010.10.08 3035
» report zsalv_045 . sapjoy 2010.08.20 4264
381 report zsalv_043 . sapjoy 2010.08.20 2978
380 report zsalv_042 . sapjoy 2010.08.20 3135
379 report zsalv_041 . sapjoy 2010.08.20 2998
378 report zsalv_040 . sapjoy 2010.08.20 2608
377 report zsalv_036 . sapjoy 2010.08.20 3473
376 report zsalv_035 . sapjoy 2010.08.20 2505
375 report zsalv_032 . sapjoy 2010.08.20 2976
374 report zsalv_031 . sapjoy 2010.08.20 2427
373 report zsalv_030 . sapjoy 2010.08.20 2331
372 report zsalv_023 . sapjoy 2010.08.20 2347