This example shows how to use the dialog box container and the splitter container.
A dialog box container is created, and a splitter container with 2 rows and 1 column is placed on it.
To keep the example simple row 1 of the splitter container is not used, but you can use it to place a control.
Row 2 is used to place a toolbar control in the button of the dialog box. The toolbar has an OK and a Cancel button. To keep the example simple, these 2 buttons only closes the dialog screen. The dialog box can also be closed by using the close button in the top right corner of the dialog box. This button is standard functionality, however you have to do the coding for closing the dialog box yourself.
Steps:
Create a screen
Place dynpro button on the screen that opens the dialog box. Name: DIALOG_BUTTON. Caption: Show dialog box. Function code: DIALOG
Place another dynpro on the screen to exit the program. Name: EXIT_BUTTON. Caption: Exit. Function code: EXIT.
Place a custom control on the screen for the dialog box. Name: DIALOG_CONTAINER
Place a custom control on the screen for the toolbar control. Name: TOOLBAR_CONTAINER
The screen:
The code:
REPORT sapmz_hf_dialogbox_cont.
* Icons for the toolbar
TYPE-POOLS:icon.
* Predefinition of the event handler class. Necessary if
* you want to make references to the class before it is defined
CLASS lcl_event_handler DEFINITION DEFERRED.
*----------------------------------------------------------------------
* G L O B A L D A T A
*----------------------------------------------------------------------
DATA:
ok_code LIKE sy-ucomm,
* Dialog container
go_dialog_container TYPE REF TO cl_gui_dialogbox_container,
* Splitter container
go_splitter_container TYPE REF TO cl_gui_splitter_container,
* Event handler class
go_event_handler TYPE REF TO lcl_event_handler,
* SAP Toolbar
go_toolbar TYPE REF TO cl_gui_toolbar.
*----------------------------------------------------------------------
* Table and workarea for registration of events. Note that a TYPE REF
* to cls_event_handler must be created before you can
* reference types cntl_simple_events and cntl_simple_event.
*----------------------------------------------------------------------
DATA:
gi_events TYPE cntl_simple_events,
g_event TYPE cntl_simple_event.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler
*---------------------------------------------------------------------*
* This class is used to handle events from the dialobox
* and the toolbar
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
* Close event of the dialogbox
on_close
FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING sender,
* Select event of the toolbar
on_function_selected
FOR EVENT function_selected OF cl_gui_toolbar
IMPORTING fcode.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
*----------------------------------------------------------------------
* Handles the Close event of the dialogbox. The colse event is
* triggered when the close button in the top right corner of the
* dialogbox is pushed. Closes the dialog box
*----------------------------------------------------------------------
METHOD on_close.
IF NOT sender IS INITIAL.
CALL METHOD sender->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* Error handling
ENDIF.
FREE go_dialog_container.
CLEAR go_dialog_container.
ENDIF.
ENDMETHOD.
*----------------------------------------------------------------------
* Handles the Function Selected event of the toolbar, which is
* triggered when one of the buttons on the toolbar is pushed.
* Both pushbuttons closes the dialogbox
*----------------------------------------------------------------------
METHOD on_function_selected.
CASE fcode.
WHEN 'OK'.
CALL METHOD go_dialog_container->free.
FREE go_dialog_container.
CLEAR go_dialog_container.
WHEN 'CANCEL'.
CALL METHOD go_dialog_container->free.
FREE go_dialog_container.
CLEAR go_dialog_container.
ENDCASE.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* Necessary to get access to certain predefined constants
CLASS cl_gui_cfw DEFINITION LOAD.
SET SCREEN '100'.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* Handles the 2 dynpro pushbuttons on screen
*----------------------------------------------------------------------
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'DIALOG'.
PERFORM show_dialog_box.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form show_dialog_box
*&---------------------------------------------------------------------*
* Performed when the Show dialog box button is pushed.
*----------------------------------------------------------------------*
FORM show_dialog_box.
IF go_dialog_container IS INITIAL.
*----------------------------------------------------------------------
* Create Dialogbox
*----------------------------------------------------------------------
CREATE OBJECT go_dialog_container
EXPORTING
* PARENT =
width = 400
height = 150
style = cl_gui_control=>ws_sysmenu
* REPID =
* dynnr = '100'
* LIFETIME = lifetime_default
top = 100
left = 350
caption = 'My dialog box'
* NO_AUTODEF_PROGID_DYNNR =
* METRIC = 0
* NAME =
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.
IF sy-subrc <> 0.
* Do some error handling..............
ENDIF.
*----------------------------------------------------------------------
* Create Splitter container and configure
*----------------------------------------------------------------------
CREATE OBJECT go_splitter_container
EXPORTING
parent = go_dialog_container
rows = 2
columns = 1
EXCEPTIONS
others = 1.
IF sy-subrc <> 0.
* Do some error handling..............
ENDIF.
* Set row height for row 1
CALL METHOD go_splitter_container->set_row_height
EXPORTING
id = 1
height = 90.
* The splitter container should not have a border
CALL METHOD go_splitter_container->set_border
EXPORTING
border = cl_gui_cfw=>false.
* Configure the splitter bar. The splitterbar is configures * so that it can't be moved
CALL METHOD go_splitter_container->set_row_sash
EXPORTING
id = 1 "Configure splitter bar no. 1
type = 0 "Type_movable
value = 0. "False
*----------------------------------------------------------------------
* Create Toolbar and set parent to the Splitter container
*----------------------------------------------------------------------
CREATE OBJECT go_toolbar
EXPORTING
parent = go_splitter_container
EXCEPTIONS
others = 1.
IF sy-subrc <> 0.
ENDIF.
* Add a buttons CALL METHOD go_toolbar->add_button
EXPORTING
fcode = 'OK' "Function Code
icon = icon_okay "ICON name
is_disabled = ' ' "Disabled = X
butn_type = cntb_btype_button "Type of button
text = 'OK' "Text on button
is_checked = ' ' "Button selected
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* Do some error handling..............
ENDIF.
CALL METHOD go_toolbar->add_button
EXPORTING
fcode = 'CANCEL' "Function Code
icon = icon_cancel "ICON name
is_disabled = ' ' "Disabled = X
butn_type = cntb_btype_button "Type of button
text = 'Cancel' "Text on button
is_checked = ' ' "Button selected
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* Do some error handling..............
ENDIF.
*----------------------------------------------------------------------
* Add Toolbar control to row 2 of the Splitter container
*----------------------------------------------------------------------
CALL METHOD go_splitter_container->add_control
EXPORTING row = 2
column = 1
control = go_toolbar.
*----------------------------------------------------------------------
* Create object for the event handler class
*----------------------------------------------------------------------
CREATE OBJECT go_event_handler.
*----------------------------------------------------------------------
* Set Handler for the dialog container. Note that you don't have to
* register the events for this class
*----------------------------------------------------------------------
SET HANDLER go_event_handler->on_close
FOR go_dialog_container.
*----------------------------------------------------------------------
* Create event handler table for the toolbar control, and register
* the events
*----------------------------------------------------------------------
* Create event table. The event ID must be found in the
* documentation of the specific control
CLEAR g_event.
REFRESH gi_events.
g_event-eventid = go_toolbar->m_id_function_selected.
g_event-appl_event = 'X'. "This is an application event
APPEND g_event TO gi_events.
* Use the events table to register events for the control
CALL METHOD go_toolbar->set_registered_events
EXPORTING
events = gi_events.
* Set handler
SET HANDLER go_event_handler->on_function_selected
FOR go_toolbar.
* Synchronization
CALL METHOD cl_gui_cfw=>flush.
ENDIF.
ENDFORM. " show_dialog_box
Friday, November 23, 2007
ABAP CODE FOR DIALOG BOX AND SPILTTER CONTAINERS
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment