ITPub博客

首页 > 应用开发 > IT综合 > 一个显示图标的ABAP例子

一个显示图标的ABAP例子

原创 IT综合 作者:tolyhuang 时间:2009-05-26 16:25:48 0 删除 编辑

[@more@]*&---------------------------------------------------------------------*
*& Report BCALV_DEMO_TOOLTIPS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT BCALV_DEMO_TOOLTIPS NO STANDARD PAGE HEADING.

*-----------------------------------------------------------------------
*... This report demonstrates tooltips in ALV
* For color encoding, two options exist:
* - a length 1 encoding ranging from 0 to 7 corresponding to the ABAP colors
* - a length 3 encoding like in the ALV fieldcatalog for colors (parameter emphasize):
* code xyz corresponds to
* x: ABAP color number (like length 1 encoding)
* y: intensified on - 1 - intensified off - 0 -
* z: inverse on - 1 - inverse off - 0 -
*
*
* - cl_salv_table (Fullscreen Grid, Fullscreen List, Grid)
*-----------------------------------------------------------------------

TYPE-POOLS: COL,
ICON,
SYM.

TYPES: BEGIN OF G_TYPE_S_TEST,
AMOUNT TYPE I,
REPID TYPE SYREPID,
DISPLAY TYPE I,
DYNAMIC TYPE SAP_BOOL,
END OF G_TYPE_S_TEST.

CONSTANTS: GC_TRUE TYPE SAP_BOOL VALUE 'X',

BEGIN OF GC_S_DISPLAY,
LIST TYPE I VALUE 1,
FULLSCREEN TYPE I VALUE 2,
GRID TYPE I VALUE 3,
END OF GC_S_DISPLAY.

DATA: GS_TEST TYPE G_TYPE_S_TEST.

TYPES: BEGIN OF GS_OUTTAB.
TYPES: LIGHTS TYPE CHAR1,
COLOR TYPE I,
TABCOL TYPE LVC_T_SCOL,
ID TYPE CHAR25,
NAME TYPE ICON-NAME,
SYMBOL TYPE ICON-ID,
END OF GS_OUTTAB.
DATA: GT_OUTTAB TYPE STANDARD TABLE OF GS_OUTTAB.
* ... and a model class object
DATA: GR_GRID TYPE REF TO CL_GUI_ALV_GRID.
* if you want to display the data table on your own Dynpro, you also need a container
DATA: GR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GS_LAYOUT TYPE LVC_S_LAYO,
GT_FIELDCAT TYPE LVC_T_FCAT.

DATA: G_OKCODE TYPE SYUCOMM.

DATA: GT_EXC TYPE TABLE OF ALV_S_QINF.

DATA: TEXT TYPE STRING.

TEXT = TEXT-B01.

*----------------------------------------------------------------------*
* SELECTION-SCREEN - for demonstration purposes only *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK GEN WITH FRAME.
PARAMETERS:
P_AMOUNT TYPE I DEFAULT 20.
SELECTION-SCREEN END OF BLOCK GEN.

SELECTION-SCREEN BEGIN OF BLOCK DSP WITH FRAME.
PARAMETERS:
P_FULL RADIOBUTTON GROUP DSP,
P_LIST RADIOBUTTON GROUP DSP,
P_GRID RADIOBUTTON GROUP DSP.
SELECTION-SCREEN END OF BLOCK DSP.

*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
GS_TEST-AMOUNT = P_AMOUNT.
GS_TEST-REPID = SY-REPID.
CASE GC_TRUE.
WHEN P_LIST.
GS_TEST-DISPLAY = GC_S_DISPLAY-LIST.
WHEN P_FULL.
GS_TEST-DISPLAY = GC_S_DISPLAY-FULLSCREEN.
WHEN P_GRID.
GS_TEST-DISPLAY = GC_S_DISPLAY-GRID.
ENDCASE.

*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.

PERFORM SELECT_DATA.

CASE GS_TEST-DISPLAY.
WHEN GC_S_DISPLAY-FULLSCREEN.
PERFORM DISPLAY_FULLSCREEN.

WHEN GC_S_DISPLAY-GRID.
PERFORM DISPLAY_GRID.

