如何同时动态设置按钮工具提示,文本和图标?

时间:2017-11-25 11:30:40

标签: sap abap dynpro

我在模块池屏幕上有一个按钮。我需要根据逻辑/条件动态更改图标,工具提示和文本。我可以成功更改图标和文字,但无法一起更改所有三件事(图标,文字和工具提示)。

样本PBO代码:

Data but(30) type c." here but is the name of button in screen.
write 'icon xxx' as ICON to but.
Concatenate but 'click here' into but separated by space.

它没有设置工具提示的值,它应显示“请点击此处继续”。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

改为使用 ICON_CREATE FM。

以下是如何即时更改所有三个属性的示例:

PARAMETERS: p_icon  TYPE icon_d MATCHCODE OBJECT h_icon,
            p_text  TYPE string,
            p_toolt TYPE string.

SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECTION-SCREEN PUSHBUTTON 49(30) but USER-COMMAND ret.
SELECTION-SCREEN END OF SCREEN 500.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'ONLI'.
       CALL FUNCTION 'ICON_CREATE'
        EXPORTING
          name       = p_icon
          text       = p_text
          info       = p_toolt
          add_stdinf = 'X'
        IMPORTING
          result     = but.
      CALL SELECTION-SCREEN 500.
    WHEN 'RET'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.