cancel
Showing results for 
Search instead for 
Did you mean: 

display during runtime

Former Member
0 Kudos

Hi all,

can anyone tell me how to popup or create UI elements ie buttons or input fields at runtime and how to delete them at runtime.

thanks in advance,

chandana.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

With the help of implicit variable "view" we can get the reference of container and from there you can easily add button on it.

class for button: cl_wd_button.

Remember "view" is a impoting parameter of method wddomodifyview and only available there so if you want to create a button at some where else then you must this variable. you can declare the attribute of IF_WD_VIEW type and can take the instance of "view". With this you can access "view" at any point of time except in method "wddoinitialize".

Code to take reference of "view" :

m_view type if_wd_view "this should be declared in Attribute tab of View

if first_time = 'X'. " you will get "first_time" for free in the wddomodifyview method.

wd_this->M_view = view

endif.

rainer_liebisch
Contributor
0 Kudos

Hello Chandana,

the concept of dynamic UI programming is explained in the series of weblogs:

/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements

/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements

/people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements

This may help to understand the idea of this concept, which is better then copying the code.

Regards,

Rainer

Former Member
0 Kudos

Hi this the code to create a button dynamically.

DATA: lr_ui_root TYPE REF TO if_wd_view_element.

DATA: lr_button TYPE REF TO cl_wd_button.

DATA: lr_container TYPE REF TO cl_wd_uielement_container.

CALL METHOD io_view->get_element

EXPORTING

id = 'tc1' "transparent container name

RECEIVING

element = lr_ui_root.

lr_container ?= lr_ui_root.

CALL METHOD cl_wd_button=>new_button

EXPORTING

id = 'tc1' "transparent container name

on_action = 'ADD_ROW' "action"

RECEIVING

control = lr_button.

cl_wd_matrix_head_data=>new_matrix_data(

EXPORTING

element = lr_button ).

lr_container->add_child(

EXPORTING

the_child = lr_button ).

to delete a button during runtime u can use:

lr_container->remove_child(

EXPORTING

the_child = lr_button ).

similarly to create input fields u can use the class CL_WD_INPUT_FIELD.

regards

chythanya