SAP Control framework

引用:翱翔云天

Make you farmiliar with SAP control framework:

Control framework主要包含两个组件:

1. CL_GUI_CFW:

这个类里面主要包含一些静态方法(Static method).

主要组件:

Dispatch:

此方法可以触发application event,如果不调用这个方法,application event会在PAI处理结束后自动调用。

Flush:

此方法用于同步automation queue。

Get_living_dynpro_controls:

返回所有active customer control。

Set_new_ok_code:

设置一个新的Function code.该方法只能用于system event的handler方法,以此可以触发PAI处理,然后我们可以对新的ok_code进行处理。

Get_current_event:

获得当前事件。

2. CL_GUI_OBJECT:

子类:CL_GUI_CONTROL

作用:我觉得最主要的功能是提供一个抽象的接口,里面的方法很少使用。

1. CL_GUI_CONTROL

这个就是我们主要要使用的超类了,先看一下它的子类:

CL_GUI_CONTROL

|_ CL_ALV_TREE_BASE

|_ CL_GUI_ALV_TREE

|_ CL_GUI_ALV_TREE_SIMPLE

|_ CL_GUI_PS_ALV_TREE_SIMPLE

|_ CL_GUI_ALV_GRID_BASE

|_ CL_GUI_ALV_GRID

|_ CL_ALV_DD_LISTBOX

|_ CL_FTR_GUI_ENTRY_ALV

|_ CL_HRPAYNA_GUI_ALV_GRID

|_ CL_CALENDAR_CONTROL_SCHEDULE

|_ CL_GUI_BARCHART

|_ CL_GUI_CALENDAR

|_ CL_GUI_CONTAINER

|_ CL_GUI_CUSTOM_CONTAINER

|_ CL_GUI_DIALOGBOX_CONTAINER

|_ CL_GUI_DOCKING_CONTAINER

|_ CL_GUI_EASY_SPLITTER_CONTAINER

|_ CL_GUI_GOS_CONTAINER

|_ CL_GUI_SPLITTER_CONTAINER

|_ CL_GUI_HTML_VIEWER

|_ CL_BFW_HTML_VIEWER_POC

|_ CL_GUI_PDF_VIEWER

|_ CL_GUI_PICTURE

|_ CL_GFW_GP_PRES_WEB

|_ CL_GUI_TEXTEDIT

|_ CL_GUI_TOOLBAR

|_ CL_TREE_CONTROL_BASE

|_ CL_GUI_SIMPLE_TREE

|_ CL_ITEM_TREE_CONTROL

|_ CL_GUI_COLUMN_TREE

|_ CL_GFW_COLUMN_TREE

|_ CL_HU_COLUMN_TREE

|_ CL_GUI_LIST_TREE

4. 关于事件

4.1两种类型:

Application event

System event

4.2关于application event使用步骤

-定义数据类型

it_events TYPE cntl_simple_events,

wa_event TYPE cntl_simple_event.

-添加事件

wa_event-eventid = cl_gui_textedit=>event_double_click.
wa_event-appl_event = ‘X’. “Application event
append wa_event to it_events.

-dispatch

CALL METHOD cl_gui_cfw=>dispatch.

4.3 关于system event使用步骤

-定义数据类型

go_event_handler TYPE REF TO cls_event_handler,

gi_events TYPE cntl_simple_events,

g_event TYPE cntl_simple_event.

-定义并且实施event handler类

CLASS cls_event_handler DEFINITION.

PUBLIC SECTION.

METHODS:

on_function_selected

FOR EVENT function_selected OF cl_gui_toolbar

IMPORTING fcode,

ENDCLASS.

CLASS cls_event_handler IMPLEMENTATION.

METHOD on_function_selected.

……

ENDMETHOD.

ENDCLASS.

-添加事件

       g_event-eventid         = <system-events>.
 g_event-appl_event   = space.    "This is an system event
APPEND g_event TO gi_events.

-注册事件

         CALL METHOD go_toolbar->set_registered_events

EXPORTING events = gi_events.

-创建event handler

CREATE OBJECT go_event_handler.

-设置event handler

         SET HANDLER go_event_handler->on_function_selected
           FOR go_toolbar.