WHEN GC_S_DISPLAY-LIST.
PERFORM DISPLAY_LIST.
ENDCASE.

*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* §2 to display the data, you first have to select it in some table
*----------------------------------------------------------------------*
FORM SELECT_DATA.

* select icons
SELECT * FROM ICON INTO CORRESPONDING FIELDS OF TABLE GT_OUTTAB
UP TO GS_TEST-AMOUNT ROWS.

ENDFORM. " select_data

*&---------------------------------------------------------------------*
*& Form display_fullscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_FULLSCREEN .

DATA: LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
LS_FCAT TYPE SLIS_FIELDCAT_ALV.

LS_LAYOUT-LIGHTS_TABNAME = '1'.
LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
LS_LAYOUT-COLTAB_FIELDNAME = 'TABCOL'.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'LIGHTS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL4.
LS_FCAT-SELTEXT_M = TEXT-HL4.
LS_FCAT-SELTEXT_S = TEXT-HL4.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'COLOR'.
LS_FCAT-INTTYPE = 'I'.
LS_FCAT-SELTEXT_L = TEXT-HL3.
LS_FCAT-SELTEXT_M = TEXT-HL3.
LS_FCAT-SELTEXT_S = TEXT-HL3.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'ID'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL1.
LS_FCAT-SELTEXT_M = TEXT-HL1.
LS_FCAT-SELTEXT_S = TEXT-HL1.
LS_FCAT-ICON = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'SYMBOL'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL2.
LS_FCAT-SELTEXT_M = TEXT-HL2.
LS_FCAT-SELTEXT_S = TEXT-HL2.
LS_FCAT-SYMBOL = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'NAME'.
LS_FCAT-TECH = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

PERFORM SELECT_DATA.

PERFORM SET_TOOLTIPS.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO = GT_EXC
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = GT_OUTTAB
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_fullscreen

*&---------------------------------------------------------------------*
*& Form display_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_LIST .
DATA: LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
LS_FCAT TYPE SLIS_FIELDCAT_ALV.

LS_LAYOUT-LIGHTS_TABNAME = '1'.
LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
LS_LAYOUT-COLTAB_FIELDNAME = 'TABCOL'.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'LIGHTS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL4.
LS_FCAT-SELTEXT_M = TEXT-HL4.
LS_FCAT-SELTEXT_S = TEXT-HL4.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'COLOR'.
LS_FCAT-INTTYPE = 'I'.
LS_FCAT-SELTEXT_L = TEXT-HL3.
LS_FCAT-SELTEXT_M = TEXT-HL3.
LS_FCAT-SELTEXT_S = TEXT-HL3.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'ID'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL1.
LS_FCAT-SELTEXT_M = TEXT-HL1.
LS_FCAT-SELTEXT_S = TEXT-HL1.
LS_FCAT-ICON = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'SYMBOL'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SELTEXT_L = TEXT-HL2.
LS_FCAT-SELTEXT_M = TEXT-HL2.
LS_FCAT-SELTEXT_S = TEXT-HL2.
LS_FCAT-SYMBOL = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'NAME'.
LS_FCAT-TECH = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

PERFORM SELECT_DATA.

PERFORM SET_TOOLTIPS.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO = GT_EXC
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = GT_OUTTAB
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_list

*&--------------------------------------------------------------------*
*& Form display_grid
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_GRID.

CALL SCREEN 100.

ENDFORM. "display_grid

*&---------------------------------------------------------------------*
*& Module d0100_pbo OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE D0100_PBO OUTPUT.
PERFORM D0100_PBO.
ENDMODULE. " d0100_pbo OUTPUT

*&---------------------------------------------------------------------*
*& Module d0100_pai INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE D0100_PAI INPUT.
PERFORM D0100_PAI.
ENDMODULE. " d0100_pai INPUT

*&---------------------------------------------------------------------*
*& Form d0100_pbo
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM D0100_PBO .

SET PF-STATUS 'D0100'.

IF GR_CONTAINER IS NOT BOUND.
*§3a for displaying the data in your own Dynpro, create a container ...
CREATE OBJECT GR_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT GR_GRID
EXPORTING I_PARENT = GR_CONTAINER.

