메뉴 건너뛰기

SAP 한국 커뮤니티

zsalv_edit

sapjoy 2010.08.20 10:56 조회 수 : 3208


report  zsalv_edit.

*----------------------------------------------------------------------*
*  Define the Local class inheriting from the CL_SALV_MODEL_LIST
*  to get an access of the model, controller and adapter which inturn
*  provides the Grid Object
*----------------------------------------------------------------------*
class lcl_salv_model definition inheriting from cl_salv_model_list.

  public section.
    data: o_control type ref to cl_salv_controller_model,
          o_adapter type ref to cl_salv_adapter.

    methods:
      grabe_model
        importing
          io_model type ref to cl_salv_model,

      grabe_controller,

      grabe_adapter.


  private section.
    data: lo_model type ref to cl_salv_model.

endclass.                    "LCL_SALV_MODEL DEFINITION

*----------------------------------------------------------------------*
* Event handler for the added buttons
*----------------------------------------------------------------------*
class lcl_event_handler definition.

  public section.
    methods:
      on_user_command for event added_function of cl_salv_events
        importing e_salv_function.

endclass.                    "lcl_event_handler DEFINITION


*----------------------------------------------------------------------*
* Local Report class - Definition
*----------------------------------------------------------------------*
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

*----------------------------------------------------------------------*
* Global data
*----------------------------------------------------------------------*
data: lo_report type ref to lcl_report.

*----------------------------------------------------------------------*
* Start of selection
*----------------------------------------------------------------------*
start-of-selection.

  create object lo_report.

  lo_report->get_data( ).

  lo_report->generate_output( ).


*----------------------------------------------------------------------*
* Local Report class - Implementation
*----------------------------------------------------------------------*
class lcl_report implementation.

  method get_data.

*   test data
    select * from sflights
           into table me->t_data
           up to 30 rows.

  endmethod.                    "get_data

  method generate_output.

*...New ALV Instance ...............................................
    try.
        cl_salv_table=>factory(
          exporting
*          r_container    = w_alv1
            list_display = abap_false
          importing
            r_salv_table = o_salv
          changing
            t_table      = t_data ).
      catch cx_salv_msg.                                "#EC NO_HANDLER
    endtry.

*...PF Status.......................................................
*   Add MYFUNCTION from the report SALV_DEMO_TABLE_EVENTS
    o_salv->set_screen_status(
      pfstatus      =  'SALV_STANDARD'
      report        =  'SALV_DEMO_TABLE_EVENTS'
      set_functions = o_salv->c_functions_all ).

*...Event handler for the button.....................................
    data: lo_events type ref to cl_salv_events_table,
          lo_event_h type ref to lcl_event_handler.

* event object
    lo_events = o_salv->get_event( ).

* event handler
    create object lo_event_h.

* setting up the event handler
    set handler lo_event_h->on_user_command for lo_events.


*...Get Model Object ...............................................
    data: lo_alv_mod type ref to cl_salv_model.

*   Narrow casting
    lo_alv_mod ?= o_salv.

*   object for the local inherited class from the CL_SALV_MODEL_LIST
    create object o_salv_model.

*   grabe model to use it later
    call method o_salv_model->grabe_model
      exporting
        io_model = lo_alv_mod.

*...Generate ALV output ...............................................
    o_salv->display( ).


  endmethod.                    "generate_output

endclass.                    "lcl_report IMPLEMENTATION

*----------------------------------------------------------------------*
* LCL_SALV_MODEL implementation
*----------------------------------------------------------------------*
class lcl_salv_model implementation.

  method grabe_model.

*   save the model
    lo_model = io_model.

  endmethod.                    "grabe_model

  method grabe_controller.

*   save the controller
    o_control = lo_model->r_controller.

  endmethod.                    "grabe_controller

  method grabe_adapter.

*   save the adapter from controller
    o_adapter ?= lo_model->r_controller->r_adapter.

  endmethod.                    "grabe_adapter

endclass.                    "LCL_SALV_MODEL IMPLEMENTATION

*----------------------------------------------------------------------*
* Event Handler for the SALV
*----------------------------------------------------------------------*
class lcl_event_handler implementation.

  method on_user_command.

    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.

    case e_salv_function.

*     Make ALV as Editable ALV
      when 'MYFUNCTION'.

*       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.

    endcase.

  endmethod.                    "on_user_command

endclass.                    "lcl_event_handler IMPLEMENTATION
번호 제목 글쓴이 날짜 조회 수
670 <b>easy abap 소스 전체 파일 입니다. [188] file sapjoy 2008.05.01 10124
669 REPORT z18_033 [47] sapjoy 2008.10.13 9031
668 REPORT Z15_003 [49] sapjoy 2008.04.15 7498
667 report zunicode_027. [4] sapjoy 2008.11.21 6262
666 REPORT Z20_01. sapjoy 2012.08.01 5062
665 REPORT z18_03. sapjoy 2012.08.01 4557
664 Z01_012 [9] sapjoy 2006.12.02 4546
663 Z_EXPORT_GRAPHIC_FROM_SE78 [1] sapjoy 2011.03.28 4443
662 report zsapdoi_002. sapjoy 2008.12.26 4405
661 REPORT zsmw0010 sapjoy 2010.10.11 4313
660 REPORT z18_028 sapjoy 2007.04.09 4278
659 report zsalv_045 . sapjoy 2010.08.20 4262
658 Dynamic Table Maintenance [1] sapjoy 2006.12.04 4094
657 REPORT ZTABLE_UTIL sapjoy 2010.10.09 4010
656 REPORT Z19_02. sapjoy 2012.08.01 3926
655 report zsaptip_009 [1] sapjoy 2010.12.10 3852
654 INCLUDE ZXF04U01 sapjoy 2008.12.15 3695
653 REPORT ZTEST_ABAPTPDF sapjoy 2010.10.09 3691
652 REPORT Z_3DGRAPH. [1] sapjoy 2010.10.17 3659
651 REPORT zfalv_011. sapjoy 2011.02.16 3624