• ALV报表的颜色设计(行、列、单元格)


    列颜色:通过字段目录的强调字段FIELDCAT实现

    行颜色:通过LAYOUT实现,给显示内表添加一个字段储存它的颜色

    单元格颜色:通过LAYOUT实现,给显示内表添加一个内表存储颜色(内表类型:LVC_T_SCOL)

    单元格颜色的设置与行颜色设计基本一致
    
    1. 在构成ALV数据的内表中,添加一个内表 CellColor,用来记录颜色代码,需要设置颜色的字段名
        CellColor的结构:FNAME        ALV 控制: 内部表字段的字段名称         
                        COLOR        ALV 控制: 颜色代码     
             COLOR是一个结构:
                   COL    ALV 控制: 颜色 ;
                   INT    ALV 控制: 强化   1/0;
                   INV    ALV 控制: 相反    1/0    设置颜色是前景,或者是背景         
        NOKEYCOL  ALV 控制: 覆盖码颜色
    2. 循环内表,设置颜色代码
    
    REPORT Z1113.
    
    TYPES:BEGIN OF TYP_01,
            MATNR TYPE MARA-MATNR,
            ERNAM TYPE MARA-ERNAM,
            ERSDA TYPE MARA-ERSDA,
            COLOR TYPE CHAR04,        
            CELLCOLOR TYPE LVC_T_SCOL,"单元格颜色
          END OF TYP_01.
    DATA IS_CELLCOLOR TYPE LVC_S_SCOL.
    DATA GT_01 TYPE STANDARD TABLE OF TYP_01 WITH HEADER LINE .
    DATA IT_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE .
    DATA IS_LAYOUT TYPE LVC_S_LAYO.
    
    DEFINE FIELDCAT.
      IT_FIELDCAT-COL_POS = &1.
      IT_FIELDCAT-FIELDNAME = &2.
      IT_FIELDCAT-SCRTEXT_L = &3.
      APPEND IT_FIELDCAT.
    END-OF-DEFINITION.
    
    START-OF-SELECTION.
      SELECT MARA~MATNR MARA~ERNAM MARA~ERSDA
        FROM MARA
        INTO CORRESPONDING FIELDS OF TABLE GT_01.
    
    END-OF-SELECTION.
      FIELDCAT '1' 'MATNR' 'MATNR'.
      LOOP AT IT_FIELDCAT.
        IF IT_FIELDCAT-FIELDNAME = 'MATNR'.
          IT_FIELDCAT-EMPHASIZE = 'C710'.
          MODIFY IT_FIELDCAT.
          CLEAR IT_FIELDCAT.
        ENDIF.
      ENDLOOP.
      FIELDCAT '2' 'ERNAM' 'ERNAM'.
      FIELDCAT '3' 'ERSDA' 'ERSDA'.
    
      LOOP AT GT_01.
      IF GT_01-MATNR = '000000000000000097'.
      GT_01-COLOR = 'C610'.
      MODIFY gt_01.
      CLEAR GT_01.
      ENDIF.
      IF GT_01-MATNR = '000000000000000129'.
      GT_01-COLOR = 'C510'.
      MODIFY GT_01.
      CLEAR GT_01.
      ENDIF.
      IF  GT_01-MATNR = '000000000000000153'.
      IS_CELLCOLOR-FNAME = 'MATNR'.
     "物料编号为‘153’的行的‘MATNR’字段颜色为 黄色
      IS_CELLCOLOR-COLOR-COL = 3.
      IS_CELLCOLOR-COLOR-INT = 1.
      IS_CELLCOLOR-COLOR-INV = 0.
      APPEND IS_CELLCOLOR TO GT_01-CELLCOLOR.
      MODIFY GT_01.
      CLEAR GT_01.
      ENDIF.
    
      ENDLOOP.
    
      IS_LAYOUT-CWIDTH_OPT = 'X'.
      IS_LAYOUT-INFO_FNAME = 'COLOR'.
      IS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'. "单元格颜色内表字段
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
         I_CALLBACK_PROGRAM                = SY-CPROG
          IS_LAYOUT_LVC   = IS_LAYOUT
          IT_FIELDCAT_LVC = IT_FIELDCAT[]
    
        TABLES
          T_OUTTAB        = GT_01[].
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
      .
      IF SY-SUBRC <> 0.
    * Implement suitable error handling here
      ENDIF.

    运行结果:

  • 相关阅读:
    <四>ASP.NETCORE 控制器(controller) 和过滤器(filter)
    <二>Asp.netcore MVC 模型(Model)
    <一>领域驱动设计
    <一>Asp.netcore MVC 路由及URL生成
    sql优化技巧之 not in 改 left join
    <三>Asp.netcore MVC 视图(View)
    <一>Thread 线程基础
    [转]mysql 启动失败:su: warning: cannot change directory to /nonexistent: No such file or directory
    NuGet修改packages目录/迁移缓存文件夹
    ORA00933: SQL 命令未正确结束
  • 原文地址:https://www.cnblogs.com/xggnb/p/11977443.html
Copyright © 2020-2023  润新知