DATA: LS_LAYOUT TYPE LVC_S_LAYO,
LT_FCAT TYPE LVC_T_FCAT,
LS_FCAT TYPE LVC_S_FCAT.

LS_LAYOUT-EXCP_FNAME = 'LIGHTS'.
LS_LAYOUT-CTAB_FNAME = 'TABCOL'.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'LIGHTS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SCRTEXT_L = TEXT-HL4.
LS_FCAT-SCRTEXT_M = TEXT-HL4.
LS_FCAT-SCRTEXT_S = TEXT-HL4.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'COLOR'.
LS_FCAT-INTTYPE = 'I'.
LS_FCAT-SCRTEXT_L = TEXT-HL3.
LS_FCAT-SCRTEXT_M = TEXT-HL3.
LS_FCAT-SCRTEXT_S = TEXT-HL3.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'ID'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SCRTEXT_L = TEXT-HL1.
LS_FCAT-SCRTEXT_M = TEXT-HL1.
LS_FCAT-SCRTEXT_S = TEXT-HL1.
LS_FCAT-ICON = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'SYMBOL'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-SCRTEXT_L = TEXT-HL2.
LS_FCAT-SCRTEXT_M = TEXT-HL2.
LS_FCAT-SCRTEXT_S = TEXT-HL2.
LS_FCAT-SYMBOL = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'NAME'.
LS_FCAT-TECH = ABAP_TRUE.

APPEND LS_FCAT TO LT_FCAT.

PERFORM SELECT_DATA.

* perform set_tooltips.

DATA: LT_TOOLTIPS TYPE LVC_T_QINF,
LT_TOOLB TYPE UI_FUNCTIONS,
LS_TOOLB TYPE UI_FUNC.

LS_TOOLB = CL_GUI_ALV_GRID=>MC_FC_CALL_CRBATCH.
APPEND LS_TOOLB TO LT_TOOLB.

LT_TOOLTIPS = GT_EXC.


CALL METHOD GR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_EXCEPT_QINFO = LT_TOOLTIPS
IT_TOOLBAR_EXCLUDING = LT_TOOLB
CHANGING
IT_FIELDCATALOG = LT_FCAT
IT_OUTTAB = GT_OUTTAB.

ENDIF.

ENDFORM. " d0100_pbo

*&---------------------------------------------------------------------*
*& Form d0100_pai
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM D0100_PAI .

CASE G_OKCODE.
WHEN 'BACK'.
PERFORM SET_TOOLTIPS.
* CALL METHOD gr_grid->refresh_table_display.
DATA LS_STBL TYPE LVC_S_STBL.
LS_STBL-ROW = 'X'.
CALL METHOD GR_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LS_STBL.
WHEN 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.

ENDFORM. " d0100_pai

*&--------------------------------------------------------------------*
*& Form show_salv_function
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM SHOW_SALV_FUNCTION USING VALUE(I_FUNCTION) TYPE SALV_DE_FUNCTION.

CASE I_FUNCTION.
WHEN 'TEST'.


ENDCASE.

ENDFORM. " show_salv_function

*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY .


PERFORM SET_TOOLTIPS.

ENDFORM. " display
*&---------------------------------------------------------------------*
*& Form set_tooltips
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_TOOLTIPS .
DATA: LS_SYMBOL TYPE ICON,
LT_SYMBOL TYPE STANDARD TABLE OF ICON,
LS_EXC TYPE ALV_S_QINF.

DEFINE MAC_GET_SYMBOL.
LS_SYMBOL-ID = &2.
LS_SYMBOL-NAME = &1.
APPEND LS_SYMBOL TO LT_SYMBOL.
END-OF-DEFINITION.