5. CL_GUI_TEXTEDIT

5.1 Constructor

5.1.1 Text Editor

我们首先考虑如何创建texteditor,所有首先要知道的是constructor方法。

看其参数列表:

MAX_NUMBER_CHARS “能够插入的最大字符数,可选

STYLE “

WORDWRAP_MODE “换行模式 可选

“0:不换行 1:在边界换行 2:在固定位置换行

WORDWRAP_POSITION “换行位置,只有WORDWRAP_MODE=2时有效 可选

WORDWRAP_TO_LINEBREAK_MODE “

FILEDROP_MODE “

PARENT “必输 container

LIFETIME “一般不用 可选

NAME “名字 可选

5.1.2 Custom Container

参数:

PARENT “如果你想container里面包含container,那么这个参数就有用了

CONTAINER_NAME “名字 必输

STYLE “风格 可选

REPID “使用该container的程序

DYNNR “使用该constainer的屏幕

1.1 步骤

5.2.1 定义一个屏幕100

SAP Control framework_第1张图片

5.2.2 在100上放一个container,名字为bobo

SAP Control framework_第2张图片

5.2.3 设置一个pf-status,定义一个退出function key

5.2.4 添加一个ok_code

SAP Control framework_第3张图片

5.2.5 定义数据类型

data:

custom_container type ref to cl_gui_custom_container,

text_editor type ref to cl_gui_textedit.

5.2.6 在pbo中创建container和text editor

CREATE OBJECT CUSTOM_CONTAINER

EXPORTING

CONTAINER_NAME = 'BOBO'

CREATE OBJECT TEXT_EDITOR

EXPORTING

WORDWRAP_MODE = 1

PARENT = custom_container

1.1 事件处理

1.1.1 Application event

1).在前面定义的屏幕上加一个输出字段,以显示事件类型

2).定义事件所需要的结构以及内表

* Internal table for events that should be registred

i_events TYPE cntl_simple_events,

* Structure for oneline of the table

wa_events TYPE cntl_simple_event.

3).定义event handler

class lcl_event_handler definition.

public section.

class-methods:

catch_dbclick for event dblclick

of cl_gui_textedit importing sender.

endclass.

class lcl_event_handler implementation.

method catch_dbclick.

event_type = 'Event dbclick Raised!'.

endmethod.

endclass.

Note:该如何确定control里面都有什么事件呢?常用的event列表如下:

DBLCLICK

double click

F1

F1 pressed

F4

F4 pressed

CONTEXT_MENU

Context Menu requested (by pressing right mouse)

CONTEXT_MENU_SELECTED

Context Menu item selected

ON_DROP

drop occured

ON_DRAG

drag occured

ON_DROP_COMPLETE

complete drag and drop operation

4).在创建text editor之后注册事件

* Link the event handler method to the event and the

* TextEdit control

* 注意,因为是静态方法,所以用=>

SET HANDLER lcl_event_handler=>catch_dbclick FOR text_editor.

* Register the event in the internal table i_events

wa_events-eventid = cl_gui_textedit=>event_double_click.

wa_events-appl_event = 'X'. "This is an application event

append wa_events to i_events.

* Pass the table to the TextEdit control using method

* set_registred_events

call method text_editor->set_registered_events

exporting events = i_events.

5).测试程序效果

SAP Control framework_第4张图片

双击之后:

SAP Control framework_第5张图片

1.1.1 System event

基本上和application event差不多,只需要注意以下几点:

1).appl_event = space

2).不需要cl_gui_cfw=>Dispatch

3).需要重新设置ok_code

      call method cl_gui_cfw=>set_new_ok_code
        exporting new_code = 'XXX'.

4).需要重新处理新设置的OK_CODE

CASE OK_CODE.

WHEN ‘XXX’.

……

ENDCASE.

1.2 调用方法

1.2.1 可调用常用方法列表

SET_REGISTERED_EVENTS

注册事件

CONSTRUCTOR

创建对象的时候调用

DELETE_TEXT

删除所有文本

EMPTY_UNDO_BUFFER

清空UNDO缓存

FIND_AND_REPLACE

查找替换

