如何在屏幕上显示多个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.

时间: 2024-10-13 22:15:47

如何在屏幕上显示多个alv的相关文章

怎样在屏幕上显示多个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_containe

在屏幕上显示日志的Android类库

Galgo是Android日志类库,用于在屏幕上显示应用的日志信息.这对于测试人员和开发人员非常有用,可以根据屏幕上的日志文件了解应用出现BUG时发生的事情. 可以定义屏幕上显示日志的背景颜色.文本颜色.文本大小和日志显示的行数. https://github.com/inaka/galgo public class ExampleActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceS

46.编写程序在屏幕上显示如下图形

1 2 3 4 55 1 2 3 44 5 1 2 33 4 5 1 2 2 3 4 5 1 (1)运用循环嵌套,并设置中间变量转换 //1.新建一个数组//2.输入内容并存储//3.输出结果 #include<iostream> using namespace std; int main() { int temp; int a[5]={1,2,3,4,5}; for(int m=0;m<5;m++) { cout<<a[m]<<" "; }

汇编一点点提高3——键盘输入8位二进制数,存入NUM单元,并在屏幕上显示对应的16进制数

此程序要注意一下几点: 1.dos1号功能--带回显的键盘输入,自动存入al 2.dos7号功能--不带回显的键盘输入,自动存入al,若要在屏幕中显示要调用DOS2号功能 3.将输入的多个二进制数转换为ASCII码 input:  mov ah,1  int 21h  add bl,bl  cmp al,'1'  jnz P1  inc bl  P1: dec ch  jnz input 4.换行子程序: newline: mov ah,2 mov dl,13 int 21h mov ah,2

01_SDL_在屏幕上显示一张图片

#include "SDL/SDL.h" #include <string> //屏幕属性 const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int SCREEN_BPP = 32; //能被使用到的面 SDL_Surface *message = NULL; SDL_Surface *background = NULL; SDL_Surface *screen = NULL; SDL_Su

[email&#160;protected]:在PC屏幕上显示Android手机屏幕

这里介绍一款工具——[email protected],用来获取手机屏幕,显示在PC屏幕上.它集截图.录像等多种功能于一体. 安装 1.    下载地址:http://droid-at-screen.org/download.html,下载后是一个jar包,放到某个目录就可以. 2.    安装JDK6或以上版本 3.    安装Android SDK(从Android官方下载一个完整包解压即可) 4.    设置ANDROID_HOME环境变量指向AndroidSDK主目录(这步如果不做,则需

iOS开发中获取视图在屏幕上显示的位置

在iOS开发中,我们会经常遇到一个问题,例如,点击一个按钮,弹出一个遮罩层,上面显示一个弹框,弹框显示的位置在按钮附近.如果这个按钮的位置相对于屏幕边缘的距离是固定的,那就容易了,可以直接写死位置.可是,如果按钮是在UITableView的cell上呢?随着UITableView的滚动,按钮可能在顶部,也可能在底部,还可能在中间,左侧.右侧都有可能,那么,这个时候,怎么去计算按钮所在的位置呢?如果按钮所在的UITabelView是在另外一个UIScrollView的一个cell上呢?如果外面再有

十五、在屏幕上显示字符

显示字符需要先实现绘点功能,然后用取模工具对需要显示的字符取模,我用的取模工具为PCtoLCD2002,设置如下图: 封装的函数最好比较容易使用,最好能选择字体,具体细节再此不详述,直接附上程序. draw.c 1 #include <stdio.h> 2 #include <linux/fb.h> 3 #include <sys/types.h> 4 #include <sys/stat.h> 5 #include <fcntl.h> 6 #i

在屏幕上显示日期时间星期的方法

一个获取当前时间的类: 1 import android.annotation.SuppressLint; 2 import android.os.Handler; 3 import android.os.Message; 4 import android.util.Log; 5 import android.widget.TextView; 6 7 import com.acmeinte.idl.sample.common.Constants; 8 import com.acmeinte.id