*&---------------------------------------------------------------------* *& Report ZALV4 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZALV4 MESSAGE-ID ZHQ. TYPE-POOLS:SLIS. DATA GT_CUSTOMER TYPE TABLE OF ZCUSTOMER. DATA GS_CUSTOMER TYPE ZCUSTOMER. TYPES:BEGIN OF GTY_CUSTOMER. INCLUDE STRUCTURE GS_CUSTOMER. TYPES:BOX TYPE C, COLOR TYPE C LENGTH 4,"行颜色 FIELD_COLOR TYPE LVC_T_SCOL, "列表格颜色 END OF GTY_CUSTOMER. DATA LT_CUSTOMER TYPE TABLE OF GTY_CUSTOMER. DATA LS_CUSTOMER TYPE GTY_CUSTOMER. SELECT-OPTIONS S_CODE FOR LS_CUSTOMER-ZCUSTOMERID. "客户编号 DATA GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV. DATA GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV. DATA GS_LAYOUT TYPE SLIS_LAYOUT_ALV. GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "自动优化列宽 GS_LAYOUT-WINDOW_TITLEBAR = '我的客户'. "标题 GS_LAYOUT-BOX_FIELDNAME = 'BOX'. "最前面的BOX GS_LAYOUT-DETAIL_INITIAL_LINES = 'X'. "详细信息显示+空白的 GS_LAYOUT-DETAIL_POPUP = 'X'. "弹出详细窗口 GS_LAYOUT-F2CODE = '&ETA'. GS_LAYOUT-CONFIRMATION_PROMPT = 'X'. "退出确认 GS_LAYOUT-INFO_FIELDNAME = 'COLOR'. "行颜色 GS_LAYOUT-COLTAB_FIELDNAME = 'FIELD_COLOR'. "列颜色 "字段列 DEFINE %%APPEND_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-COL_POS = &1. GS_FIELDCAT-FIELDNAME = &2. GS_FIELDCAT-SELTEXT_M = &3. CASE &2. WHEN 'ZAP'. GS_FIELDCAT-DO_SUM = 'X'. "GS_FIELDCAT-emphasize = 'C601'. WHEN 'ZCUSTOMERID'. GS_FIELDCAT-KEY = 'X'. GS_FIELDCAT-HOTSPOT = 'X'. WHEN OTHERS. ENDCASE. APPEND GS_FIELDCAT to GT_FIELDCAT. END-OF-DEFINITION. START-OF-SELECTION. *FNAME *COLOR *NOKEYCOL DATA LS_COLOR TYPE LVC_S_SCOL. DATA LT_COLOR TYPE LVC_T_SCOL. SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_CUSTOMER FROM ZCUSTOMER WHERE ZCUSTOMERID IN S_CODE. LOOP AT LT_CUSTOMER INTO LS_CUSTOMER. * IF LS_CUSTOMER-ZAP = 50. * LS_CUSTOMER-COLOR = 'C600'. * ENDIF. * IF LS_CUSTOMER-ZAP = 20. LS_CUSTOMER-COLOR = 'C710'. ENDIF. IF LS_CUSTOMER-ZAP = 50. CLEAR LS_COLOR. LS_COLOR-FNAME = 'ZAP'. LS_COLOR-COLOR-COL = 6. LS_COLOR-COLOR-INT = 0. LS_COLOR-COLOR-INV = 0. APPEND LS_COLOR TO LS_CUSTOMER-FIELD_COLOR. ENDIF. MODIFY LT_CUSTOMER FROM LS_CUSTOMER. ENDLOOP. END-OF-SELECTION. %%APPEND_FIELDCAT: '1' 'ZCUSTOMERID' '客户编号'. %%APPEND_FIELDCAT: '2' 'ZCOMPANYNAME' '客户名称'. %%APPEND_FIELDCAT: '3' 'ZCREATEDATE' '建档时间'. %%APPEND_FIELDCAT: '4' 'ZSCOPE' '客户经营范围'. %%APPEND_FIELDCAT: '5' 'ZUSERID' '专管业务员'. %%APPEND_FIELDCAT: '6' 'ZSEX' '性别'. %%APPEND_FIELDCAT: '7' 'ZAP' '应收账款'. DATA GT_SORT TYPE SLIS_T_SORTINFO_ALV. DATA GS_SORT TYPE SLIS_SORTINFO_ALV. CLEAR GS_SORT. GS_SORT-SPOS = '1'. GS_SORT-FIELDNAME = 'ZCUSTOMERID'. GS_SORT-DOWN = 'X'. APPEND GS_SORT TO GT_SORT. CLEAR GS_SORT. GS_SORT-SPOS = '2'. GS_SORT-FIELDNAME = 'ZUSERID'. GS_SORT-DOWN = 'X'. *GS_SORT-SUBTOT = 'X'. APPEND GS_SORT TO GT_SORT. DATA GT_FILTER TYPE SLIS_T_FILTER_ALV. DATA GS_FILTER TYPE SLIS_FILTER_ALV. GS_FILTER-FIELDNAME = 'ZSEX'. GS_FILTER-SIGN0 = 'I'. GS_FILTER-OPTIO = 'EQ'. GS_FILTER-VALUT = 'M'. APPEND GS_FILTER TO GT_FILTER. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' I_CALLBACK_PROGRAM = SY-REPID I_CALLBACK_PF_STATUS_SET = 'FORM_PF_STATUS' I_CALLBACK_USER_COMMAND = 'FORM_USER_COMMAND' I_CALLBACK_TOP_OF_PAGE = 'FORM_TOP_OF_PAGE' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * I_STRUCTURE_NAME = * I_BACKGROUND_ID = ' ' I_GRID_TITLE = '共有客户(366)家' * I_GRID_SETTINGS = IS_LAYOUT = GS_LAYOUT IT_FIELDCAT = GT_FIELDCAT * IT_EXCLUDING = * IT_SPECIAL_GROUPS = IT_SORT = GT_SORT * IT_FILTER = GT_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 = * IR_SALV_FULLSCREEN_ADAPTER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES T_OUTTAB = LT_CUSTOMER * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. FORM FORM_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS 'STANDARD' EXCLUDING RT_EXTAB. ENDFORM. FORM FORM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. DATA CODE TYPE SY-UCOMM. CODE = R_UCOMM. CASE CODE. WHEN 'CALLSF'. MESSAGE '开始打印' TYPE 'I'. WHEN 'DOWNLOAD'. MESSAGE '下载文件' TYPE 'I'. WHEN 'FLUSH'. MESSAGE S000 WITH '刷新成功' DISPLAY LIKE 'S'. WHEN OTHERS. ENDCASE. ENDFORM. FORM FORM_TOP_OF_PAGE. DATA: LV_DATE TYPE SY-DATUM. CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' EXPORTING DATE_INTERNAL = '20160101' "当前日期格式" IMPORTING DATE_EXTERNAL = LV_DATE "输出:2016.01.01 " EXCEPTIONS DATE_INTERNAL_IS_INVALID = 1 OTHERS = 2. DATA GT_LISTHEADER TYPE SLIS_T_LISTHEADER. DATA GS_LISTHEADER TYPE SLIS_LISTHEADER. CLEAR GS_LISTHEADER. GS_LISTHEADER-TYP = 'H'. GS_LISTHEADER-INFO = '表头描述文本'. APPEND GS_LISTHEADER TO GT_LISTHEADER. CLEAR GS_LISTHEADER. GS_LISTHEADER-TYP = 'S'. GS_LISTHEADER-INFO = LV_DATE. GS_LISTHEADER-KEY = '当前日期:'. APPEND GS_LISTHEADER TO GT_LISTHEADER. CLEAR GS_LISTHEADER. GS_LISTHEADER-TYP = 'A'. GS_LISTHEADER-INFO = '熟练掌握计算机知识、信息系统、数据库知识、OFFICE等办公软件。有java、SQL、HTML基础者优先'. APPEND GS_LISTHEADER TO GT_LISTHEADER. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING IT_LIST_COMMENTARY = GT_LISTHEADER. ENDFORM.
标签:CUSTOMER,GS,LISTHEADER,表格,FIELDCAT,COLOR,ALV,颜色,TYPE From: https://www.cnblogs.com/hua900822/p/17512837.html