FIND_AND_SELECT_TEXT

查找

GET_LINE_TEXT

取得某行的文本

GET_SELECTED_TEXT_AS_R3TABLE

把选择的文本放到内表中

GET_SELECTED_TEXT_AS_STREAM

get selected text as stream

GET_SELECTION_INDEXES

get absolute character indexes of selection

GET_SELECTION_POS

获得选择文本的位置

GET_TEXT_AS_R3TABLE

把文本放到内表

GET_TEXT_AS_STREAM

get whole text as stream from control (incl. "\r" and "\n")

GO_TO_LINE

跳到某一884C

HIGHLIGHT_LINES

高亮显示设定的行

HIGHLIGHT_SELECTION

把选择的文本高亮显示

INDENT_LINES

定义缩进的行

INDENT_SELECTION

对所选内容缩进

MAKE_SELECTION_VISIBLE

OPEN_LOCAL_FILE

打开本地文件,一般已经集成在toolbar里面了

PROTECT_LINES

set protect mode for a range of lines

PROTECT_SELECTION

set protect mode for selection

REGISTER_EVENT_CONTEXT_MENU

registration for event context menu

REGISTER_EVENT_DBLCLICK

registration for event double-click

REGISTER_EVENT_F1

registration for event key F1 pressed

REGISTER_EVENT_F4

registration for event key F4 pressed

REGISTER_EVENT_FILEDROP

egistration for event file dropped

REPLACE_ALL

replace all

SAVE_AS_LOCAL_FILE

save as local file

SELECT_LINES

select area of lines, not necessarily within visible part

SET_AUTOINDENT_MODE

set auto indent behavior on or off

SET_COMMENTS_STRING

set string which indicates the whole line is a comment

SET_FILEDROP_MODE

set file drop mode of TextEdit control

SET_FIRST_VISIBLE_LINE

SET_HIGHLIGHT_COMMENTS_MODE

SET_READONLY_MODE

set TextEdit control 'read only' flag true or flase

SET_SPACES_ON_INDENT

set number of spaces to use for indenting and unindenting

SET_SELECTION_POS

set text selection within control

SET_SELECTION_POS_IN_LINE

set selection to a certain line and position

SET_SELECTION_INDEXES

set selection using character indexes

SET_STATUS_TEXT

set status text in status bar of control

SET_TOOLBAR_MODE

set toolbar visibility of TextEdit control

SET_WORDBREAK_PROCEDURE

set wordbreak procedure

SET_WORDWRAP_BEHAVIOR

set wordwrap behavior of TextEdit control

UNINDENT_LINES

unindent a range of lines

UNINDENT_SELECTION

unindent selected text area

SET_NAVIGATE_ON_DBLCLICK

set navigate on double-click mode of TextEdit control

COMMENT_LINES

change a range of lines into comments

COMMENT_SELECTION

change a selected number of lines into comments

UNCOMMENT_LINES

uncomment a range of lines

UNCOMMENT_SELECTION

uncomment a selceted number of lines

DISPLAY_CONTEXT_MENU

display context menu

REGISTER_EVENT

event registration

UNREGISTER_EVENT

event registration

REGISTER_DRAGDROP

register at control framework for drag & drop

1.1.1 如何调用方法

我们以set_text_as_r3table为例介绍一下具体的步骤:

1).在前面的例子的屏幕上放置一个按钮,名字IMPORT,OK_CODE:IMP

SAP Control framework_第6张图片

2).定义一个call_meth类,里面包含load_text方法

class call_meth definition.

public section.

types:

begin of t_texttab,

line(255) type c,

end of t_texttab.

data:

i_texttab type table of t_texttab.

methods:

load_text.

private section.

methods:

add_data.

endclass.

class call_meth implementation.

method add_data.

* Create internal table with texts

APPEND 'This a method that fills the TextEdit control' TO i_texttab.

APPEND 'with a text.' TO i_texttab.

DO 10 TIMES.

APPEND 'hallo world !' TO i_texttab.

ENDDO.

endmethod.

method load_text.

Call method add_data.

* Load TextEdit control with texts

CALL METHOD text_editor->set_text_as_r3table

