말씀드릴 사항으로.. 테스트 소스가 필요하시면 메일을 주세요~
마우스 우클릭을 막은 상태니 메일 확인 후 보내드리겠습니다.
최근의 경우 METHOD 를 이용한 ALV 를 거의 사용하는데, TOP-OF-PAGE 가 필요할 경우가 종종있다.
일반 CUSTOM으로 가능한 부분외에 DOCKING 을 사용한 부분에 대한 내용임.
H사 해외프로젝트에 들어오니, 입출력이 가능한 온라인 프로그램에 TOP_OF_PAGE를 달아 달라고 하여, 테스트 해봄.
먼저 오늘 도출한 결과 창의 모습.
오늘 도출한 결과창 - 이벤트는 각각 걸었음
아래는 테스트 프로그램 관련한 결과 창 및 소스.
상단 : TOP_OF_PAGE, 하단 : ALV
상단으로 TOP_OF_PAGE 가 보인다.
요지는 스크린을 두개로 나누어(SPLIT) 상단은 TOP_OF_PAGE 로, 하단은 데이터의 내용을 뿌리는 것으로 사용한다.
아래는 프로그램 소스.
1. Z_ALVTOP_TEST
*&----------------------------------------------------*
*& Report Z_ALVTOP_TEST
*&
*&----------------------------------------------------*
*&
*&----------------------------------------------------*
REPORT Z_ALVTOP_TEST MESSAGE-ID ZTEST .
INCLUDE Z_ALVTOP_TESTTOP.
INCLUDE Z_ALVTOP_TESTO01.
INCLUDE Z_ALVTOP_TESTI01.
INCLUDE Z_ALVTOP_TESTF01.
START-OF-SELECTION.
PERFORM GET_DATA.
END-OF-SELECTION.
IF NOT IT_FLIGHT[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA SELECTED!!!'.
ENDIF.
2. Z_ALVTOP_TESTTOP
*&----------------------------------------------------*
*& Include Z_ALVTOP_TESTTOP
*&----------------------------------------------------*
DATA: IT_FLIGHT TYPE TABLE OF SFLIGHT.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM.
DATA: G_CONTAINER TYPE SCRFNAME VALUE 'CONTROL',
O_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
O_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
O_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
O_PARENT_TOP TYPE REF TO CL_GUI_CONTAINER,
O_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER.
*&----------------------------------------------------*
* CLASS LCL_EVENT_HANDLER DEFINITION
*&----------------------------------------------------*
*
*&----------------------------------------------------*
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
*Event Handler for Top of page
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE
OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "lcl_event_handler DEFINITION
*-----------------------------------------------------*
* CLASS LCL_EVENT_HANDLER IMPLEMENTATION
*-----------------------------------------------------*
*
*-----------------------------------------------------*
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD TOP_OF_PAGE.
* Top-of-page event
PERFORM EVENT_TOP_OF_PAGE USING O_DYNDOC_ID.
ENDMETHOD. "top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
2. Z_ALVTOP_TESTO01
*&---------------------------------------------------*
*& Include Z_ALVTOP_TESTO01
*&---------------------------------------------------*
*----------------------------------------------------*
* MODULE STATUS_0100 OUTPUT
*----------------------------------------------------*
*
*----------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
SET TITLEBAR 'TITLE_0100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
PERFORM CREATE_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
3. Z_ALVTOP_TESTI01
*&---------------------------------------------------*
*& Include Z_ALVTOP_TESTI01
&----------------------------------------------------*
*----------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------*
*
*----------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
4. Z_ALVTOP_TESTF01
*---------------------------------------------------*
*& Include Z_ALVTOP_TESTF01
*---------------------------------------------------*
*---------------------------------------------------*
*& Form CREATE_ALV
*---------------------------------------------------*
* text
*---------------------------------------------------*
FORM CREATE_ALV .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = G_CONTAINER.
* Create TOP-Document
CREATE OBJECT O_DYNDOC_ID
EXPORTING
STYLE = 'ALV_GRID'.
* Create Splitter for custom_container
CREATE OBJECT O_SPLITTER
EXPORTING
PARENT = G_CUSTOM_CONTAINER
ROWS = 2
COLUMNS = 1.
CALL METHOD O_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = O_PARENT_TOP.
CALL METHOD O_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = O_PARENT_GRID.
* Set height for g_parent_html
CALL METHOD O_SPLITTER->SET_ROW_HEIGHT
EXPORTING
ID = 1
HEIGHT = 5.
CREATE OBJECT G_GRID
EXPORTING
I_PARENT = O_PARENT_GRID.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
*Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
IT_OUTTAB = IT_FLIGHT[].
CALL METHOD O_DYNDOC_ID->INITIALIZE_DOCUMENT
EXPORTING
BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
* Processing events
CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = O_DYNDOC_ID.
ENDFORM. "CREATE_ALV
*---------------------------------------------------*
*& Form EVENT_TOP_OF_PAGE
*---------------------------------------------------*
* text
*---------------------------------------------------*
* -->DG_DYNDOC_ID text
*---------------------------------------------------*
FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
DATA : DL_TEXT(255) TYPE C. "Text
CALL METHOD DG_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = 'Flight Details'
SAP_STYLE = CL_DD_AREA=>HEADING
SAP_FONTSIZE = CL_DD_AREA=>LARGE
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CALL METHOD DG_DYNDOC_ID->ADD_GAP
EXPORTING
WIDTH = 200.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* program ID
DL_TEXT = 'Program Name :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
DL_TEXT = SY-REPID.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
CLEAR : DL_TEXT.
* program ID
DL_TEXT = 'User Name :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
DL_TEXT = SY-UNAME.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
PERFORM DISPLAY.
ENDFORM. " EVENT_TOP_OF_PAGE
*---------------------------------------------------*
*& Form DISPLAY
*---------------------------------------------------*
* text
*---------------------------------------------------*
FORM DISPLAY.
* Creating html control
IF O_HTML_CNTRL IS INITIAL.
CREATE OBJECT O_HTML_CNTRL
EXPORTING
PARENT = O_PARENT_TOP.
ENDIF.
CALL METHOD O_DYNDOC_ID->MERGE_DOCUMENT.
O_DYNDOC_ID->HTML_CONTROL = O_HTML_CNTRL.
* Display document
CALL METHOD O_DYNDOC_ID->DISPLAY_DOCUMENT
EXPORTING
REUSE_CONTROL = 'X'
PARENT = O_PARENT_TOP
EXCEPTIONS
HTML_DISPLAY_ERROR = 1.
IF SY-SUBRC NE 0.
MESSAGE I100 WITH 'Error Top-of-page'.
ENDIF.
ENDFORM. " display
*---------------------------------------------------*
*& Form GET_DATA
*---------------------------------------------------*
* text
*---------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------*
FORM GET_DATA .
SELECT * FROM SFLIGHT
UP TO 20 ROWS
INTO TABLE IT_FLIGHT.
ENDFORM. " GET_DATA
[LAYOUT - SCREEN PAINTER]
Click~★ 하면 크게 볼 수 있습니다
Z_ALVTOP_TESTTOP 에서
G_CONTAINER TYPE SCRFNAME VALUE 'CONTROL'
이라고 정의하였으므로 CONTROL 이라는 이름을 사용하였음.
'개발자愛 > SAP' 카테고리의 다른 글
[ABAP-FI] 기초금액 가져오는 펑션 (0) | 2009.12.08 |
---|---|
[ABAP] Error Message 뿌릴때 E 타입으로 보여주기 (0) | 2009.12.08 |
The ABAP program lines are wider than the internal table (0) | 2009.09.16 |
[Tip]Abap Report Source Scan 프로그램 (0) | 2008.12.19 |
알아두면 유용한 SAP T-Code (0) | 2008.12.19 |