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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
650 | <b>ABAP SOURCE는 교재에 사용된 소스들입니다.</b> [1] | sapjoy | 2006.12.02 | 3618 |
649 | REPORT z19_01. | sapjoy | 2012.08.01 | 3531 |
648 | z_exception_test | sapjoy | 2010.10.10 | 3520 |
647 | report zsalv_036 . | sapjoy | 2010.08.20 | 3472 |
646 | REPORT z18_04 . | sapjoy | 2012.08.01 | 3353 |
645 | REPORT ZSMARTFORMS_03. | sapjoy | 2008.11.28 | 3345 |
644 | REPORT z18_05 | sapjoy | 2012.08.01 | 3334 |
643 | Sub DOI_EXCEL_MACRO() | sapjoy | 2008.12.26 | 3312 |
642 | subroutine pool | sapjoy | 2013.11.15 | 3282 |
641 | REPORT z18_003 | sapjoy | 2007.03.05 | 3281 |
640 | REPORT z19_004 | sapjoy | 2007.03.27 | 3230 |
639 | REPORT Z_WHEREUSEDLIST [4] | sapjoy | 2011.03.28 | 3215 |
638 | REPORT ZALVCOLOR | sapjoy | 2010.10.09 | 3212 |
» | zsalv_edit [1] | sapjoy | 2010.08.20 | 3208 |
636 | REPORT ZSAPTIP_002. | sapjoy | 2009.02.20 | 3207 |
635 | REPORT Z06_001 MESSAGE-ID ZTEST . [1] | sapjoy | 2006.12.05 | 3205 |
634 | REPORT z18_06. | sapjoy | 2012.08.01 | 3159 |
633 | REPORT zsapdoi_001. [2] | sapjoy | 2008.12.20 | 3137 |
632 | report zsalv_042 . | sapjoy | 2010.08.20 | 3132 |
631 | REPORT z18_01. | sapjoy | 2012.08.01 | 3114 |
좋은자료 감사합니다!
순수하게 정보의 공유만을 위해 후기를 남기자면,
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12187
여기 BLOG 의 댓글들을 보면 (더듬더듬 해석이지만)
SAP 개발자들은 이것이 우회적인 방법이라는 뉘앙스를 언급하면서, 클래스가 이렇게 설계된 것이 아니라고 warning 을 한것으로 보입니다.
(다른 개발자들은 답변하기를 SAP 에서 CL_SALV_TABLE 에서 이를 다룰수 있게 바꾸어야 할것이라고 이야기하는군요)
개발자가 이를 사용할때에는 이 issue 를 고려해 볼 필요가 있을것으로 보입니다.