首页 > 其他分享 >ALV-行颜色+列颜色+头表格

ALV-行颜色+列颜色+头表格

时间:2023-06-28 23:45:49浏览次数:40  
标签:CUSTOMER GS LISTHEADER 表格 FIELDCAT COLOR ALV 颜色 TYPE

*&---------------------------------------------------------------------*
*& 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

相关文章

  • 使用exceljs和file-saver导出带图片的excel表格
    参考https://www.swvq.com/article/detail/487https://github.com/exceljs/exceljs/blob/master/README_zh.md#图片importExcelJSfrom'exceljs'importfileSaverfrom'file-saver'letworkbook=nullletworksheet=null//图片转base64constco......
  • vue-element table表格排序推拽功能
    //1.安装sortablejsnpminstallsortablejs--save//2.功能页面中引入importSortablefrom‘sortablejs’具体使用(注意:elementtable务必指定row-key,且row-key必须是唯一的,如id,不然会出现排序不对的情况)<el-tablerow-key="id":data="tableData"style="width:......
  • java 序列化 serialVersionUID transient
    问题再现User类实现了序列化,但是没有声明版本号,这个对象放在memcache中,User新添加了1个字段后,把之前的对象从缓存中取出来时,出现了InvalidClassException,为什么会出现这个错误?序列化序列化就是将对象转为流,用于传输或保存。序列化的是“对象状态”,所以就不包括静态变量;反序列化是从......
  • Android LayoutManager高端玩家,实现花式表格!
    如果你对RecyclerView原理还不是特别了解,非常建议你读一下。本文的项目也是学习自定义LayoutManager绝佳资料,大家有需要的可以好好拜读。前言表格是自打我进公司以后就使用的控件,起初使用的是ScrollablePanel,从一开始的被花式吊打,到后期的熟练使用。大佬写的控件确实给我的工作带来......
  • java线程监控-jstack+jvisualvm
    Java线程监控一.Jstasck1.查找进程ps-ef|greptomcat-oa2.使用jstack监控jstack2429二、jvisualvm1.tomcat应用环境配置1.1tomcat环境配置修改tomcat中,catalina.sh文件cd/usr/src/tomcat-pinter/binvicatalina.sh在第二行添加如下:JAVA_OPTS="-Dcom.sun.mana......
  • js正则匹配以$开头和结尾的内容,并改变颜色
     letres="$你好你好$"res=res.replace(/\$(?<=\$).*?(?=\$)\$/g,`<spanonclick="((params)=>{console.log(params)})('$&')"style="color:dodgerblue;padding:05px;"......
  • css颜色变淡和变浅方法收集(模拟sass的darken和lighten函数)
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document</title><......
  • JQ 表格展开伸缩
    style.csstable{border:0;border-collapse:collapse;}td{font:normal12px/17pxArial;padding:2px;width:100px;}th{font:bold12px/17pxArial;text-align:left;padding:4px;border-bottom:1pxsolid#333;width:100px;}.parent{background:#FFF38F;cursor:point......
  • 艺术 网页设计的12种颜色
    前不久,ColourLovers.com公布了一项调查结果。他们发现,美国前100大网站的Logo,主要使用12种颜色。其中,采用蓝色的网站最多,红色排在第二种,黄色排在第三种。 我把这12种颜色的RGB代码列出来,供将来自己做网页时参考。1.浅绿#8cc540  2.深绿#009f5d 3.暗蓝#019fa04.蓝色#019......
  • CSS 尺寸单位和颜色单位
    尺寸单位描述%百分比in英寸cm厘米mm毫米em1em等于当前的字体尺寸。2em等于当前字体尺寸的两倍。例如,如果某元素以12pt显示,那么2em是24pt。在CSS中,em是非常有用的单位,因为它可以自动适应用户所使用的字体。ex一个ex是一个字体的x-height。(x-height通常是......