안녕하세요
제가 ALV REUSE GRID DISPLAY 를 사용 하여,
조회를 하게 만들었습니다.
근데 APPLICATION TOOLBAR 에 버튼 하나를 추가 하고 싶습니다.
안되네요....ㅠ.ㅠ
제가 한 방법을 엑셀로 파일 첨부 하였습니다.
어떻게 하면 APPLIATION TOOLBAR 와 FUCTION KEY를 활성화 할 수 있을까요?
친절 한 답변 부탁 합니다.
댓글 2
-
activeman
2009.03.06 06:00
-
activeman
2009.03.07 01:53
오늘 서비스가 너무 좋은 것 같습니다..
샘플로 하나 올려 드리겠습니다......(미천하지만 유용하게 사용하십시요...)
REPORT ZALV_SAMPLE NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID ZPP1.
TYPE-POOLS SLIS.
TABLES: MARA,
MARC,
MAKT,
AFFW,
AFKO,
AFRU,
T100.
* [INTERNAL TABLE]
DATA: BEGIN OF IT_TAB OCCURS 0,
ZSEQ TYPE I, "seq
WERKS LIKE AFFW-WERKS, " 플랜트
MATNR LIKE AFFW-MATNR, " 자재번호
GROES(40), " 자재품명
LGORT LIKE AFFW-LGORT, " 저장위치
CHARG LIKE AFFW-CHARG, " 배치번호
ERFMG LIKE AFFW-ERFMG, " Backlog 수량
MARK,
END OF IT_TAB.
* [ALV를 위한 변수 선언]
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS: C_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
C_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
*----------------------------------------------------------------------*
* SELECTION-SCREEN *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-010.
SELECT-OPTIONS: S_WERKS FOR AFFW-WERKS OBLIGATORY, " Plant
S_MATNR FOR AFFW-MATNR, " 자재번호
S_MTART FOR MARA-MTART, " 상품유형
S_MATKL FOR MARA-MATKL, " 상품범주
S_LGORT FOR AFFW-LGORT, " 저장위치
S_BWART FOR AFFW-BWART. " 이동유형
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-020.
SELECT-OPTIONS: S_PLNBEZ FOR AFKO-PLNBEZ, " 생산품목
S_AUFNR FOR AFFW-AUFNR. " 오더번호
SELECTION-SCREEN END OF BLOCK BLK2.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-030.
PARAMETERS: S_BUDAT LIKE AFFW-BUDAT DEFAULT SY-DATUM. " 기준일자
SELECTION-SCREEN END OF BLOCK BLK3.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM CREATE_DATA_TO_IT_TAB.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM ALV_GRID_FORMAT.
PERFORM ALV_GRID_HEADER.
PERFORM ALV_GRID_EVENT.
PERFORM PRINT_BUILD USING GS_PRINT.
PERFORM ALV_GRID_FIELDCAT.
PERFORM ALV_GRID_SORT.
PERFORM DISPLAY_ALV_GRID_DISPLAY.
*----------------------------------------------------------------------*
* TOP-OF-PAGE *
*----------------------------------------------------------------------*
TOP-OF-PAGE.
PERFORM TOP_OF_PAGE.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
*&---------------------------------------------------------------------*
*& Form USER COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SLIS_EV_PF_STATUS_SET text
* -->P_C_STATUS_SET text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
CLEAR: SY-UCOMM.
CASE P_UCOMM.
WHEN 'STOC'.
ENDCASE.
P_SELFIELD-REFRESH = 'X'.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form PF_STATUS_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PF_STATUS_SET USING P_RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD'.
SET TITLEBAR '1000'.
ENDFORM. "PF_STATUS_SET
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_GRID_DISPLAY.
DATA: LV_REPID TYPE SY-REPID.
LV_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = 'X'
I_CALLBACK_PROGRAM = LV_REPID
IT_EVENTS = GT_EVENTS[]
IT_FIELDCAT = GT_FIELDCAT[]
IS_LAYOUT = GS_LAYOUT
IT_SORT = GT_SORT[]
TABLES
T_OUTTAB = IT_TAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
*& Form READ_MAKTX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_TABI_MATNR text
* <--P_IT_TABI_MAKTX text
*----------------------------------------------------------------------*
FORM READ_MAKTX USING P_MATNR
CHANGING P_MAKTX.
SELECT SINGLE MAKTX
INTO P_MAKTX
FROM MAKT
WHERE MATNR = P_MATNR
AND SPRAS = '3'.
ENDFORM. " READ_MAKTX
*&---------------------------------------------------------------------*
*& Form form_setting
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SLIS_EV_PF_STATUS_SET text
* -->P_C_STATUS_SET text
*----------------------------------------------------------------------*
FORM FORM_SETTING USING P_COM
P_FORM.
DATA: L_EVENT_S TYPE SLIS_ALV_EVENT.
READ TABLE GT_EVENTS WITH KEY NAME = P_COM
INTO L_EVENT_S.
IF SY-SUBRC EQ 0.
MOVE P_FORM TO L_EVENT_S-FORM.
MODIFY GT_EVENTS FROM L_EVENT_S INDEX SY-TABIX.
ENDIF.
ENDFORM. " form_setting
*&---------------------------------------------------------------------*
*& Form PRINT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_PRINT text
*----------------------------------------------------------------------*
FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
* LS_PRINT-PRINT = P_PRINT.
* LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF.
* LS_PRINT-NO_COVERPAGE = P_NOCOVE.
* LS_PRINT-NO_NEW_PAGE = P_NONEWP.
LS_PRINT-NO_PRINT_LISTINFOS = 'X'.
LS_PRINT-NO_CHANGE_PRINT_PARAMS = 'X'.
* LS_PRINT-RESERVE_LINES = P_RESERV.
* LS_PRINT-PRINT = P_PRINT.
ENDFORM. " PRINT_BUILD
*&---------------------------------------------------------------------*
*& Form HEADER_SETTING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_1208 text
* -->P_1209 text
* -->P_1210 text
*----------------------------------------------------------------------*
FORM HEADER_SETTING USING P_TYP P_KEY P_INFO.
DATA: L_LINE_S TYPE SLIS_LISTHEADER.
CLEAR L_LINE_S.
MOVE: P_TYP TO L_LINE_S-TYP,
P_KEY TO L_LINE_S-KEY,
P_INFO TO L_LINE_S-INFO.
APPEND L_LINE_S TO GT_TOP_OF_PAGE.
ENDFORM. " HEADER_SETTING
*&---------------------------------------------------------------------*
*& Form ALV_GRID_FORMAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_FORMAT.
*... Display options
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-NO_COLHEAD = SPACE.
GS_LAYOUT-NO_HOTSPOT = SPACE.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-NO_VLINE = SPACE.
GS_LAYOUT-CELL_MERGE = SPACE.
GS_LAYOUT-NO_MIN_LINESIZE = SPACE.
GS_LAYOUT-MIN_LINESIZE = SPACE.
GS_LAYOUT-MAX_LINESIZE = SPACE.
GS_LAYOUT-NO_ULINE_HS = SPACE.
*... Exceptions
GS_LAYOUT-LIGHTS_FIELDNAME = SPACE.
GS_LAYOUT-LIGHTS_TABNAME = SPACE.
GS_LAYOUT-LIGHTS_ROLLNAME = SPACE.
GS_LAYOUT-LIGHTS_CONDENSE = SPACE.
*... Sums
GS_LAYOUT-NO_SUMCHOICE = SPACE.
GS_LAYOUT-NO_TOTALLINE = SPACE.
GS_LAYOUT-TOTALS_BEFORE_ITEMS = SPACE.
GS_LAYOUT-TOTALS_ONLY = SPACE.
GS_LAYOUT-TOTALS_TEXT = SPACE.
GS_LAYOUT-NO_SUBCHOICE = SPACE.
GS_LAYOUT-NO_SUBTOTALS = SPACE.
GS_LAYOUT-SUBTOTALS_TEXT = SPACE.
GS_LAYOUT-NUMC_SUM = SPACE.
GS_LAYOUT-NO_UNIT_SPLITTING = SPACE.
*... Interaction
GS_LAYOUT-BOX_FIELDNAME = 'MARK'.
GS_LAYOUT-BOX_TABNAME = 'IT_TAB'.
GS_LAYOUT-BOX_ROLLNAME = SPACE.
GS_LAYOUT-EXPAND_FIELDNAME = SPACE.
GS_LAYOUT-HOTSPOT_FIELDNAME = SPACE.
GS_LAYOUT-NO_INPUT = SPACE.
GS_LAYOUT-F2CODE = SPACE.
GS_LAYOUT-CONFIRMATION_PROMPT = SPACE.
GS_LAYOUT-KEY_HOTSPOT = SPACE.
GS_LAYOUT-FLEXIBLE_KEY = SPACE.
GS_LAYOUT-REPREP = SPACE.
GS_LAYOUT-GROUP_BUTTONS = SPACE.
GS_LAYOUT-NO_KEYFIX = SPACE.
GS_LAYOUT-GET_SELINFOS = SPACE.
GS_LAYOUT-GROUP_CHANGE_EDIT = SPACE.
GS_LAYOUT-NO_SCROLLING = SPACE.
GS_LAYOUT-EXPAND_ALL = SPACE.
GS_LAYOUT-NO_AUTHOR = SPACE.
*... Detailed screen
GS_LAYOUT-DETAIL_POPUP = SPACE.
GS_LAYOUT-DETAIL_INITIAL_LINES = SPACE.
GS_LAYOUT-DETAIL_TITLEBAR = SPACE.
*... PF-status
GS_LAYOUT-DEF_STATUS = SPACE.
*... Display variants
GS_LAYOUT-HEADER_TEXT = SPACE.
GS_LAYOUT-ITEM_TEXT = SPACE.
GS_LAYOUT-DEFAULT_ITEM = SPACE.
*... colour
GS_LAYOUT-INFO_FIELDNAME = SPACE.
GS_LAYOUT-COLTAB_FIELDNAME = SPACE.
*... others
GS_LAYOUT-LIST_APPEND = SPACE.
ENDFORM. " ALV_GRID_FORMAT
*&---------------------------------------------------------------------*
*& Form ALV_GRID_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = GT_EVENTS.
PERFORM FORM_SETTING USING:
SLIS_EV_PF_STATUS_SET C_STATUS_SET,
SLIS_EV_USER_COMMAND C_USER_COMMAND,
SLIS_EV_TOP_OF_PAGE C_TOP_OF_PAGE.
ENDFORM. " ALV_GRID_EVENT
*&---------------------------------------------------------------------*
*& Form ALV_GRID_HEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_HEADER.
DATA : LV_WERKS(30),
LV_DATE(40),
LV_TIME(20).
CLEAR: LV_WERKS, LV_DATE, LV_TIME.
IF NOT ( S_WERKS-HIGH = SPACE ).
CONCATENATE S_WERKS-LOW '~' S_WERKS-HIGH INTO LV_WERKS.
ELSE.
LV_WERKS = S_WERKS-LOW.
ENDIF.
WRITE SY-DATUM TO LV_DATE USING EDIT MASK '____/__/__'.
WRITE SY-UZEIT TO LV_TIME USING EDIT MASK '__:__:__'.
CONCATENATE LV_DATE ',' LV_TIME INTO LV_DATE.
PERFORM HEADER_SETTING USING:
'H' ' ' '[ TEST Program ]',
'S' '플 랜 트 :' LV_WERKS,
'S' '기준일자 :' S_BUDAT,
'S' '사 용 자 :' SY-UNAME,
'S' '출력일자 :' LV_DATE.
ENDFORM. " ALV_GRID_HEADER
*&---------------------------------------------------------------------*
*& Form ALV_GRID_FIELDCAT
*&---------------------------------------------------------------------*
* text ==> ABAP DICTIONARY 에 STRUCTUR 생성시켰을때 사용
* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_FIELDCAT.
CLEAR: GT_FIELDCAT[].
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'IT_TAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = GT_FIELDCAT[].
DELETE GT_FIELDCAT WHERE FIELDNAME = 'MARK'.
FIELD-SYMBOLS: <FS> TYPE SLIS_FIELDCAT_ALV.
LOOP AT GT_FIELDCAT ASSIGNING <FS>.
CASE <FS>-FIELDNAME.
WHEN 'LIGHT'.
<FS>-REPTEXT_DDIC = '@EB@'.
<FS>-SELTEXT_L = '@EB@'.
<FS>-SELTEXT_M = '@EB@'.
<FS>-SELTEXT_S = '@EB@'.
<FS>-DDICTXT = 'M'.
WHEN 'MATUP'.
<FS>-KEY = 'X'.
<FS>-HOTSPOT = 'X'.
WHEN 'MAKUP'. "자재내역
<FS>-KEY = 'X'.
WHEN 'MATNR'.
<FS>-KEY = 'X'.
<FS>-HOTSPOT = 'X'.
WHEN 'MAKTX'. "자재내역
<FS>-KEY = 'X'.
ENDCASE.
<FS>-NO_ZERO = 'X'.
ENDLOOP.
ENDFORM. " ALV_GRID_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FIELDCAT_FOR_COLOR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FIELDCAT_FOR_COLOR.
DATA: LT_COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.
CLEAR: LT_COLOR, LT_COLOR[].
* LOOP AT IT_TAB WHERE FMNGA < 0.
* LT_COLOR-COLOR-COL = 6.
* APPEND LT_COLOR.
*
* IT_TAB-COLOR[] = LT_COLOR[].
* MODIFY IT_TAB.
* ENDLOOP.
ENDFORM. " FIELDCAT_FOR_COLOR
*&---------------------------------------------------------------------*
*& Form ALV_GRID_SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_SORT.
PERFORM FIELD_SORT USING GT_SORT[].
ENDFORM. " ALV_GRID_SORT
*&---------------------------------------------------------------------*
*& Form FIELD_SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_SORT[] text
*----------------------------------------------------------------------*
FORM FIELD_SORT USING LT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'ZSEQ'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = ''.
APPEND LS_SORT TO LT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'WERKS'.
LS_SORT-SPOS = 2.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = ''.
APPEND LS_SORT TO LT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'MATNR'.
LS_SORT-SPOS = 3.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = ''.
APPEND LS_SORT TO LT_SORT.
ENDFORM. " FIELD_SORT
*&---------------------------------------------------------------------*
*& Form CREATE_DATA_TO_IT_TAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_DATA_TO_IT_TAB .
* [ 데이터 가공 부분 ]
ENDFORM. " CREATE_DATA_TO_IT_TAB
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = GT_TOP_OF_PAGE.
ENDFORM. " TOP_OF_PAGE
첨부파일에 보면 constants: g_status type slis_formname value 'STATUS'로 정의 하셨습니다..
그리고 event 등록을 하셨을 겁니다.( 이벤트 등록하는 부분이 있는지 확인해 보시구요..)
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = GT_EVENTS.
PERFORM FORM_SETTING USING:
SLIS_EV_PF_STATUS_SET g_STATUS,
SLIS_EV_USER_COMMAND g_USER_COMMAND,
SLIS_EV_TOP_OF_PAGE g_TOP_OF_PAGE.
그리고 난뒤에 이부분이 실행될겁니다.
form set_status. ==> 이부분을 FORM STATUS. 로 바꾸세요. G_STATUS에서 선언한 값과 이름이 같아야 합니다.
SET PF-STATUS 'STATUS'
ENDFORM
그리고 마지막으로
REUSE_ALV_GRID_DISPLAY에서
IT_EVENTS = GT_EVENTS 가 주석 처리되어 있는데 이부분의 주석을 없애시면 됩니다.
즐밥하세요..