모듈 풀(온라인) 프로그램은 개발자가 만든 레이아웃(스크린페인터) 활용
1. 프로그램 생성
*&---------------------------------------------------------------------*
*& 모듈풀 ZTEST_ONLINE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
INCLUDE ZTEST_ONLINE_TOP . " global Data
INCLUDE ZTEST_ONLINE_O01 . " PBO-Modules
INCLUDE ZTEST_ONLINE_I01 . " PAI-Modules
INCLUDE ZTEST_ONLINE_F01 . " FORM-Routines
2. TOP에 필드 카탈로그에서 필요한 구조 선언
DATA : G_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : G_GRID1 TYPE REF TO cl_gui_alv_grid.
DATA : gt_fieldcat TYPE lvc_t_fcat.
DATA : gs_fieldcat TYPE lvc_s_fcat.
DATA : gs_layout type lvc_s_layo.
3. 스크린 0100 SET
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE INIT_DATA_0100.
MODULE GRID1_DATA.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
PBO: 액션 발생 전 실행할 이벤트
PAI : 액션 발생 후 실행할 이벤트
4. 스크린페인터 설정
조회기간 설정
GRID가 나올 영역은 아래와 같이 처리
이름은 TOP에서 정의했던 GRID1으로 변경
5. GRID1_DATA 모듈 설정
MODULE GRID1_DATA OUTPUT.
IF G_GRID1 IS INITIAL.
*인스턴스 생성
PERFORM CREATE_OBJECT.
*레이아웃 세팅
PERFORM SET_LAYOUT.
*필드카탈로그 생성
PERFORM SET_FIELDCATALOG.
IF G_REFLG IS INITIAL.
PERFORM GET_DATA_0100.
G_REFLG = 'X'.
ENDIF.
*ALV 호출
PERFORM DISPLAY_ALV.
ELSE.
*DB 호출
PERFORM GET_DATA_0100.
PERFORM REFRESH_DATA.
ENDIF.
ENDMODULE. " GRID1_DATA OUTPUT
FORM CREATE_OBJECT .
CREATE OBJECT G_CUSTOM_CONTAINER1
EXPORTING
container_name = g_ctrl1.
CREATE OBJECT G_GRID1
EXPORTING
i_parent = G_CUSTOM_CONTAINER1.
ENDFORM. " CREATE_OBJECT
FORM SET_LAYOUT .
CLEAR: GS_LAYOUT.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-CWIDTH_OPT = 'A'.
GS_LAYOUT-SEL_MODE = 'D'.
ENDFORM. " SET_LAYOUT
FORM SET_FIELDCATALOG .
CLEAR : gs_fieldcat.
CLEAR : gT_fieldcat.
GS_FIELDCAT-FIELDNAME = 'TYPE_CD'.
GS_FIELDCAT-COLTEXT = '공통코드 구분'.
GS_FIELDCAT-KEY = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
GS_FIELDCAT-FIELDNAME = 'COMMON_CD'.
GS_FIELDCAT-COLTEXT = '공통코드'.
GS_FIELDCAT-KEY = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
GS_FIELDCAT-FIELDNAME = 'KOR_DS'.
GS_FIELDCAT-COLTEXT = '한글명'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
GS_FIELDCAT-FIELDNAME = 'KOR_SH_DS'.
GS_FIELDCAT-COLTEXT = '한글명칭'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
GS_FIELDCAT-FIELDNAME = 'USE_YN'.
GS_FIELDCAT-COLTEXT = '사용여부(사용:X)'.
GS_FIELDCAT-checkbox = 'X'.
* GS_FIELDCAT-EDIT = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
GS_FIELDCAT-FIELDNAME = 'ZCRDAT'.
GS_FIELDCAT-COLTEXT = '생성일'.
APPEND gs_fieldcat TO gt_fieldcat.
ENDFORM. " SET_FIELDCATALOG
트랜잭션 실행결과
728x90
'IT 관련 > ABAP' 카테고리의 다른 글
[ABAP] 문자열 치환 (0) | 2024.02.06 |
---|