红绿灯-DEMO_DYNPRO_STATUS_ICONS

1、定义字段
data: status_icon type icons-text.

2、创建屏幕,并在屏幕定义创建一个"Status Icon"控件 ,命名为:status_icon

3、利用ICON_CREATE函数在输出是设置ICON。
  call function 'ICON_CREATE'
       exporting
            name                  = 'ICON_GREEN_LIGHT'
            text                       = '图标后面显示的文本'
            info                      = '提示'
            add_stdinf            = 'X'
       importing
            result                = status_icon
       exceptions
            icon_not_found        = 1
            outputfield_too_short = 2
            others                = 3.

4、sap的图标可以使用ICON_SHOW函数显示列出
call function 'ICON_SHOW' exporting onlydisplay = 'X'
                          exceptions no_object_found = 1
                                     no_icon_selected = 2.

5、关于图标的样例可参见sap的演示代码:DEMO_DYNPRO_STATUS_ICONS

REPORT demo_dynpro_status_icons.

DATA value TYPE i VALUE 1.

DATA: status_icon TYPE icons-text,
      icon_name(20) TYPE c,
      icon_text(10) TYPE c.

CALL SCREEN 100.

MODULE set_icon OUTPUT.

  SET PF-STATUS 'SCREEN_100'.

  CASE value.
    WHEN 1.
      icon_name = 'ICON_GREEN_LIGHT'.
      icon_text =  text-003.
    WHEN 2.
      icon_name = 'ICON_YELLOW_LIGHT'.
      icon_text =  text-002.
    WHEN 3.
      icon_name = 'ICON_RED_LIGHT'.
      icon_text =  text-001.
  ENDCASE.

  CALL FUNCTION 'ICON_CREATE'
       EXPORTING
            name                  = icon_name
            text                  = icon_text
            info                  = 'Status'
            add_stdinf            = 'X'
       IMPORTING
            result                = status_icon
       EXCEPTIONS
            icon_not_found        = 1
            outputfield_too_short = 2
            OTHERS                = 3.

  CASE sy-subrc.
    WHEN 1.
      MESSAGE e888(sabapdocu) WITH text-004.
    WHEN 2.
      MESSAGE e888(sabapdocu) WITH text-005.
    WHEN 3.
      MESSAGE e888(sabapdocu) WITH text-006.
  ENDCASE.

ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE change.
  CASE value.
    WHEN 1.
      value = 2.
    WHEN 2.
      value = 3.
    WHEN 3.
      value = 1.
  ENDCASE.
ENDMODULE.

你可能感兴趣的:(c,function,object,SAP,icons)