EXPORTING table = i_texttab.

IF sy-subrc > 0.

* Display an error message

EXIT.

ENDIF.

endmethod.

endclass.

3).调用flush方法,同步

* All methods that operates on controls are transferred to the frontend

* by a RFC calls. the method FLUSH is used

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Display an error message

ENDIF.

4).在ok_code的处理的时候调用call_met->load_text

when 'IMP'.

create object call_meth_ref.

call method call_meth_ref->load_text.

5).测试结果:

SAP Control framework_第7张图片

点击import之后:

SAP Control framework_第8张图片

注意:因为每次调用的时候都会创建call_meth对象,所以会重新添加记录到内表,这样就避免了每次都要clear内表。

1.1 更多的方法和事件

我们上面用到了几个方法,分别是:

SET_TEXT_AS_R3TABLE:这个方法把内表中的数据发送到text control中

SET_TEXT_AS_STREAM: 这个基本和SET_TEXT_AS_R3TABLE差不多

SET_REGISTERED_EVENTS:注册事件

下面我们再介绍几个常用的方法:

5.5.1 GET_REGISTERED_EVENTS

参数:

EVENTS Type CNTL_SIMPLE_EVENTS

这个方法从CL_GUI_CONTROL继承而来,没有重新定义,作用是得到当前已经注册的事件,小例子如下:

定义数据:

data:

rg_events type CNTL_SIMPLE_EVENTS.

定义方法:

class call_meth definition.

public section.

types:

begin of t_texttab,

line(255) type c,

end of t_texttab.

data:

i_texttab type table of t_texttab.

data:

rg_events type CNTL_SIMPLE_EVENTS.

methods:

load_text,

load_events.

private section.

data:

indicator type c.

methods:

add_data importing ind type c.

endclass.

class call_meth implementation.

method add_data.

data: begin of rtab,

e_name(50) type c,

e_type(20) type c,

end of rtab.

data: itab like table of rtab.

data: r_event type CNTL_SIMPLE_EVENT.

case ind.

when '1'.

* Create internal table with texts

APPEND 'This a method that fills the TextEdit control'

TO i_texttab.

APPEND 'with a text.' TO i_texttab.

DO 10 TIMES.

APPEND 'hallo world !' TO i_texttab.

ENDDO.

when '2'.

call method text_editor->GET_REGISTERED_EVENTS

importing events = rg_events.

loop at rg_events into r_event.

case r_event-eventid.

when -601.

rtab-e_name = 'EVENT_DOUBLE_CLICK'.

when 2.

when 0.

when 1.

when 5.

when 6.

when 3.

rtab-e_name = 'EVENT_F1'.

when others.

endcase.

if r_event-appl_event = space.

rtab-e_type = 'System Event'.

else.

rtab-e_type = 'Application Event'.

endif.

append rtab to itab.

endloop.

call method text_editor->SET_TEXT_AS_STREAM

exporting TEXT = itab.

when others.

endcase.

endmethod.

method load_text.

call method add_data exporting ind = '1'.

* Load TextEdit control with texts

CALL METHOD text_editor->set_text_as_r3table

EXPORTING table = i_texttab.

IF sy-subrc > 0.

* Display an error message

EXIT.

ENDIF.

* All methods that operates on controls are transferred to the frontend

* by a RFC calls. the method FLUSH is used to determine when this is don

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Display an error message

ENDIF.

endmethod.

method load_events.

call method add_data exporting ind = '2'.

call method cl_gui_cfw=>flush.

endmethod.

endclass.

定义OK_CODE处理

when 'IMP'.

if call_meth_ref is initial.

create object call_meth_ref.

call method call_meth_ref->load_text.

else.

call method call_meth_ref->load_text.

endif.

when 'GRE'.

if call_meth_ref is initial.

create object call_meth_ref.

call method call_meth_ref->load_events.

else.

call method call_meth_ref->load_events.

endif.

5.5.2 GET_SELECTION_POS和SET_SELECTION_POS

定义屏幕字段:

SAP Control framework_第9张图片

定义数据:

data:

fline type i,

tline type i,

fpos type i,

tpos type i,

gfline type i,

gtline type i,

