1、简单的CL_SALV_TABLE 的使用
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_table->display( ).
运行结果

2、使用CL_SALV_FUNCTIONS添加工具栏(注意添加的红色代码)
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).

gr_table->display( ).
运行结果

3、使用CL_SALV_DISPLAY_SETTINGS(注意添加的红色代码)
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_table->display( ).

4、使用CL_SALV_COLUMNS_TABLE和CL_SALV_COLUMN_TABLE(注意添加的红色代码)
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.

data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).

gr_table->display( ).

5、使用CL_SALV_SORTS(注意添加的红色代码),增加排序
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.

data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->ADD_SORT( 'CITYTO' ).

gr_table->display( ).

6、使用CL_SALV_AGGREGATIONS(注意添加的红色代码),增加汇总
将DISTANCE字段按CITYTO字段进行汇总
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.

data: color type lvc_s_colo.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
* gr_sorts->ADD_SORT( 'CITYTO' ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
gr_table->display( ).

7、使用CL_SALV_FILTERS(注意添加的红色代码),增加过滤
只显示CARRID等于'LH'
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_filter type ref to cl_salv_filters.

data: color type lvc_s_colo.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
* gr_sorts->ADD_SORT( 'CITYTO' ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
gr_filter = gr_table->get_filters( ). 
gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ).
gr_table->display( ).

8、使用CL_SALV_LAYOUT(注意添加的红色代码),增加变式保存
*&---------------------------------------------------------------------*
*& Report ZTEST4
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_filter type ref to cl_salv_filters.
data: gr_layout type ref to cl_salv_layout.

data: key type salv_s_layout_key.
data: color type lvc_s_colo.

start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
* gr_sorts->ADD_SORT( 'CITYTO' ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
gr_filter = gr_table->get_filters( ).
gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ).
gr_layout = gr_table->get_layout( ).
key-report = sy-repid.
gr_layout->set_key( key ).
gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
gr_table->display( ).

转载于:https://www.cnblogs.com/eric0701/p/4228730.html

cl_salv_table相关推荐

  1. 运用类CL_SALV_TABLE实现alv

    以前一直运用container的方式来显示alv,现在介绍一种不太常用的方法来显示alv,希望可以提供一种新的思路.但是一直没有找到怎样运用此方法在Toolbar上增加一个按钮,或者响应某些事件. R ...

  2. SAP_ALV(CL_SALV_TABLE)

    *参照サイト:https://blog.csdn.net/sap_jack/article/details/1816907 *ALV表示のみの場合.使う. *メリット:①ALV構造の作成は不要 ②コー ...

  3. O_ALV CL_SALV_TABLE, ALV 类的用法

    ALV详解:OO SALV OOSALV OOSALV 在Net Weaver2004平台上集合了利用函数和GRID的功能发布的SALV包程序(SALV也称为New ALV). SALV可以像使用函数 ...

  4. 【ABAP】OO ALV 概述

    •OO ALV,是指通过面向对象(Object-Oriented)的方式实现的ALV输出 •基本使用原理: –通过界面调用,在界面的Customer Control控件中,输出ALV •CLASS A ...

  5. 销售单据条件价格明细表

    REPORT ZSDR_DDFYCX   NO  STANDARD  PAGE HEADING . TABLES :VBAK ,        LIKP ,        VBUK ,         ...

  6. 弹出ALV的几种方法(ALV POPUP)

    ***方法1 DATA: go_alv    TYPE REF TO cl_salv_table, go_funlst TYPE REF TO cl_salv_functions_list. DATA ...

  7. 超级实用的列表提示错误一览显示框

    REPORT ZTEST_DIS_ERROR . *介绍:弹出错误的显示框 DATA : GT_BAPIRET  TYPE  STANDARD  TABLE  OF BAPIRET2 ,        ...

  8. OO实现ALV TABLE 五:ALV的栏位属性

    ALV的栏位属性是SAP提供的ALV功能的比较重要的一个,详细的功能包括异常状态图标.图标.符号.复选框.按钮.热点.超链接.单元格类型.单元格颜色.某一栏位颜色.某一行颜色,栏位隐藏等等.ALV的栏 ...

  9. OO实现ALV TABLE 一:最简单的ALV显示

    以前都是通过函数"REUSE_ALV_GRID_DISPLAY"来显示列表,这种方式是面向过程的,现在有另外一种面向对象化的方式来显示列表,函数REUSE_ALV_GRID_DIS ...

  10. OO实现ALV TABLE 二:ALV显示的三种形式

    一般的ALV有三种显示形式,分别为 一.普通的List 二.全屏的Grid 三.在自定义屏幕的显示的Grid 跟以往实现这三种ALV显示方式相比,以往的三种显示方式分别是调用不同的Function和C ...

最新文章

  1. VS2010 连接SQLSERVER数据库步骤
  2. linux用echo重定向到文件,Linux – Bash将String重定向到文件
  3. 从Delegate.CreateDelegate看值类型的实例方法
  4. 回调函数总结(个人见解)
  5. wxpython播放视频_opencv视屏流嵌入wxpython框架
  6. saltstack minion端状态监控程序
  7. linux下无法正常打开pdf文件的解决方法
  8. python中的as是什么意思_python中as用法实例分析
  9. web环境下的图像打印组件
  10. adb连接 vivo_vivo手机驱动
  11. 做量化投研必须掌握的三大基本模型理论
  12. ZedGraph绘图
  13. 社科研究方法汇总(含SPSS教程、Maxdea、实验法、社会网络分析法、统计调查法、访谈法)
  14. 全景图如何上传至百度地图?
  15. Codeforces 1102F Elongated Matrix——状压dp
  16. Blender摄像机环绕运动、动画渲染、视频合成
  17. BLDC电机中的死区时间究竟是什么?
  18. fstream用法总结
  19. AndroidStudio0.5.5发布
  20. win10录屏快捷键?电脑技能操作看这里!

热门文章

  1. Mac基础操作:在双显示器设置中将Dock保持在一个屏幕上以防止其移动的方法
  2. 在Mac上将WebP图像批量转换为JPG的方法
  3. 教你如何保持Tuxera NTFS For Mac软件的更新
  4. Netty NioEventLoop 启动过程源码分析
  5. 【对讲机的那点事】维修对讲机你会拆卸电路板上的集成电路块吗?
  6. 如何应用Java的静态内部类
  7. 让你口水不停的最新台湾美食推荐
  8. 关于ie7下display:inline-block;不支持的解决方案。
  9. 纠结的链接——ln、ln -s、fs.symlink、require
  10. 【python游戏编程之旅】第一篇---初识pygame