Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

button sugestion

Former Member
0 Likes
1,184

hello everyone,

does anyone has any suggestions with using buttons in dialogbox?

i mean, is it possible to place some buttons on a dialogbox beside those that u can place in a toolbar?

i've placed ok and cancel buttons in a Toolbar in a splitter container with 2 rows.

so should i make a few more rows and columns in a splitter and then add dynamic document to one row and add buttons to that document, or i add buttons to a dd_form_area? or?

any suggestions would be great.

Thanx in advance!

9 REPLIES 9
Read only

Former Member
0 Likes
1,099

still no suggestions...

Read only

Former Member
0 Likes
1,099

I am not clear what exactly are you trying to do? Can you give a big picture of the same.

If you are dealing with ALV Controls, what stops you from creating buttons on the toolbar.

Regards,

Ravi

Read only

0 Likes
1,099

hey,

i do know how to create buttons in a toolbar. i want to put some buttons above the toolbar tough.

or do you mean i should put all my buttons in a toolbar?

Read only

0 Likes
1,099

My suggestion is to have the button in the toolbar of the ALV Grid.

You can look at these examples.

BCALV_GRID_05

BCALV_GRID_07

BCALV_GRID_08

BCALV_TEST_GRID_TOOLBAR

BCALV_TOOLBAR_EVENT_RECEIVER

BCALV_TOOLBAR_EVENT_RECEIVER01

Regards,

Ravi

Note - Please mark all the helpful answers

Read only

Former Member
0 Likes
1,099

hi

good

go through this

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 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

thanks

mrutyun

Read only

0 Likes
1,099

hi.

i've done that like code that u mentioned here.

now suppose that i want to add some more buttons to the row 1 of a splitter_container

is it posssible?

to add button an a field that can input a value of the button?

Read only

0 Likes
1,099

Hi,

You cannot add anything on the Containers except for Controls like GRID / TREE / TEX EDIT etc etc.

Regards,

Ravi

Note : Please mark the helpful answers

Read only

0 Likes
1,099

isn't it possible to add dynamic document first, then add a form also dynamic one and then append buttons to that form?

thanx!

Read only

0 Likes
1,099

Hi,

You can always add a dynamic document, I have always tried it only with the text. I am not sure if its possible or NOT, take a look at this program BCALV_DEMO_HTML, where there are some buttons displayed, but I am not sure how they have been added.

Please mark all the helpful answers

Regards,

Ravi