gfpos type i,

gtpos type i.

处理ok_code:

when 'SSP'.

CALL METHOD text_editor->SET_SELECTION_POS

EXPORTING

FROM_LINE = fline

FROM_POS = fpos

TO_LINE = tline

TO_POS = tpos

EXCEPTIONS

ERROR_CNTL_CALL_METHOD = 1

others = 2

.

when 'GSP'.

CALL METHOD text_editor->GET_SELECTION_POS

IMPORTING

FROM_LINE = gfline

FROM_POS = gfpos

TO_LINE = gtline

TO_POS = gtpos

EXCEPTIONS

ERROR_CNTL_CALL_METHOD = 1

others = 2

.

5.5.3 SET_READONLY_MODE

这个方法设置text editor为只读模式,你在创建好text editor之后调用就可以。

CALL METHOD TEXT_EDITOR->SET_READONLY_MODE

EXPORTING

READONLY_MODE = 1 “0:可以修改 1:只读

EXCEPTIONS

ERROR_CNTL_CALL_METHOD = 1

INVALID_PARAMETER = 2

others = 3 .

1.1 总结

因为text editor比较简单,而且使用的不是很频繁,所以就不多介绍,估计这些也就够用了。

1. CL_GUI_SPLITTER_CONTAINER

这个类相对就简单太多了,主要功能就是container的拆分。

6.1首先我们先看看它的几个常用的方法:

CONSTRUCTOR:构造方法

主要参数:

PARENT -- Parent Container

ROWS –需要显示多少行,举例,你想把container分成上下两个部分,那么rows = 2

COLUMNS – 需要分成多少列

接下来主要是一些setter和getter方法

SET_BORDER 设置边框的格式,space:不设置 ‘X’:设置

效果如图:

Space:

SAP Control framework_第10张图片

‘X’:

SAP Control framework_第11张图片

SET_ROW_HEIGHT — GET_ROW_HEIGHT 用来设置行的高度

SET_COLUMN_WIDTH - GET_COLUMN_WIDTH 设置列的宽度

SET_ROW_MODE - GET_ROW_MODE 设置行的模式

SET_COLUMN_MODE - GET_COLUMN_MODE 设置列的模式

下面这四个方法原理一样,主要设置splitter的属性,例如能不能移动等等

SET_ROW_SASH - GET_ROW_SASH

SET_COLUMN_SASH - GET_COLUMN_SASH

6.2 小例子

我们就以前面介绍的texteditor来举例,在一个container中添加3个texteditor

6.2.1 创建屏幕,定义一下ok_code就可以了

6.2.2 定义类以及方法

首先初始化屏幕

*创建第一个splitter,水平分割初始化的cl_gui_container

create object splitter_h

exporting parent = cl_gui_container=>screen0

rows = 1

columns = 2.

* 设置边框

CALL METHOD splitter_h->SET_BORDER

EXPORTING

BORDER = 'X' “有边框的

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

* 设置模式

CALL METHOD splitter_h->SET_COLUMN_MODE

EXPORTING

MODE = 0

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

* 设置属性

CALL METHOD splitter_h->SET_COLUMN_SASH

EXPORTING

ID = 1

TYPE = splitter_h->TYPE_MOVABLE

VALUE = 0

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

*设置列的宽度

CALL METHOD splitter_h->SET_COLUMN_WIDTH

EXPORTING

ID = 1

WIDTH = 300

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

* 取得分开后的两个container

container_left = splitter_h->get_container( row = 1 column = 1 ).

container_right = splitter_h->get_container( row = 1 column = 2 ).

* 然后分割右边的container

create object splitter_v

exporting parent = container_right

rows = 2

columns = 1.

CALL METHOD splitter_v->SET_BORDER

EXPORTING

BORDER = 'X'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3 .

CALL METHOD splitter_v->SET_row_MODE

EXPORTING

MODE = splitter_v->mode_absolute

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3 .

CALL METHOD splitter_v->SET_row_height

EXPORTING

ID = 1

height = 150

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3 .

* 取得分割右边container后的两个container

container_top = splitter_v->get_container( row = 1 column = 1 ).

