아래 소스와 같이 수정 하고 싶은 필드에만 EDIT을 하였는데요 DATA CHANGE이벤트 같은거 해줘야 ITAB내용이 수정 될꺼 같더라구요 아래 소스같이만 하면 행삽입, 행삭제 , EDIT기능이용해서 ITAB내용 수정 했을시에 ITAB에 반영이 안되는거 같아요. 글구 추가로 행 선택시 마크에 X표시가 걸려야 되는데 아래 소스에서 엇게 처리 해야 하는지요.....
혹시 아시는 분께선 소스나 참고 자료좀 추천 해주시면 감사하겠습니다. ( 아래 소스는 외국 사이트서 구한건데 연구중이라요 원래 EDIT기능 하기 위해 짠 소스가 아닌데 제가 그걸 해보려다 막혀서여 도와줍쇼~ ㅜㅜ)
* 아래 소스에선 GT_MARA_ALL인터널 테이블러 ALV출력 하는것입니다.
report z_alv_grid_ctrl_refresh_2.
tables : mara.
types:
begin of ty_s_mara,
matnr like mara-matnr,
ernam like mara-ernam,
ersda like mara-ersda,
brgew like mara-brgew,
meins like mara-meins,
end of ty_s_mara.
class lcl_event_alv definition deferred.
data:
gt_mara type standard table of mara,
go_container type ref to cl_gui_docking_container,
go_alv_grid type ref to cl_gui_alv_grid,
go_events type ref to lcl_event_alv,
gt_mara_ftr type standard table of mara, " Data filtered
gt_mara_all type standard table of mara, " Data readfrom DB
okcode type syucomm,
gv_okcode type syucomm.
*---------------------------------------------------------------------*
* CLASS lcl_event_alv DEFINITION
*---------------------------------------------------------------------*
class lcl_event_alv definition.
public section.
methods:
h_user_command for event after_user_command of cl_gui_alv_grid
importing e_ucomm
sender.
endclass. " LCL_EVENT_ALV DEFINITION
*---------------------------------------------------------------------*
* Class (Implementation) lcl_event_alv
*---------------------------------------------------------------------*
class lcl_event_alv implementation.
method h_user_command.
case e_ucomm.
when '&SORT_ASC' or '&SORT_DSC'. " Sort
perform f_sort_big_table.
* PERFORM f_read_data USING c_first_page.
perform f_refresh_table.
when '&FILTER'. " Filter
perform f_filter_data.
* PERFORM f_read_data USING c_first_page.
perform f_refresh_table.
when '&DELETE_FILTER'. " Delete filter
* gt_mara_ftr[] = gt_mara_all[].
* PERFORM f_read_data USING c_first_page.
perform f_refresh_table.
endcase.
endmethod. " user_command
endclass. " LCL_EVENT_ALV
*---------------------------------------------------------------------*
*SELECTION-SCREEN :
*BEGIN OF LINE,COMMENT 10(20) v_1 FOR FIELD p_max. "#EC NEEDED
*PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY.
*SELECTION-SCREEN END OF LINE.
selection-screen : begin of block param with frame title text-t13.
selection-screen skip 1.
select-options : s_matnr for mara-matnr.
selection-screen skip 1.
selection-screen end of block param.
*---------------------------------------------------------------------*
initialization.
* v_1 = 'Lines per page'.
*---------------------------------------------------------------------*
start-of-selection.
select *
into corresponding fields of table gt_mara_all
from mara
where matnr in s_matnr.
loop at gt_mara_all into mara.
* APPEND mara TO gt_mara_ftr.
endloop.
* gt_mara_ftr = gt_mara_all.
call screen 100.
*---------------------------------------------------------------------*
* Module pbo_0100 OUTPUT
*---------------------------------------------------------------------*
module pbo_0100 output.
set pf-status 'MAIN'.
set titlebar 'MAIN1'.
perform create_and_init_alv.
endmodule. " PBO_0100 OUTPUT
*---------------------------------------------------------------------*
* Module user_command_0100 INPUT
*---------------------------------------------------------------------*
module user_command_0100 input.
gv_okcode = okcode.
clear okcode.
case gv_okcode.
when 'BACK'.
set screen 0.
when 'EXIT'.
leave program.
* WHEN c_first_page OR c_next_page OR c_last_page OR c_prev_page.
when 'REFRESH'.
call screen 200.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*---------------------------------------------------------------------*
* Form create_and_init_alv
*---------------------------------------------------------------------*
form create_and_init_alv.
* Macro definition
define m_fieldcat.
ls_alv_cat-col_pos = 1.
ls_alv_cat-fieldname = 'ERNAM'.
ls_alv_cat-ref_table = 'MARA'.
ls_alv_cat-edit = ' '.
append ls_alv_cat to lt_alv_cat.
ls_alv_cat-col_pos = 2.
ls_alv_cat-fieldname = 'MATNR'.
ls_alv_cat-ref_table = 'MARA'.
ls_alv_cat-edit = ' '.
append ls_alv_cat to lt_alv_cat.
ls_alv_cat-col_pos = 3.
ls_alv_cat-fieldname = 'ERSDA'.
ls_alv_cat-ref_table = 'MARA'.
ls_alv_cat-edit = 'X'.
append ls_alv_cat to lt_alv_cat.
ls_alv_cat-col_pos = 4.
ls_alv_cat-fieldname = 'BRGEW'.
ls_alv_cat-ref_table = 'MARA'.
ls_alv_cat-edit = 'X'.
append ls_alv_cat to lt_alv_cat.
ls_alv_cat-col_pos = 5.
ls_alv_cat-fieldname = 'MEINS'.
ls_alv_cat-ref_table = 'MARA'.
ls_alv_cat-no_out = 'X'.
append ls_alv_cat to lt_alv_cat.
end-of-definition.
data:
ls_variant type disvariant,
lt_alv_cat type lvc_t_fcat,
ls_alv_cat type lvc_s_fcat,
ls_alv_lay type lvc_s_layo,
l_offline type char1.
check go_container is initial.
call method cl_gui_alv_grid=>offline
receiving
e_offline = l_offline.
if l_offline eq 0.
create object go_container
exporting
extension = 2000
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
if sy-subrc ne 0.
message e999(zmcmm) with 'The control could not be created'.
endif.
endif.
* Create an instance of alv control
create object go_alv_grid
exporting i_parent = go_container.
create object go_events.
set handler go_events->h_user_command for go_alv_grid.
* Build field catalog
m_fieldcat.
* m_fieldcat.
* m_fieldcat.
* m_fieldcat.
* Layout
clear ls_alv_lay.
ls_alv_lay-zebra = 'X'.
ls_alv_lay-cwidth_opt = 'X'.
ls_variant-report = sy-cprog.
* Display
call method go_alv_grid->set_table_for_first_display
exporting
is_variant = ls_variant
is_layout = ls_alv_lay
i_save = 'A'
changing
it_outtab = gt_mara_all
it_fieldcatalog = lt_alv_cat.
endform. " CREATE_AND_INIT_ALV
*---------------------------------------------------------------------*
* Form F_REFRESH_TABLE
*---------------------------------------------------------------------*
form f_refresh_table.
data: ls_layout type lvc_s_layo.
call method go_alv_grid->get_frontend_layout
importing
es_layout = ls_layout.
ls_layout-cwidth_opt = 'X'.
call method go_alv_grid->set_frontend_layout
exporting
is_layout = ls_layout.
call method go_alv_grid->refresh_table_display.
endform. " F_REFRESH_TABLE
*---------------------------------------------------------------------*
* Form F_SORT_BIG_TABLE
*---------------------------------------------------------------------*
form f_sort_big_table.
data:
lt_sort_kkblo type kkblo_t_sortinfo,
lt_sort type lvc_t_sort.
call method go_alv_grid->get_sort_criteria
importing
et_sort = lt_sort.
check not lt_sort[] is initial.
* Format LVC --> KKBLO
call function 'LVC_TRANSFER_TO_KKBLO'
exporting
it_sort_lvc = lt_sort
importing
et_sort_kkblo = lt_sort_kkblo.
* The big tables must be sorted like the small one
perform fb_outtab_sort(saplkkbl) tables gt_mara_ftr
lt_sort_kkblo
using 'X'
'X'.
perform fb_outtab_sort(saplkkbl) tables gt_mara_all
lt_sort_kkblo
using 'X'
'X'.
endform. " F_SORT_BIG_TABLE
*---------------------------------------------------------------------*
* Form f_filter_data
*---------------------------------------------------------------------*
form f_filter_data.
data:
lt_filter_lvc type lvc_t_filt,
lt_filter_index type lvc_t_fidx with header line.
call method go_alv_grid->get_filter_criteria
importing
et_filter = lt_filter_lvc.
* Find data to filter
call function 'LVC_FILTER_APPLY'
exporting
it_filter = lt_filter_lvc
importing
et_filter_index = lt_filter_index[]
tables
it_data = gt_mara_all.
sort lt_filter_index descending.
loop at lt_filter_index.
delete gt_mara_all index lt_filter_index.
endloop.
endform. " F_FILTER_DATA
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0200 output.
set pf-status 'ZKJK1'.
set titlebar 'xxx'.
endmodule. " STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0200 input.
gv_okcode = okcode.
clear okcode.
case gv_okcode.
when 'BACK'.
set screen 100.
when 'EXIT'.
leave program.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
*& Module ITAB_MODIFY INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module itab_modify input.
loop at screen.
modify screen.
endloop.
loop at gt_mara_all into mara.
modify gt_mara_all index sy-tabix from mara.
endloop.
* MODIFY gt_mara_all FROM mara-ernam.
* MODIFY gt_mara_all FROM mara-ersda.
* MODIFY gt_mara_all FROM mara-brgew.
* MODIFY gt_mara_all FROM mara-meins.
endmodule. " ITAB_MODIFY INPUT
*&---------------------------------------------------------------------*
*& Module ITAB_MODIFY0 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module itab_modify0 output.
loop at screen.
modify screen.
endloop.
loop at gt_mara_all into mara.
modify gt_mara_all index sy-tabix from mara.
endloop.
endmodule. " ITAB_MODIFY0 OUTPUT
인터널 테이블에 Mark(1) 필드 하나 선언하시고 레이아웃에 mark 관련 필드 찾으셔서 필드 이름을 값으로 넘겨주면 됩니다.
또는 필드 카탈로그에 마크 관련 필드가 있는데 그거 사용해도 되구요
수고하세요.