MAC_GET_SYMBOL SYM_SPACE ' ' ." SPACE
MAC_GET_SYMBOL SYM_PLUS_BOX '!' ." box with plus inside
MAC_GET_SYMBOL SYM_MINUS_BOX '"' ." box with minus inside
MAC_GET_SYMBOL SYM_PLUS_CIRCLE '#' ." circle with plus inside
MAC_GET_SYMBOL SYM_MINUS_CIRCLE '$' ." circle with minus inside
MAC_GET_SYMBOL SYM_FILLED_SQUARE '%' ." filled square
MAC_GET_SYMBOL SYM_HALF_FILLED_SQUARE '&' ." half-filled square
MAC_GET_SYMBOL SYM_SQUARE '''' ." empty square
MAC_GET_SYMBOL SYM_FILLED_CIRCLE '(' ." filled circle
MAC_GET_SYMBOL SYM_HALF_FILLED_CIRCLE ')' ." half-filled circle
MAC_GET_SYMBOL SYM_CIRCLE '*' ." empty circle
MAC_GET_SYMBOL SYM_FILLED_DIAMOND '+' ." filled diamond
MAC_GET_SYMBOL SYM_DIAMOND ',' ." empty diamond
MAC_GET_SYMBOL SYM_BOLD_X '.' ." diagonal cross (cancel)
MAC_GET_SYMBOL SYM_NOTE '/ '." word balloon, note
MAC_GET_SYMBOL SYM_DOCUMENT '0' ." document
MAC_GET_SYMBOL SYM_CHECKED_DOCUMENT '1' ." document with checkmark
MAC_GET_SYMBOL SYM_DOCUMENTS '2 '." double documents
MAC_GET_SYMBOL SYM_FOLDER '3 '." folder
MAC_GET_SYMBOL SYM_PLUS_FOLDER '4 '." folder with plus inside
MAC_GET_SYMBOL SYM_MINUS_FOLDER '5 '." folder with minus inside
MAC_GET_SYMBOL SYM_OPEN_FOLDER '6 '." open folder
MAC_GET_SYMBOL SYM_BOLD_MINUS '7' ." bold minus sign
MAC_GET_SYMBOL SYM_BOLD_PLUS '8' ." bold plus sign
MAC_GET_SYMBOL SYM_CHECKBOX '9 '." selected checkbox
MAC_GET_SYMBOL SYM_RADIOBUTTON ': '." selected radiobutton
MAC_GET_SYMBOL SYM_LEFT_TRIANGLE ';' ." triangle pointing left
MAC_GET_SYMBOL SYM_RIGHT_TRIANGLE '<' ." triangle pointing right
MAC_GET_SYMBOL SYM_UP_TRIANGLE '=' ." triangle pointing up
MAC_GET_SYMBOL SYM_DOWN_TRIANGLE '>' ." triangle pointing down
MAC_GET_SYMBOL SYM_LEFT_HAND '? '." hand pointing left
MAC_GET_SYMBOL SYM_LEFT_ARROW 'A' ." left arrow
MAC_GET_SYMBOL SYM_RIGHT_ARROW 'B' ." right arrow
MAC_GET_SYMBOL SYM_UP_ARROW 'C' ." up arrow
MAC_GET_SYMBOL SYM_DOWN_ARROW 'D' ." down arrow
MAC_GET_SYMBOL SYM_CHECK_MARK 'E' ." check mark
MAC_GET_SYMBOL SYM_PENCIL 'F' ." pencil
MAC_GET_SYMBOL SYM_GLASSES 'G '." glasses
MAC_GET_SYMBOL SYM_LOCKED 'H' ." closed padlock
MAC_GET_SYMBOL SYM_UNLOCKED 'I' ." open padlock
MAC_GET_SYMBOL SYM_PHONE 'J '." telephone
MAC_GET_SYMBOL SYM_PRINTER 'K '." printer
MAC_GET_SYMBOL SYM_FAX 'L '." fax machine
MAC_GET_SYMBOL SYM_ASTERISK 'M' ." asterisk
MAC_GET_SYMBOL SYM_RIGHT_HAND 'N '." hand pointing right
MAC_GET_SYMBOL SYM_SORTED_UP 'O '." sorted ascending
MAC_GET_SYMBOL SYM_SORTED_DOWN 'P '." sorted descending
MAC_GET_SYMBOL SYM_CUMULATED 'Q '." cumulated
MAC_GET_SYMBOL SYM_DELETE 'R' ." delete mark
MAC_GET_SYMBOL SYM_EXECUTABLE 'S '." executable
MAC_GET_SYMBOL SYM_WORKFLOW_ITEM 'T '." workflow-object
MAC_GET_SYMBOL SYM_CAUTION 'U '." caution
MAC_GET_SYMBOL SYM_FLASH 'V' ." express, urgent
MAC_GET_SYMBOL SYM_LARGE_SQUARE 'W '." large empty square
MAC_GET_SYMBOL SYM_ELLIPSIS 'X'. " ellipsis (...)

* fill the symbols, colors in to table and set tooltips
FIELD-SYMBOLS: TYPE GS_OUTTAB.
DATA: TOOLTIPS TYPE REF TO CL_SALV_TOOLTIPS,
SETTINGS TYPE REF TO CL_SALV_FUNCTIONAL_SETTINGS,
VALUE TYPE CHAR128,
TEXT TYPE CHAR40,
TABIX TYPE SY-TABIX,
COL TYPE LVC_S_SCOL.

LOOP AT GT_OUTTAB ASSIGNING .

TABIX = SY-TABIX.

READ TABLE LT_SYMBOL INDEX SY-TABIX INTO LS_SYMBOL.
-SYMBOL = LS_SYMBOL-ID.

VALUE = -ID(3).
TEXT = -NAME.

CONCATENATE VALUE 'Q' TEXT '@' INTO VALUE.
-ID = VALUE.

VALUE = LS_SYMBOL-ID.
TEXT = LS_SYMBOL-NAME.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_SYMBOL.
LS_EXC-VALUE = VALUE.
LS_EXC-TEXT = TEXT.
APPEND LS_EXC TO GT_EXC.

-COLOR = TABIX MOD 7 + 1.
-LIGHTS = TABIX MOD 3 + 1.

COL-FNAME = 'COLOR'.
COL-COLOR-COL = TABIX MOD 7 + 1.
IF TABIX GE 7.
COL-COLOR-INV = 1.
ENDIF.
IF TABIX GE 14.
COL-COLOR-INT = 1.
ENDIF.

APPEND COL TO -TABCOL.

ENDLOOP.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_EXCEPTION.
LS_EXC-VALUE = '1'.
LS_EXC-TEXT = TEXT-ET1.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_EXCEPTION.
LS_EXC-VALUE = '2'.
LS_EXC-TEXT = TEXT-ET2.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_EXCEPTION.
LS_EXC-VALUE = '3'.
LS_EXC-TEXT = TEXT-ET3.
APPEND LS_EXC TO GT_EXC.

* length 3 encoding for colors
LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '110'.
LS_EXC-TEXT = TEXT-CT1.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '210'.
LS_EXC-TEXT = TEXT-CT2.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '310'.
LS_EXC-TEXT = TEXT-CT3.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '410'.
LS_EXC-TEXT = TEXT-CT4.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '510'.
LS_EXC-TEXT = TEXT-CT5.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '610'.
LS_EXC-TEXT = TEXT-CT6.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '710'.
LS_EXC-TEXT = TEXT-CT7.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '101'.
LS_EXC-TEXT = TEXT-CT1.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '201'.
LS_EXC-TEXT = TEXT-CT2.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '301'.
LS_EXC-TEXT = TEXT-CT3.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '401'.
LS_EXC-TEXT = TEXT-CT4.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '501'.
LS_EXC-TEXT = TEXT-CT5.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '601'.
LS_EXC-TEXT = TEXT-CT6.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '701'.
LS_EXC-TEXT = TEXT-CT7.
APPEND LS_EXC TO GT_EXC.

* simple length 1 encoding for colors - corresponds to intensified and inverse off
LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '1'.
LS_EXC-TEXT = TEXT-CT1.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '2'.
LS_EXC-TEXT = TEXT-CT2.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '3'.
LS_EXC-TEXT = TEXT-CT3.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '4'.
LS_EXC-TEXT = TEXT-CT4.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '5'.
LS_EXC-TEXT = TEXT-CT5.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '6'.
LS_EXC-TEXT = TEXT-CT6.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '7'.
LS_EXC-TEXT = TEXT-CT7.
APPEND LS_EXC TO GT_EXC.

LS_EXC-TYPE = CL_SALV_TOOLTIP=>C_TYPE_COLOR.
LS_EXC-VALUE = '0'.
LS_EXC-TEXT = TEXT-CT0.
APPEND LS_EXC TO GT_EXC.


ENDFORM. " set_tooltips

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9437124/viewspace-1022490/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-22

  • 博文量
    268
  • 访问量
    1411193