container_bottom = splitter_v->get_container( row = 2 column = 1 ).

endmethod.

6.2.3 往已经分割好的container中添加texteditor

method add_control.

CREATE OBJECT editor_1

EXPORTING

PARENT = container_left .

CREATE OBJECT editor_2

EXPORTING

PARENT = container_top .

CREATE OBJECT editor_3

EXPORTING

PARENT = container_bottom .

endmethod.

6.2.4 测试程序代码

REPORT ZBOBO_SPLITER_CONTROL .

data: con type ref to cl_gui_container.

DATA OK_CODE LIKE SY-UCOMM.

class create_screen definition create private.

public section.

class-methods:

init_screen.

methods:

constructor,

add_control.

private section.

data:

splitter_h type ref to cl_gui_splitter_container,

splitter_v type ref to cl_gui_splitter_container,

container_left type ref to cl_gui_container,

container_right type ref to cl_gui_container,

container_top type ref to cl_gui_container,

container_bottom type ref to cl_gui_container,

editor_1 type ref to cl_gui_textedit,

editor_2 type ref to cl_gui_textedit,

editor_3 type ref to cl_gui_textedit.

methods:

fill_data.

endclass.

class create_screen implementation.

method init_screen.

data: screen type ref to create_screen.

create object screen.

endmethod.

method constructor.

data:

events type cntl_simple_events,

event type cntl_simple_event.

* container_left type ref to cl_gui_container,

* container_right type ref to cl_gui_container.

* container_top type ref to cl_gui_container,

* container_bottom type ref to cl_gui_container.

create object splitter_h

exporting parent = cl_gui_container=>screen0

rows = 1

columns = 2.

CALL METHOD splitter_h->SET_BORDER

EXPORTING

BORDER = 'X'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

CALL METHOD splitter_h->SET_COLUMN_MODE

EXPORTING

MODE = 0

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

CALL METHOD splitter_h->SET_COLUMN_SASH

EXPORTING

ID = 1

TYPE = splitter_h->TYPE_MOVABLE

VALUE = 0

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

CALL METHOD splitter_h->SET_COLUMN_WIDTH

EXPORTING

ID = 1

WIDTH = 300

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

container_left = splitter_h->get_container( row = 1 column = 1 ).

container_right = splitter_h->get_container( row = 1 column = 2 ).

create object splitter_v

exporting parent = container_right

rows = 2

columns = 1.

CALL METHOD splitter_v->SET_BORDER

EXPORTING

BORDER = 'X'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

CALL METHOD splitter_v->SET_row_MODE

EXPORTING

MODE = splitter_v->mode_absolute

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

CALL METHOD splitter_v->SET_row_height

EXPORTING

ID = 1

height = 150

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

others = 3

.

container_top = splitter_v->get_container( row = 1 column = 1 ).

container_bottom = splitter_v->get_container( row = 2 column = 1 ).

call method add_control.

endmethod.

method add_control.

CREATE OBJECT editor_1

EXPORTING

PARENT = container_left .

CREATE OBJECT editor_2

EXPORTING

PARENT = container_top .

CREATE OBJECT editor_3

EXPORTING

PARENT = container_bottom .

endmethod.

method fill_data.

endmethod.

endclass.

start-of-selection.

call screen 100.

*&---------------------------------------------------------------------*

*& Module STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'STATUS_100'.

* SET TITLEBAR 'xxx'.

CALL METHOD CREATE_SCREEN=>INIT_SCREEN.

ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

6.2.5 测试结果如图:

SAP Control framework_第12张图片

6.2.6 更深探讨

我们把整个屏幕都分了,那么能不能我们只分割一个customer_container呢?

答案是当然可以,我们首先放一个customer container到屏幕上,然后创建custom container,然后在此基础上分割custom container.

创建屏幕:

SAP Control framework_第13张图片

添加代码:

data: con type ref to cl_gui_custom_container.

CREATE OBJECT con

EXPORTING

CONTAINER_NAME = 'BOBO' .

create object splitter_h

exporting parent = con

rows = 1

columns = 2.

看看效果:

SAP Control framework_第14张图片

到此splitter control介绍完毕。

你可能感兴趣的:(framework)