Z_ALV
*&---------------------------------------------------------------------*
*& Include ZFI_ALV
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& ALV 관련 클래스 관련 선언 및 구현, 변수 *
*&---------------------------------------------------------------------*
* TABLES
*TABLES : ICON. " 아이콘테이블
*INCLUDE <ICON>.
** TYPES
*TYPE-POOLS : SLIS, F4TYP, SDYDO.
*
TYPES : BEGIN OF t_msg,
msgid TYPE symsgid,
msgno TYPE symsgno,
msgty,
msg1(50),
msg2(50),
msg3(50),
msg4(50),
END OF t_msg.
DATA : gs_msg TYPE t_msg.
*
DATA : BEGIN OF gt_top_of_page_txt OCCURS 0,
top_text TYPE sdydo_text_element,
fontsize TYPE sdydo_attribute,
color TYPE sdydo_attribute,
END OF gt_top_of_page_txt.
DATA : gv_repid TYPE sy-repid.
DATA : gv_dynnr TYPE sy-dynnr.
DATA : gv_refresh TYPE c.
* STRUCTURES
DATA : gs_layout TYPE slis_layout_alv,
gs_exgt_caused_by_user TYPE slis_exit_by_user,
gs_fieldcat TYPE slis_fieldcat_alv,
gs_sort TYPE slis_sortinfo_alv,
gs_keyinfo TYPE slis_keyinfo_alv,
gs_variant TYPE disvariant,
gs_scroll TYPE slis_list_scroll,
gs_detail_func LIKE dd02l-tabname.
DATA : gs_lvc_layo1 TYPE lvc_s_layo, " LAYOUT\
gs_lvc_layo2 TYPE lvc_s_layo,
gs_lvc_layo3 TYPE lvc_s_layo,
gs_lvc_layo4 TYPE lvc_s_layo.
DATA : gs_lvc_fcat TYPE lvc_s_fcat. " FIELDCATALOG
DATA : gs_row LIKE lvc_s_row,
gs_col LIKE lvc_s_col.
DATA : gs_stable TYPE lvc_s_stbl.
FIELD-SYMBOLS : <gfs_t_fcat> TYPE lvc_t_fcat,
<gfs_s_fcat> TYPE lvc_s_fcat,
<gfs_t_sort> TYPE lvc_t_sort,
<gfs_s_sort> TYPE lvc_s_sort.
* INTERNAL TABLES
DATA : gt_events TYPE slis_t_event,
gt_listheader TYPE slis_t_listheader,
gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_exit TYPE slis_event_exit OCCURS 0,
gt_print TYPE slis_print_alv.
DATA : gt_ui_functions1 TYPE ui_functions, " TOOLBAR
gt_ui_functions2 TYPE ui_functions,
gt_ui_functions3 TYPE ui_functions,
gt_ui_functions4 TYPE ui_functions.
DATA : gt_lvc_sort1 TYPE lvc_t_sort, " SORT
gt_lvc_sort2 TYPE lvc_t_sort,
gt_lvc_sort3 TYPE lvc_t_sort,
gt_lvc_sort4 TYPE lvc_t_sort.
DATA : gt_lvc_fcat1 TYPE lvc_t_fcat, " FIELDCATALOG
gt_lvc_fcat2 TYPE lvc_t_fcat,
gt_lvc_fcat3 TYPE lvc_t_fcat,
gt_lvc_fcat4 TYPE lvc_t_fcat.
* DROP-DOWN LIST BOX 관련 ----------------------------------------------
DATA : gt_lvc_drop TYPE lvc_t_drop,
gs_lvc_drop TYPE lvc_s_drop.
* COLUMN COLOR 관련 ----------------------------------------------------
DATA : gt_alv_color TYPE lvc_t_scol WITH HEADER LINE,
gs_alv_color TYPE lvc_s_colo.
* 선택된 ROW 관련 ------------------------------------------------------
DATA : gt_rows TYPE lvc_t_row,
gs_rows TYPE lvc_s_row,
gv_fun(1) VALUE 'D'.
* F4 POSSIBLE ENTRY ----------------------------------------------------
* STRUCTURES
DATA : gs_f4_value TYPE seahlpres,
gs_f4_field TYPE dfies,
gs_f4 TYPE ddshretval,
gs_lvc_modi TYPE lvc_s_modi,
gs_lvc_f4 TYPE lvc_s_f4.
* INTERNAL TABLES
DATA : gt_f4_values TYPE TABLE OF seahlpres,
gt_f4_fields TYPE TABLE OF dfies,
gt_lvc_f4 TYPE lvc_t_f4.
* FIELD SYMBOLS
FIELD-SYMBOLS : <fs_f4tab> TYPE lvc_t_modi.
DATA : gv_consistency_check(1) TYPE c.
DATA : gv_alv_colpos TYPE i.
" ALV 신호등 처리
CONSTANTS : gc_status_green LIKE icon-id VALUE icon_green_light.
CONSTANTS : gc_status_yellow LIKE icon-id VALUE icon_yellow_light.
CONSTANTS : gc_status_red LIKE icon-id VALUE icon_red_light.
CONSTANTS : gc_status_init LIKE icon-id VALUE icon_light_out.
DATA : gv_top_of_page(255) TYPE c.
************************************************************************
* THE DECLARATION OF VARIABLES
************************************************************************
* CONTROL관련 데이타 선언
CLASS : lcl_def_receiver DEFINITION DEFERRED,
lcl_def_grid DEFINITION DEFERRED.
* REFERENCE TO CUSTOM CONTAINER: NECCESSARY TO BIND ALV CONTROL
CONSTANTS : gc_alv1_contname TYPE scrfname VALUE 'ALV1_CONT'.
CONSTANTS : gc_alv2_contname TYPE scrfname VALUE 'ALV2_CONT'.
CONSTANTS : gc_alv3_contname TYPE scrfname VALUE 'ALV3_CONT'.
CONSTANTS : gc_alv4_contname TYPE scrfname VALUE 'ALV4_CONT'.
DATA :
go_container_top1 TYPE REF TO cl_gui_container,
go_container_alv1 TYPE REF TO cl_gui_container,
go_container_top2 TYPE REF TO cl_gui_container,
go_container_alv2 TYPE REF TO cl_gui_container,
go_container_top3 TYPE REF TO cl_gui_container,
go_container_alv3 TYPE REF TO cl_gui_container,
go_container_top4 TYPE REF TO cl_gui_container,
go_container_alv4 TYPE REF TO cl_gui_container,
go_alv1 TYPE REF TO lcl_def_grid,
go_alv2 TYPE REF TO lcl_def_grid,
go_alv3 TYPE REF TO lcl_def_grid,
go_alv4 TYPE REF TO lcl_def_grid,
go_splitter0 TYPE REF TO cl_gui_easy_splitter_container,
go_splitter1 TYPE REF TO cl_gui_splitter_container,
go_splitter2 TYPE REF TO cl_gui_splitter_container,
go_splitter3 TYPE REF TO cl_gui_splitter_container,
go_splitter4 TYPE REF TO cl_gui_splitter_container,
go_docking TYPE REF TO cl_gui_container,
go_column_tree TYPE REF TO cl_gui_column_tree,
go_tree TYPE REF TO cl_gui_alv_tree,
go_toolbar TYPE REF TO cl_gui_toolbar,
go_textedit TYPE REF TO cl_gui_textedit,
go_event_receiver1 TYPE REF TO lcl_def_receiver,
go_event_receiver2 TYPE REF TO lcl_def_receiver,
go_event_receiver3 TYPE REF TO lcl_def_receiver,
go_event_receiver4 TYPE REF TO lcl_def_receiver.
DATA : go_docking_cont1 TYPE REF TO cl_gui_docking_container.
DATA : go_docking_cont2 TYPE REF TO cl_gui_docking_container.
DATA : go_docking_cont3 TYPE REF TO cl_gui_docking_container.
DATA : go_docking_cont4 TYPE REF TO cl_gui_docking_container.
DATA : go_dd_document1 TYPE REF TO cl_dd_document.
DATA : go_dd_document2 TYPE REF TO cl_dd_document.
DATA : go_dd_document3 TYPE REF TO cl_dd_document.
DATA : go_dd_document4 TYPE REF TO cl_dd_document.
DATA : go_html_view1 TYPE REF TO cl_gui_html_viewer.
DATA : go_html_view2 TYPE REF TO cl_gui_html_viewer.
DATA : go_html_view3 TYPE REF TO cl_gui_html_viewer.
DATA : go_html_view4 TYPE REF TO cl_gui_html_viewer.
DATA : go_ddic_fcat TYPE lvc_t_fcat.
*---------------------------------------------------------------------*
* CLASS LCL_DEF_GRID1 DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_def_grid DEFINITION INHERITING FROM cl_gui_alv_grid.
PUBLIC SECTION.
METHODS : u_set_fixed_rows,
u_set_resize_cols,
u_scroll_to_bottom,
u_set_optimize,
u_set_current_cell_base
IMPORTING
row TYPE i
col TYPE i.
ENDCLASS. "LCL_DEF_GRID DEFINITION
*---------------------------------------------------------------------*
* CLASS LCL_DEF_GRID IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_def_grid IMPLEMENTATION.
METHOD u_set_fixed_rows.
CALL METHOD me->set_fixed_rows
EXPORTING
rows = 1.
ENDMETHOD. " U_SET_FIXED_ROWS
METHOD u_set_resize_cols.
CALL METHOD me->set_resize_cols
EXPORTING
enable = 1. " NO
ENDMETHOD. " U_SET_RESIZE_COLS
METHOD u_scroll_to_bottom.
CALL METHOD me->scroll_to_bottom.
ENDMETHOD. " U_SCROLL_TO_BOTTOM
METHOD u_set_current_cell_base.
CALL METHOD me->set_current_cell_base
EXPORTING
row = row
col = col.
ENDMETHOD. " U_SET_CURRENT_CELL_BASE
METHOD u_set_optimize.
CALL METHOD me->optimize_all_cols
EXPORTING
include_header = 1.
ENDMETHOD. " U_SET_OPTIMIZE
ENDCLASS. " LCL_DEF_GRID IMPLEMENTATION
************************************************************************
* 선언부 외의 ALV 공용
************************************************************************
*&---------------------------------------------------------------------*
*& Form F_CLEAR_CONTAINER_PROC
*&---------------------------------------------------------------------*
* CLEAR, REFRESH 처리를 한다.
*----------------------------------------------------------------------*
* -->PV_CONTAINER text
* -->PV_ALV_GRID text
*----------------------------------------------------------------------*
FORM clear_container_proc USING
pv_alv_grid TYPE REF TO lcl_def_grid
pv_container TYPE REF TO cl_gui_docking_container
pv_split_cont TYPE REF TO cl_gui_splitter_container
pv_cont_top TYPE REF TO cl_gui_container
pv_cont_alv TYPE REF TO cl_gui_container
pv_html TYPE REF TO cl_gui_html_viewer
pv_event TYPE REF TO lcl_def_receiver.
IF NOT pv_html IS INITIAL.
CALL METHOD pv_html->free.
CLEAR pv_html.
ENDIF.
*-- 먼저 ALVGRID 를 먼저 FREE 한다.
IF NOT pv_alv_grid IS INITIAL.
CALL METHOD pv_alv_grid->free.
CLEAR pv_alv_grid.
ENDIF.
IF NOT pv_cont_top IS INITIAL.
CALL METHOD pv_cont_top->free.
CLEAR pv_cont_top.
ENDIF.
IF NOT pv_cont_alv IS INITIAL.
CALL METHOD pv_cont_alv->free.
CLEAR pv_cont_alv.
ENDIF.
IF NOT pv_split_cont IS INITIAL.
CALL METHOD pv_split_cont->free.
CLEAR pv_split_cont.
ENDIF.
CLEAR : pv_event.
*-- CONTAINER 를 FREE 한다..
IF NOT pv_container IS INITIAL.
CALL METHOD pv_container->free.
CLEAR pv_container.
ENDIF.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
ENDFORM. " F_CLEAR_CONTAINER_PROC
*&---------------------------------------------------------------------*
*& Form GET_SELECTED_ROW
*&---------------------------------------------------------------------*
* ALV 선택된 라인 가져오기
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_selected_row USING pv_grid TYPE REF TO lcl_def_grid.
* SELECTED ROW
CLEAR : gt_rows[], gs_rows.
CALL METHOD pv_grid->get_selected_rows
IMPORTING
et_index_rows = gt_rows.
ENDFORM. " GET_SELECTED_ROW
*&---------------------------------------------------------------------*
*& Form F_REFRESH_CONTAINER
*&---------------------------------------------------------------------*
* 화면의 REFRESH 처리 등을 한다.
*----------------------------------------------------------------------*
* -->PV_CONTAINER text
* -->PV_ALV_GRID text
*----------------------------------------------------------------------*
FORM refresh_container
USING pv_alv_grid TYPE REF TO lcl_def_grid
pv_lvc_layo TYPE lvc_s_layo
p_gubun TYPE c.
* 로컬변수선언
DATA : ls_stable TYPE lvc_s_stbl.
DATA : lv_soft TYPE c.
CLEAR : ls_stable.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
IF p_gubun EQ 'S'.
lv_soft = 'X'.
ENDIF.
* Grid Layout Reset => Column Width Optimize and so on
* refresh 후에 원래대로 Grid 가 표시되도록 하는 처리
CALL METHOD pv_alv_grid->set_frontend_layout
EXPORTING
is_layout = pv_lvc_layo.
CALL METHOD pv_alv_grid->refresh_table_display
EXPORTING
i_soft_refresh = lv_soft "'X'이면 자체기준으로 SORT한다.
is_stable = ls_stable.
* Send Buffered Automation Queue to Frontend
CALL METHOD cl_gui_cfw=>flush.
ENDFORM. " F_REFRESH_CONTAINER
*&---------------------------------------------------------------------*
*& Form APPEND_EXCLUDE_FUNCTIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_TABLE text
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM append_exclude_functions TABLES pt_table
USING p_value.
DATA : l_ui_func TYPE ui_func.
l_ui_func = p_value.
APPEND l_ui_func TO pt_table.
ENDFORM. " APPEND_EXCLUDE_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form REGISTER_ALV_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_ALV text
* -->P_P_RECEIVER text
*----------------------------------------------------------------------*
FORM register_alv_event USING
p_alv_grid TYPE REF TO lcl_def_grid
p_receiver TYPE REF TO lcl_def_receiver.
ENDFORM. " REGISTER_ALV_EVENT
*&---------------------------------------------------------------------*
*& Form CHECK_ALV_PARAMETER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM check_sort_parameter
USING pt_fieldcat TYPE lvc_t_fcat
pt_sort TYPE lvc_t_sort
CHANGING p_fieldname p_subrc .
FIELD-SYMBOLS : <fs_sort> TYPE lvc_s_sort.
FIELD-SYMBOLS : <fs_fcat> TYPE lvc_s_fcat.
CLEAR : p_subrc, p_fieldname.
LOOP AT pt_sort ASSIGNING <fs_sort>.
READ TABLE pt_fieldcat ASSIGNING <fs_fcat>
WITH KEY fieldname = <fs_sort>-fieldname.
IF sy-subrc NE 0.
p_subrc = sy-subrc.
p_fieldname = <fs_sort>-fieldname.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FIELDCATALOG_MERGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0047 text
* -->P_0048 text
*----------------------------------------------------------------------*
FORM fieldcatalog_merge USING pv_table pv_fcat.
ASSIGN (pv_fcat) TO <gfs_t_fcat>.
" Field catalog is must be via dictionary
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = pv_table
CHANGING
ct_fieldcat = <gfs_t_fcat>
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE s000(zfi) WITH TEXT-m02. " Failed create field fatalog
LEAVE TO SCREEN 0.
ENDIF.
ENDFORM.
댓글 없음:
댓글 쓰기