최초 작성일: 2024년 5월 13일
목적: ALV -> Search Help 이해하기
Step 02.만들어 놓은 ALV에 서치 헬프 기능 추가 하기
[소스 코드]
*&---------------------------------------------------------------------*
*& Report ZTEST_HONG_ALVSEARHELP
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_HONG_ALVSEARHELP.
TABLES:SPFLI.
"Types
TYPES:
BEGIN OF ZSPFLI02,
MANDT TYPE SPFLI-MANDT,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
COUNTFR TYPE SPFLI-COUNTRYFR,
CITYFR TYPE SPFLI-CITYFROM,
AIRFROM TYPE SPFLI-AIRPFROM,
COUNTTO TYPE SPFLI-COUNTRYTO,
CITYTO TYPE SPFLI-CITYTO,
END OF ZSPFLI02.
"Work area
DATA:
w_ZSPFLI02 TYPE ZSPFLI02.
"Internal table
DATA:
i_ZSPFLI02 TYPE STANDARD TABLE OF ZSPFLI02.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_carrid FOR spfli-carrid .
SELECTION-SCREEN SKIP.
SELECT-OPTIONS s_connid FOR spfli-connid .
SELECT-OPTIONS s_coufr FOR spfli-COUNTRYFR .
SELECT-OPTIONS s_cityfr FOR spfli-CITYFROM .
SELECTION-SCREEN SKIP.
PARAMETERS NUM TYPE I DEFAULT 10.
"PARAMETERS p_carrid TYPE scarr-carrid OBLIGATORY DEFAULT 'AA'.
SELECTION-SCREEN END OF BLOCK part1.
INITIALIZATION.
*&---------------------------------------------------------------------*
*& start of selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
*&---------------------------------------------------------------------*
*& end-of-selection.
*&---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM build_fieldcatlog.
PERFORM build_events.
PERFORM build_layout.
PERFORM list_display.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data .
SELECT MANDT
CARRID
CONNID
COUNTRYFR
CITYFROM
AIRPFROM
COUNTRYTO
CITYTO
FROM SPFLI
INTO TABLE i_ZSPFLI02
UP TO 30 ROWS.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_fieldcatlog
*&---------------------------------------------------------------------*
FORM build_fieldcatlog .
CLEAR:w_fieldcat,i_fieldcat[].
PERFORM build_fcatalog USING:
'CARRID' 'ZSPFLI02' 'CARRID',
'CARRID' 'ZSPFLI02' 'CARRID',
'CARRID' 'ZSPFLI02' 'CARRID',
'CITYFR' 'ZSPFLI02' 'CITYFR',
'AIRFROM' 'ZSPFLI02' 'AIRFROM',
'COUNTTO' 'ZSPFLI02' 'COUNTTO',
'CITYTO' 'ZSPFLI02' 'CITYTO'.
ENDFORM. "BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form BUILD_FCATALOG
*&---------------------------------------------------------------------*
FORM build_fcatalog USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcatlog
*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_events.
CLEAR :
w_events, i_events[].
w_events-name = 'TOP_OF_PAGE'."Event Name
w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
APPEND w_events TO i_events.
CLEAR w_events.
ENDFORM. "build_events
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
FORM build_layout .
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form list_display
*&---------------------------------------------------------------------*
FORM list_display .
DATA:
l_program TYPE sy-repid.
l_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_ZSPFLI02
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " list_display
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.
DATA :
li_header TYPE slis_t_listheader,
w_header LIKE LINE OF li_header.
DATA:
l_date TYPE char10.
WRITE sy-datum TO l_date.
w_header-typ = 'H'.
CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'S'.
w_header-info = sy-title.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'A'.
w_header-info = sy-uname.
APPEND w_header TO li_header.
CLEAR w_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = li_header.
ENDFORM. "top_of_page
[출력 화면]
Search help 1단계로
start of selection 앞에
'initialization' 과 'SELECTION-SCREEN' 구문을 통해서 ALV 화면에서 Search Help를 추가 시킴
SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_carrid FOR spfli-carrid .
SELECTION-SCREEN SKIP.
SELECT-OPTIONS s_connid FOR spfli-connid .
SELECT-OPTIONS s_coufr FOR spfli-COUNTRYFR .
SELECT-OPTIONS s_cityfr FOR spfli-CITYFROM .
SELECTION-SCREEN SKIP.
PARAMETERS NUM TYPE I DEFAULT 10.
"PARAMETERS p_carrid TYPE scarr-carrid OBLIGATORY DEFAULT 'AA'.
SELECTION-SCREEN END OF BLOCK part1.
INITIALIZATION.
'SAP > ABAP' 카테고리의 다른 글
ALV+SearchHelp+SelectOption(1/3) (0) | 2024.05.14 |
---|---|
[Search Help] Search Help 만들어서 적용시키기 3/3 (0) | 2024.05.13 |
[Search Help] Seach Help 기본 동작 원리 이해 하기 1/3 (0) | 2024.05.13 |
ABAP: 기본 구성요소 (0) | 2023.10.25 |
시뮬레이터 코드 이해하기 (0) | 2023.10.20 |