美文网首页SAP
ABAP更新ALV后自适应列宽

ABAP更新ALV后自适应列宽

作者: JayDragon | 来源:发表于2021-12-25 22:56 被阅读0次

    有些操作会更新ALV的某个字段值,例如消息字段,此时会希望ALV的消息字段会根据内容自动调整列宽:

    FORM frm_user_command USING r_ucomm TYPE sy-ucomm
                                rs_selfield TYPE slis_selfield.
    
      DATA: lr_grid   TYPE REF TO cl_gui_alv_grid,
            ls_layout TYPE lvc_s_layo.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = lr_grid.
      CASE r_ucomm.
        WHEN 'ZCANCEL'.
          PERFORM frm_cancel.
        WHEN 'ZSAVE'.
          PERFORM frm_save.
      ENDCASE.
      CALL METHOD lr_grid->get_frontend_layout
        IMPORTING
          es_layout = ls_layout.
      ls_layout-cwidth_opt = 'X'.    "最优宽
      CALL METHOD lr_grid->set_frontend_layout
        EXPORTING
          is_layout = ls_layout.
      CALL METHOD lr_grid->check_changed_data.
      rs_selfield-refresh = 'X' .
    ENDFORM. "FRM_USER_COMMAND
    

    相关文章

      网友评论

        本文标题:ABAP更新ALV后自适应列宽

        本文链接:https://www.haomeiwen.com/subject/ndujqrtx.html