怎样在屏幕上显示多个alv
本文解说怎样在屏幕上显示多个alv.
实现这种需求关键是下面几点(举例:在屏幕上显示4个alv):
1.须要定义4个alv control
2.由于有4个alv control,于是就须要定义4个容器装这4个控件
3.为了合理布局这4个容器,就要将这4个容器嵌入另外一个splitter 容器中
4.可是splitter容器又仅仅能置入其它容器中,那么就须要再定义一个容器
总之,须要3层容器和1层控件,总共要定义6个容器和4个控件
5.最里面的容器应该是cl_gui_custom_container类型。基于屏幕容器区域创建该容器
6.再在最底层容器里面嵌入splitter 容器
7.依据splitter容器创建4个镶嵌在其内的alv容器
8.再在alv容器中创建alv控件
9.调用alv的方法现实内表数据
下面是屏幕上显示4个alv的实例:
主程序代码:
TYPE-POOLS: slis, icon.
TABLES: sflight, spfli, scarr, sbook.
* Define okcode
DATA: ok_code TYPE sy-ucomm.
* Define objects used in screen
DATA: go_split_container TYPE REF TO cl_gui_splitter_container.
DATA: go_container TYPE REF TO cl_gui_custom_container.
DATA: go_container1 TYPE REF TO cl_gui_container.
DATA: go_container2 TYPE REF TO cl_gui_container.
DATA: go_container3 TYPE REF TO cl_gui_container.
DATA: go_container4 TYPE REF TO cl_gui_container.
DATA: go_alv_control1 TYPE REF TO cl_gui_alv_grid.
DATA: go_alv_control2 TYPE REF TO cl_gui_alv_grid.
DATA: go_alv_control3 TYPE REF TO cl_gui_alv_grid.
DATA: go_alv_control4 TYPE REF TO cl_gui_alv_grid.
* Define internal tables and structures
DATA: BEGIN OF gs_sflight,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
fldate TYPE sflight-fldate,
price TYPE sflight-price,
END OF gs_sflight.
DATA: BEGIN OF gs_spfli,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF gs_spfli.
DATA: BEGIN OF gs_scarr,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
END OF gs_scarr.
DATA: BEGIN OF gs_sbook,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
bookid TYPE sbook-bookid,
customid TYPE sbook-customid,
END OF gs_sbook.
* Define alv components
DATA: gs_field_cat1 TYPE lvc_s_fcat.
DATA: gs_field_cat2 TYPE lvc_s_fcat.
DATA: gs_field_cat3 TYPE lvc_s_fcat.
DATA: gs_field_cat4 TYPE lvc_s_fcat.
DATA: gt_field_cat1 TYPE lvc_t_fcat.
DATA: gt_field_cat2 TYPE lvc_t_fcat.
DATA: gt_field_cat3 TYPE lvc_t_fcat.
DATA: gt_field_cat4 TYPE lvc_t_fcat.
* Define displayed data
DATA: gt_sflight LIKE STANDARD TABLE OF gs_sflight,
gt_spfli LIKE STANDARD TABLE OF gs_spfli,
gt_scarr LIKE STANDARD TABLE OF gs_scarr,
gt_sbook LIKE STANDARD TABLE OF gs_sbook.
START-OF-SELECTION.
PERFORM sub_retrieve_data.
PERFORM sub_alv_data.
CALL SCREEN 9100.
*&---------------------------------------------------------------------*
*& Form SUB_RETRIEVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM sub_retrieve_data .
SELECT
carrid
connid
fldate
price
INTO CORRESPONDING FIELDS OF TABLE gt_sflight
FROM sflight.
SELECT
carrid
connid
cityfrom
cityto
INTO CORRESPONDING FIELDS OF TABLE gt_spfli
FROM spfli.
SELECT
carrid
carrname
INTO CORRESPONDING FIELDS OF TABLE gt_scarr
FROM scarr.
SELECT
carrid
connid
bookid
customid
INTO CORRESPONDING FIELDS OF TABLE gt_sbook
FROM sbook.
ENDFORM. " SUB_RETRIEVE_DATA
*&---------------------------------------------------------------------*
*& Form SUB_ALV_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_alv_data .
* Build field catelog 1
gs_field_cat1-col_pos = 1.
gs_field_cat1-fieldname = 'CARRID'.
gs_field_cat1-scrtext_m = 'airline code'.
APPEND gs_field_cat1 TO gt_field_cat1.
gs_field_cat1-col_pos = 2.
gs_field_cat1-fieldname = 'CONNID'.
gs_field_cat1-scrtext_m = 'connection number'.
APPEND gs_field_cat1 TO gt_field_cat1.
gs_field_cat1-col_pos = 3.
gs_field_cat1-fieldname = 'FLDATE'.
gs_field_cat1-scrtext_m = 'flight date'.
APPEND gs_field_cat1 TO gt_field_cat1.
gs_field_cat1-col_pos = 4.
gs_field_cat1-fieldname = 'PRICE'.
gs_field_cat1-scrtext_m = 'flight price'.
APPEND gs_field_cat1 TO gt_field_cat1.
* Build field catelog 2
gs_field_cat2-col_pos = 1.
gs_field_cat2-fieldname = 'CARRID'.
gs_field_cat2-scrtext_m = 'airline code'.
APPEND gs_field_cat2 TO gt_field_cat2.
gs_field_cat2-col_pos = 2.
gs_field_cat2-fieldname = 'CONNID'.
gs_field_cat2-scrtext_m = 'connection number'.
APPEND gs_field_cat2 TO gt_field_cat2.
gs_field_cat2-col_pos = 3.
gs_field_cat2-fieldname = 'CITYFROM'.
gs_field_cat2-scrtext_m = 'city from'.
APPEND gs_field_cat2 TO gt_field_cat2.
gs_field_cat2-col_pos = 4.
gs_field_cat2-fieldname = 'CITYTO'.
gs_field_cat2-scrtext_m = 'city to'.
APPEND gs_field_cat2 TO gt_field_cat2.
* Build field catelog 3
gs_field_cat3-col_pos = 1.
gs_field_cat3-fieldname = 'CARRID'.
gs_field_cat3-scrtext_m = 'airline code'.
APPEND gs_field_cat3 TO gt_field_cat3.
gs_field_cat3-col_pos = 2.
gs_field_cat3-fieldname = 'CONNID'.
gs_field_cat3-scrtext_m = 'connection number'.
APPEND gs_field_cat3 TO gt_field_cat3.
* Build field catelog 4
gs_field_cat4-col_pos = 1.
gs_field_cat4-fieldname = 'CARRID'.
gs_field_cat4-scrtext_m = 'airline code'.
APPEND gs_field_cat4 TO gt_field_cat4.
gs_field_cat4-col_pos = 2.
gs_field_cat4-fieldname = 'CONNID'.
gs_field_cat4-scrtext_m = 'connection number'.
APPEND gs_field_cat4 TO gt_field_cat4.
gs_field_cat4-col_pos = 3.
gs_field_cat4-fieldname = 'BOOKID'.
gs_field_cat4-scrtext_m = 'book id'.
APPEND gs_field_cat4 TO gt_field_cat4.
gs_field_cat4-col_pos = 4.
gs_field_cat4-fieldname = 'CUSTOMID'.
gs_field_cat4-scrtext_m = 'custom id'.
APPEND gs_field_cat4 TO gt_field_cat4.
ENDFORM. " SUB_ALV_DATA
*&---------------------------------------------------------------------*
*& Module ALV_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE alv_display OUTPUT.
IF go_split_container IS INITIAL.
CREATE OBJECT go_container
EXPORTING
container_name = 'GO_CONTAINER'.
CREATE OBJECT go_split_container
EXPORTING
link_dynnr = sy-dynnr
link_repid = sy-repid
parent = go_container
rows = 2
columns = 2
name = 'GO_SPLIT_CONTAINER'.
CALL METHOD go_split_container->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_container1.
CALL METHOD go_split_container->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_container2.
CALL METHOD go_split_container->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_container3.
CALL METHOD go_split_container->get_container
EXPORTING
row = 2
column = 2
RECEIVING
container = go_container4.
CREATE OBJECT go_alv_control1
EXPORTING
i_parent = go_container1.
CREATE OBJECT go_alv_control2
EXPORTING
i_parent = go_container2.
CREATE OBJECT go_alv_control3
EXPORTING
i_parent = go_container3.
CREATE OBJECT go_alv_control4
EXPORTING
i_parent = go_container4.
CALL METHOD go_alv_control1->set_table_for_first_display
CHANGING
it_outtab = gt_sflight
it_fieldcatalog = gt_field_cat1.
CALL METHOD go_alv_control2->set_table_for_first_display
CHANGING
it_outtab = gt_spfli
it_fieldcatalog = gt_field_cat2.
CALL METHOD go_alv_control3->set_table_for_first_display
CHANGING
it_outtab = gt_scarr
it_fieldcatalog = gt_field_cat3.
CALL METHOD go_alv_control4->set_table_for_first_display
CHANGING
it_outtab = gt_sbook
it_fieldcatalog = gt_field_cat4.
ELSE.
CALL METHOD go_alv_control1->refresh_table_display.
CALL METHOD go_alv_control2->refresh_table_display.
CALL METHOD go_alv_control3->refresh_table_display.
CALL METHOD go_alv_control4->refresh_table_display.
ENDIF.
ENDMODULE. " ALV_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_9100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9100 OUTPUT.
SET PF-STATUS 'STATUS9100'.
ENDMODULE. " STATUS_9100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9100 INPUT.
CASE ok_code.
WHEN 'PBAK'.
CALL METHOD go_alv_control1->free.
CALL METHOD go_alv_control2->free.
CALL METHOD go_alv_control3->free.
CALL METHOD go_alv_control4->free.
CALL METHOD go_container1->free.
CALL METHOD go_container2->free.
CALL METHOD go_container3->free.
CALL METHOD go_container4->free.
CALL METHOD go_split_container->free.
CALL METHOD go_container->free.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9100 INPUT
屏幕9100中的代码:
PROCESS BEFORE OUTPUT.
MODULE status_9100.
MODULE alv_display.
PROCESS AFTER INPUT.
MODULE user_command_9100.
怎样在屏幕上显示多个alv的更多相关文章
- 在屏幕上显示C盘根目录下的所有文件和文件夹
1 import java.io.File; //在屏幕上显示C盘根目录下的所有文件和文件夹 public class ListDemo { public static void main(Strin ...
- linux tail-在屏幕上显示指定文件的末尾若干行
博主推荐:获取更多 linux文件内容查看命令 收藏:linux命令大全 tail命令用于输入文件中的尾部内容.tail命令默认在屏幕上显示指定文件的末尾10行.如果给定的文件不止一个,则在显示的每个 ...
- Droid@screen:在PC屏幕上显示Android手机屏幕
这里介绍一款工具——Droid@screen,用来获取手机屏幕,显示在PC屏幕上.它集截图.录像等多种功能于一体. 安装 1. 下载地址:http://droid-at-screen.org/d ...
- 【opengl】OpenGL中三维物体显示在二维屏幕上显示的变换过程
转自:http://blog.sina.com.cn/s/blog_957b9fdb0100zesv.html 为了说明在三维物体到二维图象之间,需要经过什么样的变换,我们引入了相机(Camera)模 ...
- iOS开发中获取视图在屏幕上显示的位置
在iOS开发中,我们会经常遇到一个问题,例如,点击一个按钮,弹出一个遮罩层,上面显示一个弹框,弹框显示的位置在按钮附近.如果这个按钮的位置相对于屏幕边缘的距离是固定的,那就容易了,可以直接写死位置.可 ...
- ProgressDialog(三)——代号为中心的屏幕上显示ProgressDialog(ProgressBar)
MainActivity如下面: package cc.testprogressdialog; import android.os.Bundle; import android.view.Gravit ...
- ABAP 在屏幕上显示图片
1.se78 上传 或 预览图片 图片预览 2.程序代码 定义各变量 DATA: H_PICTURE TYPE REF TO CL_GUI_PICTURE, H_PIC_CONTAINER TYPE ...
- Flash3D学习计划(三)——学习VB,IB相关,理解三角形顶点顺序;在屏幕上显示2D矩形,并实现缩放,平移,旋转
VB:顶点缓冲 IB: 顶点索引缓冲 三角形的顶点顺序决定了三角形是顺时针还是逆时针,从而决定了三角形在背面剔除的过程中是否会被剔除掉. 相关理论知识可以在前面的文章中找到更多的说明. 实现效果 sf ...
- [SimplePlayer] 2. 在屏幕上显示视频图像
我们这里采用SDL(本文所用版本为SDL2.0.5)来进行图像输出,SDL在进行图像渲染时一般采用的会是direct3D或者opengl,SDL对它们进行了封装,不过我们这里只讨论SDL的使用,并不会 ...
随机推荐
- android 5.0新特性
Android Lollipop 面向开发人员的主要功能 Material Design 设计 注重性能 通知 以大屏幕呈现 以文档为中心 连接性能再上一级 高性能图形 音频处理功能更强 摄像头和视频 ...
- setOnClickListener报空指针异常
1.异常提示: 2.错误原因: 先看代码: public class MainActivity extends ActionBarActivity { private Button btn_test; ...
- 关于Delphi XE2的FMX的一点点研究之消息篇
Delphi XE2出来了一阵子了,里面比较抢眼的东西,除了VCLStyle这个换肤的东西之外,另外最让人眼亮的应该是FMX这个东西了.万一的博客上都连载了一票的关于FMX的使用心得了.我还是没咋去关 ...
- Java线程并发中常见的锁--自旋锁 偏向锁
随着互联网的蓬勃发展,越来越多的互联网企业面临着用户量膨胀而带来的并发安全问题.本文着重介绍了在java并发中常见的几种锁机制. 1.偏向锁 偏向锁是JDK1.6提出来的一种锁优化的机制.其核心的思想 ...
- Java实现定时任务的三种方法(转)
在应用里经常都有用到在后台跑定时任务的需求.举个例子,比如需要在服务后台跑一个定时任务来进行非实时计算,清除临时数据.文件等.在本文里,我会给大家介绍3种不同的实现方法: 普通thread实现 Tim ...
- 在SharePoint 2010中部署RBS (转)
一.RBS(Remote BLOB Storage)简单介绍 在SharePoint的大部分企业应用案例中,SharePoint都是要承担着非常繁重的文件管理工作,这些文件类型包含了Word文档,Ex ...
- 高级Bash脚本编程指南(27):文本处理命令(三)
高级Bash脚本编程指南(27):文本处理命令(三) 成于坚持,败于止步 处理文本和文本文件的命令 tr 字符转换过滤器. 必须使用引用或中括号, 这样做才是合理的. 引用可以阻止shell重新解释出 ...
- [Android学习笔记]扩展application
扩展Application对象 每一个应用程序启动之后,都会分配一个linux用户,并且运行在一个独立的进程中.默认情况下,一个应用程序只会运行在一个进程中(可以通过配置android:process ...
- GitHub上最受欢迎的Android开源项目TOP20
以下这些开源项目都是从GitHub上筛选的,我强烈推荐android程序源代码有时间的时候自己在上面淘淘,或许能发现自己须要的开源程序. 了解开源项目有两个优点: 1.借鉴代码,一般来说.火爆的开源项 ...
- uva--562Dividing coins +dp
题意: 给定一堆硬币,然后将他们分成两部分,使得两部分的差值最小;输出这个最小的差值. 思路: 想了好久都没想到一个合适的状态转移方程.后面看了别人的题解后,才知道能够转成背包问题求解. 我们将全部的 ...