控制alv中layout保存及搜索帮助

问题

今天有user反映希望程序alv结果可以保存layout,但save layout按钮为灰色。程序实现alv方法为CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’。

原因

经debug发现’REUSE_ALV_GRID_DISPLAY’中参数i_save值为空值space。
i_save参数官方介绍如下:

’ ’ = Display variants cannot be saved     (不能保存)
Defined display variants (such as delivered display variants) can be selected for presentation regardless of this indicator. However, changes cannot be saved.

’X’ = Standard save mode          (全局布局可以保存)
Display variants can be saved as standard display variants.
Saving display variants as user-specific is not possible.

’U’ = User-specific save mode        (用户自定义布局可以保存)
Display variants can only be saved as user-specific.

’A’ = Standard and user-specific save mode (全局和用户自定义布局都可以保存)
Display variants can be saved both as user-specific and as standard
variants. Users make their choice on the dialog box for saving the
display variant.

解决办法

将i_save值写死赋值为A,测试后发现可以保存layout,选择屏幕layout输入框需要做F4帮助,方便user直接选择自己layout并保存variant。

以下为与layout相关部分代码,wk_vari为选择屏幕上layout输入框。

DATA : variante        LIKE disvariant,
       def_variante    LIKE disvariant,
       variant_exit(1) TYPE c,
       variant_save(1) TYPE c.

PARAMETERS:   wk_vari LIKE disvariant-variant.

INITIALIZATION.

  variant_save = 'A'.
  CLEAR variante.
  variante-report = sy-repid.
  def_variante    = variante.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save        = variant_save
    CHANGING
      cs_variant    = def_variante
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.

  IF sy-subrc = 0.
    wk_vari = def_variante-variant.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR wk_vari.

  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant    = variante
      i_save        = variant_save
    IMPORTING
      e_exit        = variant_exit
      es_variant    = def_variante
    EXCEPTIONS
      not_found     = 1
      program_error = 2
      OTHERS       = 3.
  IF sy-subrc = 2.
    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF variant_exit = space.
        wk_vari = def_variante-variant.
    ENDIF.
  ENDIF.

AT SELECTION-SCREEN.
  
  IF NOT wk_vari IS INITIAL.
    MOVE variante TO def_variante.
    MOVE wk_vari TO def_variante-variant.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
      EXPORTING
        i_save     = variant_save
      CHANGING
        cs_variant = def_variante.
        variante   = def_variante.
  ELSE.
    CLEAR variante.
    variante-report = sy-repid.
  ENDIF.
  
  "调用alv函数时赋值i_save、is_variant参数即可
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_interface_check  = ''
      i_callback_program = sy-repid
      it_fieldcat        = xfieldcat[]
      i_default          = 'X'
      i_save             = variant_save
      is_layout          = layout
      is_variant         = variante
    TABLES
      t_outtab           = inttab
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

椰子皮不皮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值