SAP control framework-DIALOGBOX_CONTAINER

Source: Internet
Author: User

Reference: skysky

We have read several iner, including customer container and Splitter container. Next I will introduce the other two commonly used container to you.

1.1 cl_gui_dialogbox_container

We can see from the name what it is, that is, the container in the pop-up dialog box. Some people will ask, there are many functions that can pop up the dialog box, even if there is no corresponding function, we can also choose to create a new dialog screen, and then call this screen. Yes, let's talk about functions. There are a lot of popup functions that can be used, but these functions all have fixed screen formats. What if they are not applicable? If you want to create a screen, but our program may not be able to use it at all, isn't it a waste of resources to create a screen?

Therefore, this container is introduced here, which makes it more flexible to use Popup.

7.1.1 definition:

The pop-up dialog box is a bit like popup confirmation.

7.1.2 method:

Constructor:

Parent: Specify super container

Width: width

Height: Height

Repid: Report ID

Dynnr: screen number

Top: location defined

Left: location defined

Caption: Title

7.1.3 example:

We put a button on the screen and an input field.

When you click this button, a dialog box is displayed, in which you can enter some information or import a local text file.

Then we can select a section or a piece of text in the text file as the content of the input field.

This may be another form of input help. We can save the help field as a local file and use this method for input help.

OK. Start now.

À defines the screen and screen fields, and sets status and OK _code.

Screen fields:

Value I/O

P1 push

OK _code OK

Flow logic:

Process before output.

Module status_0100.

Process after input.

Module user_command_0100.

Main Program declare screen fields:

Data: OK _code like sy-ucomm.

Data: Value (100) type C.

À define container

Data:

* Dialog box

Dialog_ref type ref to cl_gui_dialogbox_container,

* Text Editor

Text_ref type ref to cl_gui_textedit.

À define event processing

* For event Process

Data:

Event Type cntl_simple_event,

Events type cntl_simple_events.

* Set F1 event for Text Editor

Catch_f1 for event F1

Of cl_gui_textedit importing sender,

À set Handler

* Register events

Set handler me-> catch_f1 for text_ref.

Event-eventid = cl_gui_textedit => event_f1.

Event-appl_event = 'x '.

Append event to events.

Call method text_ref-> set_registered_events

Exporting

Events = events.

À create dialogbox and insert text editor

Create object dialog_ref

Exporting

Parent = cl_gui_container => screen0

Width = 400

Height = 200

Repid = repid

Dynnr = dynnr

Top = 80

Left = 50

Caption = 'test bobobo '.

Create object text_ref

Exporting

Parent = dialog_ref.

À get the selected part and place it in the input field

* Get selected content

Call method text_ref-> get_selected_text_as_stream

Importing

Selected_text = sel_text.

* Move the selected content to screen input field

Read Table sel_text into STR Index 1.

Value = Str.

Source code

Report zbobo_dialogbox_control.

* Define the screen field and OK code

Data: OK _code like sy-ucomm.

Data: Value (100) type C.

* Init dialog Screen

Class dialog_init definition.

Public section.

* Load cl_gui_cfw

Class cl_gui_cfw definition load.

Methods:

* Create dialog box

Create_dialog,

* Insert text edit control to dialog box

Insert_control,

* Set F1 event for Text Editor

Catch_f1 for event F1

Of cl_gui_textedit importing sender,

* Get the selection field to screen Field

Process_control.

Private section.

Data:

* Dialog box

Dialog_ref type ref to cl_gui_dialogbox_container,

* Text Editor

Text_ref type ref to cl_gui_textedit.

Data: repid like sy-repid,

Dynnr like sy-dynnr.

* For event Process

Data:

Event Type cntl_simple_event,

Events type cntl_simple_events.

Endclass.

Class dialog_init implementation.

Method create_dialog.

If dialog_ref is initial.

Create object dialog_ref

Exporting

Parent = cl_gui_container => screen0

Width = 400

Height = 200

Repid = repid

Dynnr = dynnr

Top = 80

Left = 50

Caption = 'test bobobo'

Exceptions

Cntl_error = 1

Cntl_system_error = 2

Create_error = 3

Lifetime_error = 4

Lifetime_dynpro_dynpro_link = 5

Event_already_registered = 6

Error_regist_event = 7

Others = 8

.

Endif.

* Insert text editor to dialog box

Call method insert_control.

Endmethod.

Method insert_control.

If not dialog_ref is initial.

Create object text_ref

Exporting

Parent = dialog_ref.

* Register events

Set handler me-> catch_f1 for text_ref.

Event-eventid = cl_gui_textedit => event_f1.

Event-appl_event = 'x '.

Append event to events.

Call method text_ref-> set_registered_events

Exporting

Events = events.

Endif.

Endmethod.

Method catch_f1.

* Catch the F1 event and Process

Call method process_control.

Call method cl_gui_cfw => dispatch.

Endmethod.

Method process_control.

Data: STR (100) type C,

Sel_text like table of Str.

If not text_ref is initial.

* Get selected content

Call method text_ref-> get_selected_text_as_stream

Importing

Selected_text = sel_text

.

* Move the selected content to screen input field

Read Table sel_text into STR Index 1.

Value = Str.

Endif.

* Free container

Call method text_ref-> free.

Call method dialog_ref-> free.

Endmethod.

Endclass.

* Define reference of dialog_init

Data: ref type ref to dialog_init.

Start-of-selection.

Call screen 100.

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

* & Module status_0100 output

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

* Text

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

Module status_0100 output.

Set PF-STATUS 'tt '.

Endmodule. "status_0100 output

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

* & Module user_command_0100 Input

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

* Text

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

Module user_command_0100 input.

Case OK _code.

When 'back '.

Leave program.

When 'get '.

* Create instance of dialog_init

Create Object ref.

* Main process of dialog box

Call method ref-> create_dialog.

Endcase.

Endmodule. "user_command_0100 Input

Test Results

Execution program:

Point get value

Press F1

1.1 cl_gui_docking_container

This class is relatively simple, and its functions are similar to splitter iner. I will not detail it. List the main methods and attributes.

1.1.1 Method

Constructor:

Parent type ref to cl_gui_container the screen or container you want to dock

Repid type syrepid connection report

Dynnr type sydynnr connection Screen

Side type I dock_at_left dock position, left, right ......

Caption Type C name

1.1.2 attributes

There are several commonly used constant

Dock_at_left

Dock_at_top

Dock_at_bottom

Dock_at_right

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.