DATA: lt_tab TYPE REF TO cl_salv_table,
lr_cols TYPE REF TO cl_salv_columns_table, "레이아웃
lr_col TYPE REF TO cl_salv_column_table, "컬럼 속성 제어
ls_color TYPE lvc_s_colo, " 컬럼 색깔
lo_sorts TYPE REF TO cl_salv_sorts, " 정렬
lr_display TYPE REF TO cl_salv_display_settings, " 헤더
lr_filter TYPE REF TO cl_salv_filters," 필터
lo_event TYPE REF TO cl_salv_events_table. " event
" 필터 적용 변수
DATA: l_low TYPE salv_de_selopt_low,
l_fname TYPE lvc_fname,
l_option TYPE salv_de_selopt_option,
l_sign TYPE salv_de_selopt_sign,
l_high TYPE salv_de_selopt_high.
cl_salv_table
을 사용하여 아주 간단하게 alv를 띄워보자 cl_salv_table=>factory(
IMPORTING
r_salv_table = lt_tab " Basis Class Simple ALV Tables
CHANGING
t_table = gt_log ).
*-- Layout & Column 설정
lr_cols = gt_disp->get_columns( ). "OPTIMIZE LAYOUT
* lr_cols->set_optimize( abap_true ).
" 필드명
lr_col ?= lr_cols->get_column( 'STATUS' ).
lr_col->set_long_text( '상태').
lr_col->set_medium_text( '상태').
lr_col->set_short_text( '상태').
lr_col ?= lr_cols->get_column( 'BANFN' ).
ls_color-col = '4'.
ls_color-int = '1'.
ls_color-inv = '0'.
lr_col->set_color( ls_color ).
lr_col->set_output_length( 10 ).
lr_col ?= lr_cols->get_column( 'BNFPO' ).
ls_color-col = '4'.
ls_color-int = '1'.
ls_color-inv = '0'.
lr_col->set_color( ls_color ).
lr_col->set_output_length( 6 ).
lr_col ?= lr_cols->get_column( 'MSG' ).
lr_col->set_output_length( 50 ).
lr_col ?= lr_cols->get_column( 'NUMBER' ).
lr_col->set_visible( ' ' ).
*-- POP 타이틀 헤더 설정
lr_display = gt_disp->get_display_settings( ).
lr_display->set_list_header( '에러 로그 확인' ).
*-- PF-STATUS 설정
gt_disp->set_screen_status(
pfstatus = 'POPUP_STATUS'
report = sy-repid
set_functions = gt_disp->c_functions_all ).
*-- 필터 설정 ( 에러 로그 )
l_fname = 'STATUS'.
l_low = icon_led_red.
lr_filter = gt_disp->get_filters( ).
lr_filter->add_filter(
EXPORTING
columnname = l_fname
sign = 'I' " Selection Condition Sign
option = 'EQ' " Selection Condition Option
low = l_low ).
*-- 위치 조정
CALL METHOD gt_disp->set_screen_popup
EXPORTING
start_column = 10
end_column = 90 " 가로
start_line = 1
end_line = 25.
*-- SORT 설정
" 요청번호, 구매문서번호, 고정공급업체 별 sort
CALL METHOD gt_disp->get_sorts
RECEIVING
value = lo_sorts." ALV Sort
CALL METHOD lo_sorts->add_sort
EXPORTING
columnname = 'BANFN'
sequence = if_salv_c_sort=>sort_down. " Sort Sequence
CALL METHOD lo_sorts->add_sort
EXPORTING
columnname = 'BNFPO'
sequence = if_salv_c_sort=>sort_down. " Sort Sequence
*-- 이벤트 등록
lo_event = gt_disp->get_event( ).
SET HANDLER lcl_handler=>on_user_command2 FOR lo_event.
*-- popup alv display.
gt_disp->display( ).
-> 자식 클래스 ?= 부모 클래스의 경우에 사용.
lr_col ?= lr_cols->get_column( 'NUMBER' ).
lr_col->set_visible( ' ' ).
부모 클래스(lr_cols)의 get_column 메소드를 통한 값을 lr_col에 넘겨서 사용.
CLASS lcl_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_user_command2 FOR EVENT added_function OF cl_salv_events_table
IMPORTING e_salv_function. " popup toolbar control
ENDCLASS. "lcl_handler DEFINITION
CLASS lcl_handler IMPLEMENTATION.
METHOD on_user_command2.
CASE e_salv_function.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
WHEN 'ALL'.
" popup toolbar 버튼 클릭 시.
PERFORM disp_all_log. " 성공 로그까지 Display
WHEN 'ERROR'.
" popup toolbar 버튼 클릭 시.
PERFORM disp_error_log.
ENDCASE.
ENDMETHOD. "on_user_command2
ENDCLASS. "lcl_handler IMPLEMENTATION
앞선 코드에서 l_low로 필터가 적용된 팝업이 호출된다.
- 에러 로그는 초기 필터가 적용된 팝업을 호출하고,
초기 필터 적용부는 앞선 코드 참고
METHOD on_user_command2.
CASE e_salv_function.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
WHEN 'ALL'.
" 전체 로그
PERFORM disp_all_log.
WHEN 'ERROR'.
" 에러 로그
PERFORM disp_error_log.
ENDCASE.
ENDMETHOD. "on_user_command2
PERFORM disp_all_log
cl_salv_filters
를 찾아가면 적용되는 여러 함수들이 있음DATA: lr_filter TYPE REF TO cl_salv_filters, " 필터
lo_event TYPE REF TO cl_salv_events_table. " event
DATA: l_fname TYPE lvc_fname.
*-- 필터 설정 ( 에러 로그 )
l_fname = 'STATUS'.
lr_filter = gt_disp->get_filters( ).
lr_filter->remove_filter( columnname = l_fname ).
gt_disp->refresh( ).
PERFORM disp_error_log
DATA:
lr_filter TYPE REF TO cl_salv_filters, " 필터
lo_event TYPE REF TO cl_salv_events_table. " event
DATA: l_low TYPE salv_de_selopt_low,
l_fname TYPE lvc_fname,
l_option TYPE salv_de_selopt_option,
l_sign TYPE salv_de_selopt_sign,
l_high TYPE salv_de_selopt_high.
*-- 필터 설정 ( 에러 로그 )
l_fname = 'STATUS'.
l_low = icon_led_red.
lr_filter = gt_disp->get_filters( ).
lr_filter->remove_filter( columnname = l_fname ).
lr_filter->add_filter(
EXPORTING
columnname = l_fname
sign = 'I' " Selection Condition Sign
option = 'EQ' " Selection Condition Option
low = l_low ).
gt_disp->refresh( ).
ㅂㅂ
코드 색깔 어떻게 알록달록하게 하셨나요?? -.-