TYPE-POOLS: SLIS.
*INCLUDE ZPHBDP_ALV_DISPALY.
**** begin of ALV 引用 *****************
TYPE-POOLS SLIS. "引用ALV控件
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
EVENTCAT TYPE SLIS_T_EVENT,
IT_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT WITH HEADER LINE.
DATA: G_LAYOUT TYPE SLIS_LAYOUT_ALV.
**** end of ALV 引用 *****************
DATA: BEGIN OF WA_ICON,
ID1(10),
ICON1(10),
ID2(10),
ICON2(10),
ID3(10),
ICON3(10),
ID4(10),
ICON4(10),
ID5(10),
ICON5(10),
ID6(10),
ICON6(10),
ID7(10),
ICON7(10),
ID8(10),
ICON8(10),
ID9(10),
ICON9(10),
ID10(10),
ICON10(10),
END OF WA_ICON,
IT_ICON LIKE WA_ICON OCCURS 0 WITH HEADER LINE.
* EVENTCAT TYPE SLIS_T_EVENT.
DATA: STATS_TEXT(20) VALUE 'ALV 表'. "工具栏按钮的文本
DATA: COUNT TYPE I,
C_COU(2),
LINE LIKE SY-LINNO.
DATA: DO_COUNT TYPE I, "循环当前次数
DO_C_COUNT(2).
CONSTANTS STA_NUM TYPE I VALUE 65.
DATA: NUMBER TYPE I,
WORD(2),
NUMBER2 TYPE I,
WORD2(2).
DATA: MOD TYPE I.
TOP-OF-PAGE.
DATA: MSG(100).
CONCATENATE '使用以下图标时,只需要复制图标前面对应的两位代码,然后在前后各加上一个' '''@'' 如:@01@;' INTO MSG.
WRITE MSG.
CONCATENATE '当鼠标放在图标上出现' '''提示''' ',可在两位代码加上' '''提示''' ' 如:@01\Q提示@' INTO MSG.
WRITE MSG.
ULINE (121).
* SKIP.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'BUT1'.
PERFORM ALV_GRID.
WHEN 'F03' OR 'F04' OR 'F05'.
LEAVE PROGRAM.
ENDCASE.
START-OF-SELECTION.
PERFORM PT_GRID.
*&---------------------------------------------------------------------*
*& Form PT_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PT_GRID .
STATS_TEXT = 'ALV 网格表显示'.
PERFORM FRM_SET_WIN_STATUS .
CLEAR DO_COUNT.
"第一位为数字的所有图标
DO 10 TIMES.
DO_C_COUNT = DO_COUNT.
ULINE (121).
WRITE / '|'.
CLEAR COUNT.
"第二位为数字的所有图标
DO 10 TIMES.
C_COU = COUNT.
CONCATENATE DO_C_COUNT C_COU INTO C_COU.
PERFORM FRM_SET_FORM USING C_COU.
COUNT = COUNT + 1.
ENDDO.
WRITE: / '|'.
"第二位为字母ICON
NUMBER = STA_NUM.
COUNT = 0.
DO 30 TIMES.
IF COUNT < 26.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
CONCATENATE DO_C_COUNT WORD INTO WORD.
ELSE.
CLEAR WORD.
ENDIF.
PERFORM FRM_SET_FORM USING WORD.
NUMBER = NUMBER + 1. "ASC码加1
COUNT = COUNT + 1. "内循环次数加1
MOD = COUNT MOD 10. "如果循环次数整除10,换行
IF MOD = 0.
WRITE: / '|'.
ENDIF.
ENDDO.
WRITE: / .
DO_COUNT = DO_COUNT + 1. "外循环次数加1
LINE = SY-LINNO - 2.
SKIP TO LINE LINE.
ENDDO.
CLEAR DO_COUNT.
"第一位为字母ICON
NUMBER = STA_NUM.
DO 26 TIMES.
ULINE 1(121).
WRITE / '|'.
DO_C_COUNT = DO_COUNT.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1. "ASC码加1
"第二位为数字的所有图标
CLEAR COUNT.
DO 10 TIMES.
C_COU = COUNT.
CONCATENATE WORD C_COU INTO C_COU.
PERFORM FRM_SET_FORM USING C_COU.
COUNT = COUNT + 1.
ENDDO.
WRITE / '|'.
"第二位为字母ICON
NUMBER2 = STA_NUM.
COUNT = 0.
DO 30 TIMES.
IF COUNT < 26.
PERFORM FRM_CHANGE_ASC USING NUMBER2 WORD2.
CONCATENATE WORD WORD2 INTO WORD2.
ELSE.
CLEAR WORD2.
ENDIF.
PERFORM FRM_SET_FORM USING WORD2.
NUMBER2 = NUMBER2 + 1. "ASC码加1
COUNT = COUNT + 1. "内循环次数加1
MOD = COUNT MOD 10. "如果循环次数整除10,换行
IF MOD = 0.
WRITE: / '|'.
ENDIF.
ENDDO.
WRITE: / .
LINE = SY-LINNO - 2.
SKIP TO LINE LINE.
ENDDO.
"加上最下的划线完成表格
IF LINE > 0.
ULINE 1(121).
ENDIF.
ENDFORM. " PT_GRID
*&---------------------------------------------------------------------*
*& Form ALV_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID .
DATA: WDO_COUNT TYPE I, "外循环次数
WDO_COUNT_C,
NDO_COUNT TYPE I, "内循环次数
NDO_COUNT_C.
DATA: FRM_ID(2).
DATA: FRM_TABIX TYPE I.
STATS_TEXT = '普通网格显示'.
REFRESH IT_ICON.
DO 10 TIMES.
WDO_COUNT_C = WDO_COUNT.
CLEAR NDO_COUNT.
DO 10 TIMES.
NDO_COUNT_C = NDO_COUNT.
CONCATENATE WDO_COUNT_C NDO_COUNT_C INTO FRM_ID.
PERFORM ADD_IT USING FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
ENDDO.
NUMBER = STA_NUM.
CLEAR NDO_COUNT.
DO 30 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1. "ASC码加1
CONCATENATE WDO_COUNT_C WORD INTO FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
IF NDO_COUNT > 26.
CLEAR FRM_ID.
ENDIF.
PERFORM ADD_IT USING FRM_ID.
ENDDO.
WDO_COUNT = WDO_COUNT + 1.
ENDDO.
NUMBER = STA_NUM.
DO 26 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1.
CLEAR NDO_COUNT.
DO 10 TIMES.
NDO_COUNT_C = NDO_COUNT.
CONCATENATE WORD NDO_COUNT_C INTO FRM_ID.
PERFORM ADD_IT USING FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
ENDDO.
NUMBER2 = STA_NUM.
CLEAR NDO_COUNT.
DO 30 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER2 WORD2.
CONCATENATE WORD WORD2 INTO FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
IF NDO_COUNT > 26.
CLEAR FRM_ID.
ENDIF.
PERFORM ADD_IT USING FRM_ID.
NUMBER2 = NUMBER2 + 1.
ENDDO.
ENDDO.
PERFORM CHANGE_GRID. "转换行列
"ALV显示
G_LAYOUT-ZEBRA = 'X'.
REFRESH IT_FIELDCAT.
PERFORM ADD_FIELDCAT USING 'ID1' '5' 'ID号1' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON1' '7' '图标1' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID2' '5' 'ID号2' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON2' '7' '图标2' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID3' '5' 'ID号3' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON3' '7' '图标3' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID4' '5' 'ID号4' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON4' '7' '图标4' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID5' '5' 'ID号5' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON5' '7' '图标5' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID6' '5' 'ID号6' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON6' '7' '图标6' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID7' '5' 'ID号7' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON7' '7' '图标7' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID8' '5' 'ID号8' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON8' '7' '图标8' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID9' '5' 'ID号9' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON9' '7' '图标9' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID10' '5' 'ID号10' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON10' '7' '图标10' '' 'C' '' '' '' ''.
IT_EVENT_EXIT-UCOMM = 'F03'.
IT_EVENT_EXIT-BEFORE = 'X'.
IT_EVENT_EXIT-AFTER = 'X'.
APPEND IT_EVENT_EXIT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS' "加入标准工具栏
I_CALLBACK_USER_COMMAND = 'FRM_USER_COM' "加入用户自定义事件
IS_LAYOUT = G_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EVENTS = EVENTCAT
IT_EVENT_EXIT = IT_EVENT_EXIT[]
TABLES "将需要显示内表内容放在此处
T_OUTTAB = IT_ICON.
ENDFORM. " ALV_GRID
*&---------------------------------------------------------------------*
*& Form frm_set_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_COU text
* -->P_ICO text
*----------------------------------------------------------------------*
FORM FRM_SET_FORM USING P_COU.
DATA: FRM_ICO(4).
IF P_COU IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_COU
IMPORTING
OUTPUT = C_COU.
CONCATENATE '@' C_COU '@' INTO FRM_ICO.
CONDENSE FRM_ICO.
WRITE: C_COU ,'-' ,FRM_ICO ,'|'.
ELSE.
WRITE: ' ', '|'.
ENDIF.
ENDFORM. "frm_set_form
*&---------------------------------------------------------------------*
*& Form frm_change_asc
*&---------------------------------------------------------------------*
* 数字转换成字母
*----------------------------------------------------------------------*
* -->P_CHAR text
*----------------------------------------------------------------------*
FORM FRM_CHANGE_ASC USING P_CHAR1 P_CHAR2.
DATA:ZT_CHAR TYPE C.
"转换成ASCI码
FIELD-SYMBOLS : <N> TYPE X.
ASSIGN P_CHAR1 TO <N> CASTING.
MOVE <N> TO P_CHAR2.
"恢复成SAP码
*DATA : RN TYPE I.
DATA : N_X(4) TYPE X.
FIELD-SYMBOLS : <FC> TYPE C.
MOVE P_CHAR1 TO N_X.
ASSIGN N_X TO <FC> CASTING ."type c.
MOVE <FC>+1(1) TO P_CHAR2.
ENDFORM. "frm_change_asc
*&---------------------------------------------------------------------*
*& Form ADD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->VALUE(P_FIELDNAME) text
* -->VALUE(P_OUTPUTLEN) text
* -->P_TEXT text
* -->VALUE(P_KEY) text
* -->VALUE(P_JUST) text
* -->VALUE(P_FIELD) text
* -->VALUE(P_TABLE) text
* -->VALUE(P_EDIT) text
* -->P_CHECKBOX text
*----------------------------------------------------------------------*
FORM ADD_FIELDCAT USING VALUE(P_FIELDNAME)
VALUE(P_OUTPUTLEN)
P_TEXT
VALUE(P_KEY)
VALUE(P_JUST)
VALUE(P_FIELD)
VALUE(P_TABLE)
VALUE(P_EDIT)
P_CHECKBOX .
CLEAR: IT_FIELDCAT.
IF P_CHECKBOX ='CHEBOX'.
IT_FIELDCAT-CHECKBOX = 'X'.
ENDIF.
IT_FIELDCAT-FIELDNAME = P_FIELDNAME.
IT_FIELDCAT-OUTPUTLEN = P_OUTPUTLEN.
IT_FIELDCAT-REPTEXT_DDIC = P_TEXT.
IT_FIELDCAT-KEY = P_KEY.
IT_FIELDCAT-JUST = P_JUST.
IT_FIELDCAT-REF_FIELDNAME = P_FIELD.
IT_FIELDCAT-REF_TABNAME = P_TABLE.
IT_FIELDCAT-EDIT = P_EDIT.
APPEND IT_FIELDCAT.
ENDFORM. "ADD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_SET_ALV_TITLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FRM_SET_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
PERFORM FRM_SET_WIN_STATUS.
ENDFORM. "FRM_SET_ALV_TITLE
*&---------------------------------------------------------------------*
*& Form frm_set_win_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_WIN_STATUS .
SET PF-STATUS '100'.
ENDFORM. " frm_set_win_status
*&---------------------------------------------------------------------*
*& Form FRM_USER_COM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM FRM_USER_COM USING UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE UCOMM.
WHEN 'F03' OR 'F04' OR 'F05'.
LEAVE PROGRAM.
WHEN 'BUT1'.
SUBMIT ZTEST_WKB048.
ENDCASE.
ENDFORM. "FRM_USER_COM
*&---------------------------------------------------------------------*
*& Form add_it
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ADD_IT USING P_ID .
IF P_ID IS NOT INITIAL.
IT_ICON-ID1 = P_ID.
CONDENSE IT_ICON-ID1.
CONCATENATE '@' IT_ICON-ID1 '@' INTO IT_ICON-ICON1.
CONDENSE IT_ICON-ICON1.
ELSE.
CLEAR IT_ICON.
ENDIF.
APPEND IT_ICON.
ENDFORM. "ADD_IT
*&---------------------------------------------------------------------*
*& Form change_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM CHANGE_GRID.
DATA: FRM_IT_ICON LIKE IT_ICON OCCURS 0 WITH HEADER LINE.
DATA: FRM_TABIX TYPE P,
FRM_MOD TYPE I.
DATA: FRM_SY_INDX LIKE SY-TABIX.
FRM_IT_ICON[] = IT_ICON[].
REFRESH IT_ICON.
LOOP AT FRM_IT_ICON.
FRM_SY_INDX = SY-TABIX MOD 40.
FRM_TABIX = FRM_TABIX + 1.
FRM_MOD = FRM_TABIX MOD 10.
CASE FRM_TABIX.
WHEN '1'.
IT_ICON-ID1 = FRM_IT_ICON-ID1.
IT_ICON-ICON1 = FRM_IT_ICON-ICON1.
WHEN '2'.
IT_ICON-ID2 = FRM_IT_ICON-ID1.
IT_ICON-ICON2 = FRM_IT_ICON-ICON1.
WHEN '3'.
IT_ICON-ID3 = FRM_IT_ICON-ID1.
IT_ICON-ICON3 = FRM_IT_ICON-ICON1.
WHEN '4'.
IT_ICON-ID4 = FRM_IT_ICON-ID1.
IT_ICON-ICON4 = FRM_IT_ICON-ICON1.
WHEN '5'.
IT_ICON-ID5 = FRM_IT_ICON-ID1.
IT_ICON-ICON5 = FRM_IT_ICON-ICON1.
WHEN '6'.
IT_ICON-ID6 = FRM_IT_ICON-ID1.
IT_ICON-ICON6 = FRM_IT_ICON-ICON1.
WHEN '7'.
IT_ICON-ID7 = FRM_IT_ICON-ID1.
IT_ICON-ICON7 = FRM_IT_ICON-ICON1.
WHEN '8'.
IT_ICON-ID8 = FRM_IT_ICON-ID1.
IT_ICON-ICON8 = FRM_IT_ICON-ICON1.
WHEN '9'.
IT_ICON-ID9 = FRM_IT_ICON-ID1.
IT_ICON-ICON9 = FRM_IT_ICON-ICON1.
WHEN '10'.
IT_ICON-ID10 = FRM_IT_ICON-ID1.
IT_ICON-ICON10 = FRM_IT_ICON-ICON1.
ENDCASE.
IF FRM_MOD = 0.
APPEND IT_ICON.
CLEAR IT_ICON.
FRM_TABIX = 0.
ENDIF.
IF FRM_SY_INDX = 0.
APPEND IT_ICON.
ENDIF.
ENDLOOP.
DESCRIBE TABLE IT_ICON LINES FRM_SY_INDX.
DELETE IT_ICON INDEX FRM_SY_INDX.
ENDFORM. " add_it
*INCLUDE ZPHBDP_ALV_DISPALY.
**** begin of ALV 引用 *****************
TYPE-POOLS SLIS. "引用ALV控件
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
EVENTCAT TYPE SLIS_T_EVENT,
IT_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT WITH HEADER LINE.
DATA: G_LAYOUT TYPE SLIS_LAYOUT_ALV.
**** end of ALV 引用 *****************
DATA: BEGIN OF WA_ICON,
ID1(10),
ICON1(10),
ID2(10),
ICON2(10),
ID3(10),
ICON3(10),
ID4(10),
ICON4(10),
ID5(10),
ICON5(10),
ID6(10),
ICON6(10),
ID7(10),
ICON7(10),
ID8(10),
ICON8(10),
ID9(10),
ICON9(10),
ID10(10),
ICON10(10),
END OF WA_ICON,
IT_ICON LIKE WA_ICON OCCURS 0 WITH HEADER LINE.
* EVENTCAT TYPE SLIS_T_EVENT.
DATA: STATS_TEXT(20) VALUE 'ALV 表'. "工具栏按钮的文本
DATA: COUNT TYPE I,
C_COU(2),
LINE LIKE SY-LINNO.
DATA: DO_COUNT TYPE I, "循环当前次数
DO_C_COUNT(2).
CONSTANTS STA_NUM TYPE I VALUE 65.
DATA: NUMBER TYPE I,
WORD(2),
NUMBER2 TYPE I,
WORD2(2).
DATA: MOD TYPE I.
TOP-OF-PAGE.
DATA: MSG(100).
CONCATENATE '使用以下图标时,只需要复制图标前面对应的两位代码,然后在前后各加上一个' '''@'' 如:@01@;' INTO MSG.
WRITE MSG.
CONCATENATE '当鼠标放在图标上出现' '''提示''' ',可在两位代码加上' '''提示''' ' 如:@01\Q提示@' INTO MSG.
WRITE MSG.
ULINE (121).
* SKIP.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'BUT1'.
PERFORM ALV_GRID.
WHEN 'F03' OR 'F04' OR 'F05'.
LEAVE PROGRAM.
ENDCASE.
START-OF-SELECTION.
PERFORM PT_GRID.
*&---------------------------------------------------------------------*
*& Form PT_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PT_GRID .
STATS_TEXT = 'ALV 网格表显示'.
PERFORM FRM_SET_WIN_STATUS .
CLEAR DO_COUNT.
"第一位为数字的所有图标
DO 10 TIMES.
DO_C_COUNT = DO_COUNT.
ULINE (121).
WRITE / '|'.
CLEAR COUNT.
"第二位为数字的所有图标
DO 10 TIMES.
C_COU = COUNT.
CONCATENATE DO_C_COUNT C_COU INTO C_COU.
PERFORM FRM_SET_FORM USING C_COU.
COUNT = COUNT + 1.
ENDDO.
WRITE: / '|'.
"第二位为字母ICON
NUMBER = STA_NUM.
COUNT = 0.
DO 30 TIMES.
IF COUNT < 26.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
CONCATENATE DO_C_COUNT WORD INTO WORD.
ELSE.
CLEAR WORD.
ENDIF.
PERFORM FRM_SET_FORM USING WORD.
NUMBER = NUMBER + 1. "ASC码加1
COUNT = COUNT + 1. "内循环次数加1
MOD = COUNT MOD 10. "如果循环次数整除10,换行
IF MOD = 0.
WRITE: / '|'.
ENDIF.
ENDDO.
WRITE: / .
DO_COUNT = DO_COUNT + 1. "外循环次数加1
LINE = SY-LINNO - 2.
SKIP TO LINE LINE.
ENDDO.
CLEAR DO_COUNT.
"第一位为字母ICON
NUMBER = STA_NUM.
DO 26 TIMES.
ULINE 1(121).
WRITE / '|'.
DO_C_COUNT = DO_COUNT.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1. "ASC码加1
"第二位为数字的所有图标
CLEAR COUNT.
DO 10 TIMES.
C_COU = COUNT.
CONCATENATE WORD C_COU INTO C_COU.
PERFORM FRM_SET_FORM USING C_COU.
COUNT = COUNT + 1.
ENDDO.
WRITE / '|'.
"第二位为字母ICON
NUMBER2 = STA_NUM.
COUNT = 0.
DO 30 TIMES.
IF COUNT < 26.
PERFORM FRM_CHANGE_ASC USING NUMBER2 WORD2.
CONCATENATE WORD WORD2 INTO WORD2.
ELSE.
CLEAR WORD2.
ENDIF.
PERFORM FRM_SET_FORM USING WORD2.
NUMBER2 = NUMBER2 + 1. "ASC码加1
COUNT = COUNT + 1. "内循环次数加1
MOD = COUNT MOD 10. "如果循环次数整除10,换行
IF MOD = 0.
WRITE: / '|'.
ENDIF.
ENDDO.
WRITE: / .
LINE = SY-LINNO - 2.
SKIP TO LINE LINE.
ENDDO.
"加上最下的划线完成表格
IF LINE > 0.
ULINE 1(121).
ENDIF.
ENDFORM. " PT_GRID
*&---------------------------------------------------------------------*
*& Form ALV_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID .
DATA: WDO_COUNT TYPE I, "外循环次数
WDO_COUNT_C,
NDO_COUNT TYPE I, "内循环次数
NDO_COUNT_C.
DATA: FRM_ID(2).
DATA: FRM_TABIX TYPE I.
STATS_TEXT = '普通网格显示'.
REFRESH IT_ICON.
DO 10 TIMES.
WDO_COUNT_C = WDO_COUNT.
CLEAR NDO_COUNT.
DO 10 TIMES.
NDO_COUNT_C = NDO_COUNT.
CONCATENATE WDO_COUNT_C NDO_COUNT_C INTO FRM_ID.
PERFORM ADD_IT USING FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
ENDDO.
NUMBER = STA_NUM.
CLEAR NDO_COUNT.
DO 30 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1. "ASC码加1
CONCATENATE WDO_COUNT_C WORD INTO FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
IF NDO_COUNT > 26.
CLEAR FRM_ID.
ENDIF.
PERFORM ADD_IT USING FRM_ID.
ENDDO.
WDO_COUNT = WDO_COUNT + 1.
ENDDO.
NUMBER = STA_NUM.
DO 26 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER WORD.
NUMBER = NUMBER + 1.
CLEAR NDO_COUNT.
DO 10 TIMES.
NDO_COUNT_C = NDO_COUNT.
CONCATENATE WORD NDO_COUNT_C INTO FRM_ID.
PERFORM ADD_IT USING FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
ENDDO.
NUMBER2 = STA_NUM.
CLEAR NDO_COUNT.
DO 30 TIMES.
PERFORM FRM_CHANGE_ASC USING NUMBER2 WORD2.
CONCATENATE WORD WORD2 INTO FRM_ID.
NDO_COUNT = NDO_COUNT + 1.
IF NDO_COUNT > 26.
CLEAR FRM_ID.
ENDIF.
PERFORM ADD_IT USING FRM_ID.
NUMBER2 = NUMBER2 + 1.
ENDDO.
ENDDO.
PERFORM CHANGE_GRID. "转换行列
"ALV显示
G_LAYOUT-ZEBRA = 'X'.
REFRESH IT_FIELDCAT.
PERFORM ADD_FIELDCAT USING 'ID1' '5' 'ID号1' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON1' '7' '图标1' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID2' '5' 'ID号2' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON2' '7' '图标2' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID3' '5' 'ID号3' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON3' '7' '图标3' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID4' '5' 'ID号4' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON4' '7' '图标4' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID5' '5' 'ID号5' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON5' '7' '图标5' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID6' '5' 'ID号6' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON6' '7' '图标6' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID7' '5' 'ID号7' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON7' '7' '图标7' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID8' '5' 'ID号8' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON8' '7' '图标8' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID9' '5' 'ID号9' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON9' '7' '图标9' '' 'C' '' '' '' ''.
PERFORM ADD_FIELDCAT USING 'ID10' '5' 'ID号10' '' 'C' '' '' '' '' .
PERFORM ADD_FIELDCAT USING 'ICON10' '7' '图标10' '' 'C' '' '' '' ''.
IT_EVENT_EXIT-UCOMM = 'F03'.
IT_EVENT_EXIT-BEFORE = 'X'.
IT_EVENT_EXIT-AFTER = 'X'.
APPEND IT_EVENT_EXIT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS' "加入标准工具栏
I_CALLBACK_USER_COMMAND = 'FRM_USER_COM' "加入用户自定义事件
IS_LAYOUT = G_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EVENTS = EVENTCAT
IT_EVENT_EXIT = IT_EVENT_EXIT[]
TABLES "将需要显示内表内容放在此处
T_OUTTAB = IT_ICON.
ENDFORM. " ALV_GRID
*&---------------------------------------------------------------------*
*& Form frm_set_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_COU text
* -->P_ICO text
*----------------------------------------------------------------------*
FORM FRM_SET_FORM USING P_COU.
DATA: FRM_ICO(4).
IF P_COU IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_COU
IMPORTING
OUTPUT = C_COU.
CONCATENATE '@' C_COU '@' INTO FRM_ICO.
CONDENSE FRM_ICO.
WRITE: C_COU ,'-' ,FRM_ICO ,'|'.
ELSE.
WRITE: ' ', '|'.
ENDIF.
ENDFORM. "frm_set_form
*&---------------------------------------------------------------------*
*& Form frm_change_asc
*&---------------------------------------------------------------------*
* 数字转换成字母
*----------------------------------------------------------------------*
* -->P_CHAR text
*----------------------------------------------------------------------*
FORM FRM_CHANGE_ASC USING P_CHAR1 P_CHAR2.
DATA:ZT_CHAR TYPE C.
"转换成ASCI码
FIELD-SYMBOLS : <N> TYPE X.
ASSIGN P_CHAR1 TO <N> CASTING.
MOVE <N> TO P_CHAR2.
"恢复成SAP码
*DATA : RN TYPE I.
DATA : N_X(4) TYPE X.
FIELD-SYMBOLS : <FC> TYPE C.
MOVE P_CHAR1 TO N_X.
ASSIGN N_X TO <FC> CASTING ."type c.
MOVE <FC>+1(1) TO P_CHAR2.
ENDFORM. "frm_change_asc
*&---------------------------------------------------------------------*
*& Form ADD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->VALUE(P_FIELDNAME) text
* -->VALUE(P_OUTPUTLEN) text
* -->P_TEXT text
* -->VALUE(P_KEY) text
* -->VALUE(P_JUST) text
* -->VALUE(P_FIELD) text
* -->VALUE(P_TABLE) text
* -->VALUE(P_EDIT) text
* -->P_CHECKBOX text
*----------------------------------------------------------------------*
FORM ADD_FIELDCAT USING VALUE(P_FIELDNAME)
VALUE(P_OUTPUTLEN)
P_TEXT
VALUE(P_KEY)
VALUE(P_JUST)
VALUE(P_FIELD)
VALUE(P_TABLE)
VALUE(P_EDIT)
P_CHECKBOX .
CLEAR: IT_FIELDCAT.
IF P_CHECKBOX ='CHEBOX'.
IT_FIELDCAT-CHECKBOX = 'X'.
ENDIF.
IT_FIELDCAT-FIELDNAME = P_FIELDNAME.
IT_FIELDCAT-OUTPUTLEN = P_OUTPUTLEN.
IT_FIELDCAT-REPTEXT_DDIC = P_TEXT.
IT_FIELDCAT-KEY = P_KEY.
IT_FIELDCAT-JUST = P_JUST.
IT_FIELDCAT-REF_FIELDNAME = P_FIELD.
IT_FIELDCAT-REF_TABNAME = P_TABLE.
IT_FIELDCAT-EDIT = P_EDIT.
APPEND IT_FIELDCAT.
ENDFORM. "ADD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_SET_ALV_TITLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FRM_SET_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
PERFORM FRM_SET_WIN_STATUS.
ENDFORM. "FRM_SET_ALV_TITLE
*&---------------------------------------------------------------------*
*& Form frm_set_win_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_WIN_STATUS .
SET PF-STATUS '100'.
ENDFORM. " frm_set_win_status
*&---------------------------------------------------------------------*
*& Form FRM_USER_COM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM FRM_USER_COM USING UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE UCOMM.
WHEN 'F03' OR 'F04' OR 'F05'.
LEAVE PROGRAM.
WHEN 'BUT1'.
SUBMIT ZTEST_WKB048.
ENDCASE.
ENDFORM. "FRM_USER_COM
*&---------------------------------------------------------------------*
*& Form add_it
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ADD_IT USING P_ID .
IF P_ID IS NOT INITIAL.
IT_ICON-ID1 = P_ID.
CONDENSE IT_ICON-ID1.
CONCATENATE '@' IT_ICON-ID1 '@' INTO IT_ICON-ICON1.
CONDENSE IT_ICON-ICON1.
ELSE.
CLEAR IT_ICON.
ENDIF.
APPEND IT_ICON.
ENDFORM. "ADD_IT
*&---------------------------------------------------------------------*
*& Form change_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM CHANGE_GRID.
DATA: FRM_IT_ICON LIKE IT_ICON OCCURS 0 WITH HEADER LINE.
DATA: FRM_TABIX TYPE P,
FRM_MOD TYPE I.
DATA: FRM_SY_INDX LIKE SY-TABIX.
FRM_IT_ICON[] = IT_ICON[].
REFRESH IT_ICON.
LOOP AT FRM_IT_ICON.
FRM_SY_INDX = SY-TABIX MOD 40.
FRM_TABIX = FRM_TABIX + 1.
FRM_MOD = FRM_TABIX MOD 10.
CASE FRM_TABIX.
WHEN '1'.
IT_ICON-ID1 = FRM_IT_ICON-ID1.
IT_ICON-ICON1 = FRM_IT_ICON-ICON1.
WHEN '2'.
IT_ICON-ID2 = FRM_IT_ICON-ID1.
IT_ICON-ICON2 = FRM_IT_ICON-ICON1.
WHEN '3'.
IT_ICON-ID3 = FRM_IT_ICON-ID1.
IT_ICON-ICON3 = FRM_IT_ICON-ICON1.
WHEN '4'.
IT_ICON-ID4 = FRM_IT_ICON-ID1.
IT_ICON-ICON4 = FRM_IT_ICON-ICON1.
WHEN '5'.
IT_ICON-ID5 = FRM_IT_ICON-ID1.
IT_ICON-ICON5 = FRM_IT_ICON-ICON1.
WHEN '6'.
IT_ICON-ID6 = FRM_IT_ICON-ID1.
IT_ICON-ICON6 = FRM_IT_ICON-ICON1.
WHEN '7'.
IT_ICON-ID7 = FRM_IT_ICON-ID1.
IT_ICON-ICON7 = FRM_IT_ICON-ICON1.
WHEN '8'.
IT_ICON-ID8 = FRM_IT_ICON-ID1.
IT_ICON-ICON8 = FRM_IT_ICON-ICON1.
WHEN '9'.
IT_ICON-ID9 = FRM_IT_ICON-ID1.
IT_ICON-ICON9 = FRM_IT_ICON-ICON1.
WHEN '10'.
IT_ICON-ID10 = FRM_IT_ICON-ID1.
IT_ICON-ICON10 = FRM_IT_ICON-ICON1.
ENDCASE.
IF FRM_MOD = 0.
APPEND IT_ICON.
CLEAR IT_ICON.
FRM_TABIX = 0.
ENDIF.
IF FRM_SY_INDX = 0.
APPEND IT_ICON.
ENDIF.
ENDLOOP.
DESCRIBE TABLE IT_ICON LINES FRM_SY_INDX.
DELETE IT_ICON INDEX FRM_SY_INDX.
ENDFORM. " add_it