ALV 를 DISPLAY 하는 화면에 앞 입력 조건 값을 DISPLAY 해 달라는 요청이 가끔씩 들어오곤 한다.
그럴 때 사용 가능한 예제….
SELECTION SCREEN을 디자인할 때
SELECTION-SCREEN BEGIN OF SCREEN 1100 AS SUBSCREEN.
위에 구문 처럼 SUBSCREEN을 지정하고 DISPLAY할 화면에 서브 스크린 을 지정하여 주면 된다.
화면 100 번 디자인( 아랫 부분은 ALV DISPLAY 영역 윗부분은 서브 스크린)
Program( 굵게 표시된 부분이 subscreen 을 구성하는 부분이다.
*&---------------------------------------------------------------------*
*& Report YBKTEMP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YBKTEMP.
TABLES : MAKT.
DATA : OK_CODE TYPE SY-UCOMM.
DATA : GT_MAKT LIKE MAKT OCCURS 0 WITH HEADER LINE.
DATA : GT_FCODE TYPE TABLE OF FCODE,
GS_FCODE TYPE FCODE.
*-- ALV Custom Container Name
CONSTANTS :
CO_CUSTOM_CONTAINER_100 TYPE CHAR20 VALUE 'CUSTOM_AREA_100'.
SELECTION-SCREEN BEGIN OF SCREEN 1100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_MATNR FOR MAKT-MATNR.
SELECTION-SCREEN END OF BLOCK B01.
SELECTION-SCREEN END OF SCREEN 1100.
*--------------------------------------------------------------------*
* CLASS Define.
*--------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER_100 DEFINITION DEFERRED.
DATA : G_EVENT_RECEIVER_100 TYPE REF TO LCL_EVENT_RECEIVER_100.
*-- ALV Define
DATA :
G_CUSTOM_CONTAINER_100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_GRID_100 TYPE REF TO CL_GUI_ALV_GRID,
GS_LAYOUT_100 TYPE LVC_S_LAYO,
G_VARIANT_100 TYPE DISVARIANT,
GT_FIELDCAT_100 TYPE LVC_T_FCAT,
GS_FIELDCAT TYPE LVC_S_FCAT,
GT_SORT_100 TYPE LVC_T_SORT,
GT_TOOLBAR_EXCLUDING_100 TYPE UI_FUNCTIONS.
DATA : GS_STBL TYPE LVC_S_STBL. "Refresh 시 라인및 컬럼 고정
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER_100 DEFINITION.
PUBLIC SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER_100 IMPLEMENTATION.
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*--------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT
*--------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM MODIFY_SCREEN. "실행버튼을 누른 후 조회 조건을 비활성
START-OF-SELECTION.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Form MODIFY_SCREEN
*&---------------------------------------------------------------------*
FORM MODIFY_SCREEN .
IF OK_CODE EQ 'EXECUTE'.
LOOP AT SCREEN.
IF SCREEN-NAME(7) EQ 'S_MATNR'.
SCREEN-INPUT = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " MODIFY_SCREEN
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET TITLEBAR 'T100'.
CLEAR : GT_FCODE, GT_FCODE[].
IF OK_CODE EQ 'EXECUTE'.
CLEAR : GS_FCODE.
GS_FCODE = 'EXECUTE'.
APPEND GS_FCODE TO GT_FCODE.
ENDIF.
SET PF-STATUS '100' EXCLUDING GT_FCODE. "실행 한 후 실행 버튼을 제거
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module INITIAL_CONTAINER_100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE INITIAL_CONTAINER_100 OUTPUT.
IF GT_MAKT[] IS NOT INITIAL.
IF G_CUSTOM_CONTAINER_100 IS INITIAL.
*-- Create Object Custom Container
CREATE OBJECT G_CUSTOM_CONTAINER_100
EXPORTING
CONTAINER_NAME = CO_CUSTOM_CONTAINER_100.
*-- Create Object GRID
CREATE OBJECT G_GRID_100
EXPORTING
I_PARENT = G_CUSTOM_CONTAINER_100.
PERFORM SET_FIELD_CAT_100.
PERFORM SET_LAYOUT_100.
PERFORM SET_TOOLBAR_100.
PERFORM SET_METHOD_100.
G_VARIANT_100 = SY-REPID.
"ALV Grid를 출력한다.
CALL METHOD G_GRID_100->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = G_VARIANT_100
IS_LAYOUT = GS_LAYOUT_100
IT_TOOLBAR_EXCLUDING = GT_TOOLBAR_EXCLUDING_100
I_SAVE = 'A'
I_DEFAULT = 'X'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT_100[]
IT_OUTTAB = GT_MAKT[]
IT_SORT = GT_SORT_100[].
ELSE.
CALL METHOD G_GRID_100->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = GS_STBL.
ENDIF.
ENDIF.
ENDMODULE. " INITIAL_CONTAINER_100 OUTPUT
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE EXIT INPUT.
CASE OK_CODE.
WHEN 'BACK'.
CLEAR : OK_CODE.
LEAVE TO SCREEN 0.
WHEN 'EXIT' OR 'CANC'.
CLEAR : OK_CODE.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " EXIT INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXECUTE'.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE GT_MAKT
FROM MAKT
WHERE MATNR IN S_MATNR
AND SPRAS EQ SY-LANGU.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form SET_FIELD_CAT_100
*&---------------------------------------------------------------------*
FORM SET_FIELD_CAT_100.
*-- Call funtion module to build the field catalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'MAKT'
CHANGING
CT_FIELDCAT = GT_FIELDCAT_100
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DELETE GT_FIELDCAT_100 WHERE FIELDNAME EQ TEXT-F14.
LOOP AT GT_FIELDCAT_100 INTO GS_FIELDCAT.
CLEAR : GS_FIELDCAT-COL_POS,
GS_FIELDCAT-KEY.
MODIFY GT_FIELDCAT_100 FROM GS_FIELDCAT.
ENDLOOP.
ENDFORM. " SET_FIELD_CAT_100
*&--------------------------------------------------------------------*
*& Form SET_LAYOUT_100
*&--------------------------------------------------------------------*
FORM SET_LAYOUT_100.
*-- Layout Setting
GS_LAYOUT_100-ZEBRA = 'X'.
GS_LAYOUT_100-NO_ROWINS = 'X'.
GS_LAYOUT_100-CWIDTH_OPT = 'X'. " Column Width 최적화 사용여부
GS_LAYOUT_100-NO_TOTLINE = SPACE.
GS_LAYOUT_100-SEL_MODE = 'D'. " B-single C-multi D-cell A-rowcol
ENDFORM. " SET_LAYOUT_100
*&--------------------------------------------------------------------*
*& Form SET_TOOLBAR_100
*&--------------------------------------------------------------------*
FORM SET_TOOLBAR_100.
CLEAR : GT_TOOLBAR_EXCLUDING_100, GT_TOOLBAR_EXCLUDING_100[].
*-- gt_toolbar_excluding
"Tollbar에서 제거할 버튼지정
DEFINE SET_TOOLBAR_100.
APPEND &1 TO GT_TOOLBAR_EXCLUDING_100.
END-OF-DEFINITION.
SET_TOOLBAR_100 :
CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_COPY,
CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_CUT,
CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE,
CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW,
CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
ENDFORM. " SET_TOOLBAR_100
*&--------------------------------------------------------------------*
*& Form SET_METHOD_100
*&--------------------------------------------------------------------*
FORM SET_METHOD_100.
CREATE OBJECT G_EVENT_RECEIVER_100.
ENDFORM. " SET_METHOD_100
화면 100 번
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN SCR INCLUDING SY-CPROG '1100'.
MODULE STATUS_0100.
MODULE INITIAL_CONTAINER_100.
PROCESS AFTER INPUT.
CALL SUBSCREEN SCR.
MODULE EXIT AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
SCR | Subsc |
CUSTOM_AREA_100 | Actrl |
OK_CODE | OK |
'SAP > ABAP' 카테고리의 다른 글
Useful ABAP Package (0) | 2015.11.18 |
---|---|
스크린에서 버튼을 tree 처럼 만들기 (0) | 2014.08.26 |
SMW0 (0) | 2014.08.25 |
= '' 와 = ' '가 같다? (0) | 2010.07.19 |
message 띄우기.. (0) | 2010.07.19 |