sap alv 添加状态灯

Posted jackeylove

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sap alv 添加状态灯相关的知识,希望对你有一定的参考价值。

*&---------------------------------------------------------------------*
INCLUDE <icon>.
TYPES:BEGIN OF ty_out,
        seq     TYPE char6,      "序号
        werks   TYPE marc-werks, "工厂
        matnr   TYPE marc-matnr, "物料号
        maktx   TYPE makt-maktx, "物料描述
        ersda   TYPE mara-ersda, "创建时间
        mtart   TYPE mara-mtart, "物料类型
        beskz   TYPE marc-beskz, "采购类型
        sobsl   TYPE marc-sobsl, "特殊采购类型
        flag1   TYPE char1,      "外购件计划价
        flag2   TYPE char1,      "自制件BOM
        andat   TYPE mast-andat, "BOM创建时间
        flag3   TYPE char1,      "自制件工艺路线
        andat_p TYPE plko-andat, "工艺路线创建时间
        flag4   TYPE char1,      "自制件工时
        flag5   TYPE char1,      "自制件成本核算状态
        cpudt   TYPE keko-cpudt, "自制件成本核算时间
        status  TYPE char1,      "状态
        light   TYPE icons-text,      " 红绿灯
        descr   TYPE char40,     "状态说明
      END OF ty_out.
DATA:gt_out TYPE TABLE OF ty_out,
     gs_out TYPE ty_out.


*&---------------------------------------------------------------------*
*&                FRM_CREATE_ICON
*&---------------------------------------------------------------------*
FORM frm_create_icon USING i_coname TYPE string
                     CHANGING c_out TYPE icons-text.

*WRITE: ICON_GREEN_LIGHT AS ICON.
*WRITE: ICON_YELLOW_LIGHT AS ICON.
*WRITE: ICON_RED_LIGHT AS ICON.
  CALL FUNCTION ICON_CREATE
    EXPORTING
      name                  = i_coname
      add_stdinf            = X
    IMPORTING
      result                = c_out
    EXCEPTIONS
      icon_not_found        = 1
      outputfield_too_short = 2
      OTHERS                = 3.
ENDFORM.

loop at gt_out ASSIGNING FIELD-SYMBOL(<lfs_out>).
    IF <lfs_out>-status = R.
      PERFORM frm_create_icon USING ICON_RED_LIGHT
                               CHANGING    <lfs_out>-light.
    ELSE.
      PERFORM frm_create_icon USING ICON_GREEN_LIGHT
                               CHANGING    <lfs_out>-light.
    ENDIF.
  ENDLOOP.

 

以上是关于sap alv 添加状态灯的主要内容,如果未能解决你的问题,请参考以下文章

sap alv显示问题

八十八SAP中ALV事件之二,事件的定义和事件子例程

原创:SAP LVC ALV编辑小技巧

一百一十一SAP的OO-ALV之五,显示ALV表格

八十三SAP中的ALV创建之二,ALV相关的类型池定义

sap alv字段当满足条件变灰