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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
371 | report zsalv_021 . | sapjoy | 2010.08.20 | 2293 |
370 | report zsalv_020 . | sapjoy | 2010.08.20 | 2381 |
369 | report zsalv_019 . | sapjoy | 2010.08.20 | 2272 |
368 | report zsalv_018 . | sapjoy | 2010.08.20 | 2327 |
367 | report zsalv_017 . | sapjoy | 2010.08.20 | 2270 |
366 | report zsalv_015 | sapjoy | 2010.08.20 | 2280 |
365 | report zsalv_014 | sapjoy | 2010.08.20 | 2299 |
364 | report zsalv_013 | sapjoy | 2010.08.20 | 2361 |
363 | report zsalv_012 | sapjoy | 2010.08.20 | 2271 |
362 | report zsalv_011 | sapjoy | 2010.08.20 | 2331 |
361 | report zsalv_010 | sapjoy | 2010.08.20 | 2294 |
360 | report zsalv_004 | sapjoy | 2010.08.20 | 3078 |
359 | report zsalv_003 | sapjoy | 2010.08.20 | 2336 |
358 | report zsalv_002 [1] | sapjoy | 2010.08.20 | 2476 |
357 | report zsalv_001 | sapjoy | 2010.08.20 | 2442 |
» | zsalv_edit [1] | sapjoy | 2010.08.20 | 3235 |
355 | REPORT ZRTTS_02 | sapjoy | 2009.12.24 | 2586 |
354 | REPORT ZRTTS_01 . | sapjoy | 2009.12.24 | 2670 |
353 | Z16_005TOP | sapjoy | 2009.09.22 | 2549 |
352 | Z16_005 | sapjoy | 2009.09.22 | 2579 |
좋은자료 감사합니다!
순수하게 정보의 공유만을 위해 후기를 남기자면,
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12187
여기 BLOG 의 댓글들을 보면 (더듬더듬 해석이지만)
SAP 개발자들은 이것이 우회적인 방법이라는 뉘앙스를 언급하면서, 클래스가 이렇게 설계된 것이 아니라고 warning 을 한것으로 보입니다.
(다른 개발자들은 답변하기를 SAP 에서 CL_SALV_TABLE 에서 이를 다룰수 있게 바꾸어야 할것이라고 이야기하는군요)
개발자가 이를 사용할때에는 이 issue 를 고려해 볼 필요가 있을것으로 보입니다.