ABAP 신호등 아이콘
Updated:
1. ALV 생성 화면
Selection Screen
Screen 0100
2. ALV 생성 코드
REPORT PROGRAM
*&---------------------------------------------------------------------*
*& Report Z_ALV_FLIGHT_24
*&---------------------------------------------------------------------*
REPORT ZALV24_01.
INCLUDE ZALV_01_TOP.
INCLUDE ZALV_01_B01.
INCLUDE ZALV_01_I01.
INCLUDE ZALV_01_F01.
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
START-OF-SELECTION.
SELECT *
FROM SFLIGHT
INTO TABLE GT_SFLIGHT
WHERE CARRID IN SO_CAR
AND CONNID IN SO_CON.
* 3. SEATOCC 값에 따라 신호등 아이콘을 넣어주고자 함
* SELECT 이후에 작성되야 함
LOOP AT GT_SFLIGHT INTO GS_SFLIGHT.
IF GS_SFLIGHT-SEATSMAX - GS_SFLIGHT-SEATSOCC < 5.
GS_SFLIGHT-LIGHT = 1.
ELSEIF GS_SFLIGHT-SEATSMAX - GS_SFLIGHT-SEATSOCC < 100.
GS_SFLIGHT-LIGHT = 2.
ELSE.
GS_SFLIGHT-LIGHT = 3.
ENDIF.
MODIFY GT_SFLIGHT FROM GS_SFLIGHT.
ENDLOOP.
End-of-SELECTION.
CALL SCREEN 100.
SCREEN 0100
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE CREATE_ALV.
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
MODULE EXIT AT EXIT-COMMAND.
TOP
*&---------------------------------------------------------------------*
*& Include Z_ALV_FLIGHT_24_TOP
*&---------------------------------------------------------------------*
* 신호등 만들기부터 시작
* 1. 신호등도 넣을 수 았는 새로운 타입 생성
TYPES: BEGIN OF GTY_SFLIGHT.
INCLUDE TYPE SFLIGHT. //SFLIGHT 구조 포함
TYPES: LIGHT TYPE C LENGTH 1. //추가할 COL 항목
TYPES: END OF GTY_SFLIGHT.
* 2. 새로 만든 타입을 참조하여 ITAB 생성 및 기존 GT_SGLIGHT, GS_SFLIGHT 주석처리
*DATA: GS_SFLIGHT TYPE SFLIGHT,
* GT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA: GS_SFLIGHT TYPE GTY_SFLIGHT,
GT_SFLIGHT TYPE TABLE OF GTY_SFLIGHT.
DATA: OK_CODE TYPE SY-UCOMM.
SELECT-OPTIONS: SO_CAR FOR GS_SFLIGHT-CARRID,
SO_CON FOR GS_SFLIGHT-CONNID.
DATA: GO_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GO_ALV TYPE REF TO CL_GUI_ALV_GRID,
GS_LAYOUT TYPE LVC_S_LAYO,
LS_STBL TYPE LVC_S_STBL,
GS_VARIANT TYPE DISVARIANT,
GV_SAVE TYPE C LENGTH 1.
PARAMETERS: pa_vari TYPE disvariant-variant.
PBO
*&---------------------------------------------------------------------*
*& Include Z_ALV_FLIGHT_24_B01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module CREATE_ALV OUTPUT
*&---------------------------------------------------------------------*
MODULE CREATE_ALV OUTPUT.
IF GO_CONT IS INITIAL.
PERFORM SET_OBJECT.
PERFORM SET_LAYOUT.
GS_VARIANT-REPORT = SY-CPROG.
GS_VARIANT-VARIANT = PA_VARI.
GV_SAVE = 'A'.
PERFORM DISPLAY_ALV.
ELSE.
LS_STBL-ROW = 'X'.
LS_STBL-COL = 'X'.
CALL METHOD GO_ALV->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LS_STBL
I_SOFT_REFRESH = 'X'.
ENDIF.
ENDMODULE.
PAI
*&---------------------------------------------------------------------*
*& Include Z_ALV_FLIGHT_24_I01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
MODULE EXIT INPUT.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
PERFORM
*&---------------------------------------------------------------------*
*& Include Z_ALV_FLIGHT_24_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form SET_OBJECT
*&---------------------------------------------------------------------*
FORM SET_OBJECT .
CREATE OBJECT GO_CONT
EXPORTING
CONTAINER_NAME = 'AREA_100'.
CREATE OBJECT GO_ALV
EXPORTING
I_PARENT = GO_CONT.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
FORM DISPLAY_ALV .
CALL METHOD GO_ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'SFLIGHT'
IS_VARIANT = GS_VARIANT
I_SAVE = GV_SAVE
I_DEFAULT = 'X'
IS_LAYOUT = GS_LAYOUT
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = GT_SFLIGHT.
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* OTHERS = 4
.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
FORM SET_LAYOUT .
GS_LAYOUT-GRID_TITLE = 'LIST'(002).
GS_LAYOUT-ZEBRA = 'X'.
* GS_LAYOUT-CWIDTH_OPT = 'X'. // 열 넒이 자동 최적화(HEADER 길이에 맞춰짐)
* GS_LAYOUT-NO_TOOLBAR = 'X'.
* GS_LAYOUT-NO_HEADERS = 'X'.
GS_LAYOUT-TOTALS_BEF = 'X'.
* GS_LAYOUT-EDIT = 'X'.
GS_LAYOUT-SEL_MODE = 'A'.
GS_LAYOUT-EXCP_FNAME = 'LIGHT'. // EXCEPT FIELD NAME: 해당 필드를 신호등으로 표현
// 이 설정 전에 아얘 LIGHT COLUMN 안보인 이유?
// LIGHT의 FIELD TYPE이 숫자가 아니여서
// 위 DISPLAY: I_STRUATURE_NAME 변경은?
// I_STRUCTURE_NAME은 무조건 DB TABLE 이름
// 만약 DB TABLE과 전혀 다른 STRUCTURE를 보이려면?
// FIELD CATALOG를 생성하여 사용
GS_LAYOUT-EXCP_LED = 'X'. // 하나짜리 신호등으로 변경
ENDFORM.