• 在ALV 上控制不同的颜色和加复选框这样的按钮


    很多时候根据开发说明书的要求,要在ALV上实现不同颜色的控制和加复选框标识等:

    1、定义ALV内表:

    DATA: BEGIN OF lt_alv OCCURS 0,
      flag(1),
      aufnr LIKE afko-aufnr,"生产订单编号
      matnr LIKE afpo-matnr,"物料编码
      maktx LIKE makt-maktx,"物料名称
      psmng LIKE afpo-psmng,"数量
      vornr LIKE afvc-vornr,"工序编号
      ltxa1 LIKE afvc-ltxa1,"工序描述
      ism01 LIKE afru-ism01,"完工工时(已确认)
      vgw01 LIKE afvv-vgw01,"额定工时(待确认)
      loekz(3),"订单状态
      color(4) TYPE c,
      checkbox(1),
      END OF lt_alv.

    2、给内表字段赋需要的颜色和值:

      LOOP AT lt_alv.
        IF lt_alv-vgw01 = 0.
          lt_alv-color = 'C710'.
          lt_alv-checkbox = 'X'.
        ELSEIF lt_alv-loekz = '已删除'.
          lt_alv-color = 'C710'.
          lt_alv-checkbox = 'X'.
        ELSEIF lt_alv-vgw01 = lt_alv-ism01.
          lt_alv-color = 'C710'.
          lt_alv-checkbox = 'X'.
        ENDIF.
        MODIFY lt_alv.
      ENDLOOP.

    3、ALV里的定义,和宏里面位置符:

    *&---------------------------------------------------------------------*
    *&      Form  LAYOUT_BUILD
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM layout_build .
      i_layout-box_fieldname        = 'FLAG'.
      i_layout-colwidth_optimize    = 'X'. "优化列宽选项是否设置
      i_layout-zebra                = 'X'.
      i_layout-detail_initial_lines = 'X'.
      i_layout-no_vline             = ''." layout_build
      i_layout-info_fieldname = 'COLOR'."ALV数据行颜色
    ENDFORM.                    " LAYOUT_BUILD
    *&---------------------------------------------------------------------*
    *&      Form  FIELDCAT_INIT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_FIELDCAT[]  text
    *----------------------------------------------------------------------*
    FORM fieldcat_init   USING u_er_fieldcat TYPE slis_t_fieldcat_alv.
    
      DATA: afieldcat TYPE slis_fieldcat_alv,
                pos TYPE i.
      CLEAR pos.
      DEFINE d_get_field.
        pos = pos + 1.
        clear afieldcat.
        afieldcat-col_pos  = pos.
        afieldcat-fieldname  = &1.
        afieldcat-seltext_l = &2.
        afieldcat-key = &3.
        afieldcat-checkbox = &4.
        afieldcat-edit = &5.
    *    if &1 eq 'RLGPRO'.
    *      afieldcat-ref_tabname = 'ZDUMPK'.
    *      afieldcat-ref_fieldname = 'LGPRO'.
    *    endif.
        append afieldcat to u_er_fieldcat.
      END-OF-DEFINITION.
      d_get_field 'AUFNR' '生产订单编码' '' '' ''.
      d_get_field 'MATNR' '物料编码' '' '' ''.
      d_get_field 'MAKTX' '物料名称' '' '' ''.
      d_get_field 'PSMNG' '数量' '' '' ''.
      d_get_field 'VORNR' '工序编号' '' '' ''.
      d_get_field 'LTXA1' '工序描述' '' '' ''.
      d_get_field 'VGW01' '额定工时' '' '' ''.
      d_get_field 'ISM01' '完成工时' '' '' ''.
      d_get_field 'LOEKZ' '订单状态' '' '' ''.
      d_get_field 'CHECKBOX' '不能报工标识' '' 'X' ''.
    ENDFORM.                    " FIELDCAT_INIT

    4、OK!

  • 相关阅读:
    第6章 解决问题 6-1 机器学习解决问题(1)
    第5章 常见的算法和分类 5-2 机器学习常见算法和分类(2)
    Linux中Shell数组的笔记
    Linux中Shell数组的笔记
    Linux中Shell中取消变量和特殊变量的笔记
    Linux中Shell中取消变量和特殊变量的笔记
    Linux实现MYSQl数据库的定时备份
    Linux中su和sudo的用法整理
    Linux用户组笔记整理
    Linux 用户管理命令笔记
  • 原文地址:https://www.cnblogs.com/huangjianisgood/p/2772610.html
Copyright © 2020-2023  润新知