ABAP - SALV教程07 斑马纹显示和SALV标题

  • SALV设置斑马纹和标题
      METHOD set_layout.
        DATA: lo_display TYPE REF TO cl_salv_display_settings.
    *   取得显示对象
        lo_display = co_alv->get_display_settings( ).
    
    *   设置ZEBRA显示
        lo_display->set_striped_pattern( 'X' ).
    *   设置Title
        lo_display->set_list_header( '销售订单报表' ).
      ENDMETHOD.

  • 显示效果 
  • 完整代码 
    CLASS lcl_model DEFINITION.
      PUBLIC SECTION.
        TYPES:BEGIN OF TY_dATA,
                vbeln TYPE vbak-vbeln,
                erdat TYPE erdat,
                erzet TYPE erzet,
                ernam TYPE ernam,
                auart TYPE auart.
        TYPES:END  OF ty_data.
    
        DATA mt_data TYPE TABLE OF ty_data.
    
        DATA mo_salv TYPE REF TO cl_salv_table.
    
        "获取数据的方法
        METHODS get_data.
        "展示SALV的方法
        METHODS alv_show.
    
      PRIVATE SECTION.
        METHODS:
          set_status  CHANGING co_alv TYPE REF TO cl_salv_table.
    
        METHODS:
          set_layout  CHANGING co_alv TYPE REF TO cl_salv_table.
    
    ENDCLASS.
    
    CLASS lcl_model IMPLEMENTATION.
      METHOD get_data.
        SELECT vbeln erdat erzet ernam auart
          INTO TABLE mt_data
          FROM vbak
          UP TO 20 ROWS.
      ENDMETHOD.
    
      METHOD alv_show.
        DATA: lx_msg TYPE REF TO cx_salv_msg.
        TRY.
            cl_salv_table=>factory(
              IMPORTING
                r_salv_table = mo_salv
              CHANGING
                t_table      = mt_data ).
          CATCH cx_salv_msg INTO lx_msg.
        ENDTRY.
        me->set_status( CHANGING co_alv = mo_salv ).
        me->set_layout( CHANGING co_alv = mo_salv ).
        mo_salv->display( ).
      ENDMETHOD.
    
      METHOD set_status.
        DATA(lo_functions) = co_alv->get_functions( ).
        "cl_salv_functions_list类型的实例对象的添加状态方法
        lo_functions->set_all( abap_true ).
        "lo_functions->set_default( abap_true ).
      ENDMETHOD.
    
      METHOD set_layout.
        DATA: lo_display TYPE REF TO cl_salv_display_settings.
    *   取得显示对象
        lo_display = co_alv->get_display_settings( ).
    
    *   设置ZEBRA显示
        lo_display->set_striped_pattern( 'X' ).
    *   设置Title
        lo_display->set_list_header( '销售订单报表' ).
      ENDMETHOD.
    
    ENDCLASS.
    
    START-OF-SELECTION.
      DATA(lo_model) = NEW lcl_model( ).
      lo_model->get_data( ).
      lo_model->alv_show( ).

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值