SAP ABAP ALV Split을 통한 헤더 텍스트 추가 방법
ALV Grid 화면 출력 시, 화면을 분할하여 헤더텍스트를 추가하는 방법을 공유합니다.
1. 스크린 컨테이너와 객체 컨테이너 설정
2. 화면 분할
3. 행/열에 따른 컨테이너 할당
4. Document 객체 생성 및 할당
5. 텍스트 추가
6. 예시화면
7. 관련 소스코드
DATA: GO_TREE TYPE REF TO LCL_TREE_EVENT_RECEIVER,
GO_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, ” 200 Screen.
GO_CUSTOM_CONTAINER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, ” 300 Screen.
GO_DOCKING_CONTAINER1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
GO_DOCKING_CONTAINER2 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
GO_SPLITTER1 TYPE REF TO CL_GUI_SPLITTER_CONTAINER, ” Main.
GO_SPLITTER2 TYPE REF TO CL_GUI_SPLITTER_CONTAINER, ” 200 Screen.
GO_SPLITTER3 TYPE REF TO CL_GUI_SPLITTER_CONTAINER, ” 300 Screen.
GO_CONTAINER1 TYPE REF TO CL_GUI_CONTAINER, ” Main1.
GO_CONTAINER2 TYPE REF TO CL_GUI_CONTAINER, ” Main2.
GO_CONTAINER3 TYPE REF TO CL_GUI_CONTAINER, ” 200 Screen1 top.
GO_CONTAINER4 TYPE REF TO CL_GUI_CONTAINER, ” 200 Screen1.
GO_CONTAINER5 TYPE REF TO CL_GUI_CONTAINER, ” 200 Screen2 bottom.
GO_CONTAINER6 TYPE REF TO CL_GUI_CONTAINER, ” 200 Screen2.
GO_CONTAINER7 TYPE REF TO CL_GUI_CONTAINER, ” 300 Screen1 top.
GO_CONTAINER8 TYPE REF TO CL_GUI_CONTAINER, ” 300 Screen1.
GO_CONTAINER9 TYPE REF TO CL_GUI_CONTAINER, ” 300 Screen2 bottom.
GO_CONTAINER10 TYPE REF TO CL_GUI_CONTAINER, ” 300 Screen2.
GO_COLUMN_TREE TYPE REF TO CL_GUI_COLUMN_TREE,
GO_GRID1 TYPE REF TO CL_GUI_ALV_GRID, ” Main.
GO_GRID2 TYPE REF TO CL_GUI_ALV_GRID, ” 200 Screen1.
GO_GRID3 TYPE REF TO CL_GUI_ALV_GRID, ” 200 Screen2.
GO_GRID4 TYPE REF TO CL_GUI_ALV_GRID, ” 300 Screen1.
GO_GRID5 TYPE REF TO CL_GUI_ALV_GRID, ” 300 Screen2.
GO_EVENT_RECEIVER1 TYPE REF TO LCL_EVENT_RECEIVER, ” Main.
GO_EVENT_RECEIVER2 TYPE REF TO LCL_EVENT_RECEIVER2, ” 200 Screen AS-IS.
GO_EVENT_RECEIVER3 TYPE REF TO LCL_EVENT_RECEIVER3, ” 200 Screen TO-BE.
GO_EVENT_RECEIVER4 TYPE REF TO LCL_EVENT_RECEIVER4, ” 300 Screen AS-IS.
GO_EVENT_RECEIVER5 TYPE REF TO LCL_EVENT_RECEIVER5, ” 300 Screen TO-BE.
GO_DOCUMENT1 TYPE REF TO CL_DD_DOCUMENT, ” 200 Screen as-is Top_of_page.
GO_DOCUMENT2 TYPE REF TO CL_DD_DOCUMENT, ” 200 Screen to-be Top_of_page.
GO_DOCUMENT3 TYPE REF TO CL_DD_DOCUMENT, ” 300 Screen as-is Top_of_page.
GO_DOCUMENT4 TYPE REF TO CL_DD_DOCUMENT, ” 300 Screen to-be Top_of_page.
GO_HTML_CNTRL1 TYPE REF TO CL_GUI_HTML_VIEWER, ” 200 screen as-is top-of-page.
GO_HTML_CNTRL2 TYPE REF TO CL_GUI_HTML_VIEWER, ” 200 screen to-be top-of-page.
GO_HTML_CNTRL3 TYPE REF TO CL_GUI_HTML_VIEWER, ” 300 screen as-is top-of-page.
GO_HTML_CNTRL4 TYPE REF TO CL_GUI_HTML_VIEWER, ” 300 screen to-be top-of-page.
* 1. Custom Container와 Screen 맵핑.
CREATE OBJECT GO_CUSTOM_CONTAINER1
EXPORTING
CONTAINER_NAME = ‘GC_CONTAINER_0200’.
* 2. 화면 분할.
CREATE OBJECT GO_SPLITTER2
EXPORTING
PARENT = GO_CUSTOM_CONTAINER1
ROWS = 4
* WIDTH = 2000
COLUMNS = 1.
* 1행 1열 top.
CALL METHOD GO_SPLITTER2->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = GO_CONTAINER3.
* 2행 1열 screen.
CALL METHOD GO_SPLITTER2->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = GO_CONTAINER4.
* 3행 1열 top.
CALL METHOD GO_SPLITTER2->GET_CONTAINER
EXPORTING
ROW = 3
COLUMN = 1
RECEIVING
CONTAINER = GO_CONTAINER5.
* 4행 1열 screen.
CALL METHOD GO_SPLITTER2->GET_CONTAINER
EXPORTING
ROW = 4
COLUMN = 1
RECEIVING
CONTAINER = GO_CONTAINER6.
* 3. Header Text 높이 조정.
CALL METHOD GO_SPLITTER2->SET_ROW_HEIGHT
EXPORTING
ID = 1
HEIGHT = 10.
CALL METHOD GO_SPLITTER2->SET_ROW_HEIGHT
EXPORTING
ID = 3
HEIGHT = 10.
* 4. Header Text 선언.
CREATE OBJECT GO_DOCUMENT1
EXPORTING
STYLE = ‘ALV_GRID’.
CREATE OBJECT GO_DOCUMENT2
EXPORTING
STYLE = ‘ALV_GRID’.
CALL METHOD GO_DOCUMENT1->INITIALIZE_DOCUMENT
EXPORTING
BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
CALL METHOD GO_DOCUMENT2->INITIALIZE_DOCUMENT
EXPORTING
BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
* 텍스트 추가
CALL METHOD GO_DOCUMENT1->ADD_TEXT
EXPORTING
TEXT = ‘보정대상 데이터’
SAP_STYLE = CL_DD_AREA=>HEADING
SAP_FONTSIZE = CL_DD_AREA=>MEDIUM
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CALL METHOD GO_DOCUMENT1->MERGE_DOCUMENT.
* Display document
CALL METHOD GO_DOCUMENT1->DISPLAY_DOCUMENT
EXPORTING
REUSE_CONTROL = ‘X’
PARENT = GO_CONTAINER3
EXCEPTIONS
HTML_DISPLAY_ERROR = 1.
CALL METHOD GO_DOCUMENT2->ADD_TEXT
EXPORTING
TEXT = ‘보정완료 데이터’
SAP_STYLE = CL_DD_AREA=>HEADING
SAP_FONTSIZE = CL_DD_AREA=>MEDIUM
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CALL METHOD GO_DOCUMENT2->MERGE_DOCUMENT.
* Display document
CALL METHOD GO_DOCUMENT2->DISPLAY_DOCUMENT
EXPORTING
REUSE_CONTROL = ‘X’
PARENT = GO_CONTAINER5
EXCEPTIONS
HTML_DISPLAY_ERROR = 1.