[ABAP] Selection Screen 按钮管理

1. 隐藏执行按钮

[ABAP] Selection Screen 按钮管理_第1张图片

initialization.
  data btab type table of sy-ucomm.

  append 'ONLI' to btab.
  call function 'RS_SET_SELSCREEN_STATUS'
    exporting
      p_status  = sy-pfkey
    tables
      p_exclude = btab.

2.添加按钮(Tool Bar)

[ABAP] Selection Screen 按钮管理_第2张图片

tables: sscrfields.


selection-screen begin of line.

  selection-screen function key 1.
  selection-screen function key 2.

selection-screen end of line.

initialization.

  sscrfields-functxt_01 = icon_execute_object.
  sscrfields-functxt_02 = icon_graphics.

3. 添加按钮(Screen)

[ABAP] Selection Screen 按钮管理_第3张图片

selection-screen:
begin of line,

pushbutton 2(10) but01 user-command cli1,

end of line.

完整代码(可执行)


tables: sscrfields.


selection-screen begin of line.

  selection-screen comment 1(5) text-001 for field p1. "starting from 12

  parameters : p1 type matnr. " this will take 10

  selection-screen comment 50(10) lv_icon. "starting from 12

  selection-screen function key 1.
  selection-screen function key 2.




selection-screen end of line.

selection-screen skip 1.

selection-screen:
begin of line,

pushbutton 2(10) but01 user-command cli1,

end of line.


initialization.

  sscrfields-functxt_01 = icon_execute_object.
  sscrfields-functxt_02 = icon_graphics.

  data btab type table of sy-ucomm.

  append 'ONLI' to btab.
  call function 'RS_SET_SELSCREEN_STATUS'
    exporting
      p_status  = sy-pfkey
    tables
      p_exclude = btab.



  if lv_icon = ''.
    lv_icon = icon_led_yellow.
  endif.

  but01 = '测试按钮'.


at selection-screen.

  if sy-ucomm = 'FC01'.
    lv_icon = icon_led_green.
  elseif sy-ucomm = 'FC02'.
    lv_icon = icon_led_red.
  elseif sy-ucomm = 'CLI1'.
    lv_icon = icon_message_warning.
  endif.

你可能感兴趣的:(ABAP,ABAP)