cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic creation of UI Elements

Former Member
0 Kudos

Hi all,

I am trying to create UI Elements dynamically.

I have written code in modifyview.

First am displaying a dropdown box for sflight details. Am able to see this in my output window.

But when I use the dropdown option and select any value, I get the following error.

No layout data has been specified for child element "" in the UI element container

Can any explain why this is happening?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

When you make a selection in DropDownList DoModifyView will be triggered again...

are you taking care that elements are generated only once...

This could be the problem..check on this..

Regards

Manas Dua

Former Member
0 Kudos

yes am using the following statement to handle this.

IF FIRST_TIME = ABAP_TRUE.

I am not able to find in debug mode also where this error arises.

Former Member
0 Kudos

Hello Mohamed Aslam,

First of all, it is nothing to do with First_time variable provided by the framework, it is with something else. and even if you dont use the variable it will not give you the error but it will be slow as anytime you do activity on the application it would trigger modify view method.

NOW coming to solution. If you could recall or may be do it to realize the reason, whenever we include ui element in the view, we define the layout data in the properties. for ex when we define matrix layout,,,we define whether ui element has "matrixheaddata" or "matrixdata"

Regards

Anurag Chopra

Former Member
0 Kudos

Hello Aslam,

May be you could refer the below code.

You need to include the following code in the wddomodifyview method of view.

DATA: l_root_cnt TYPE REF TO cl_wd_uielement_container,

l_text_view TYPE REF TO cl_wd_text_view,

l_flow_data TYPE REF TO cl_wd_flow_data.

  • Check whether the method is called for the first time

IF first_time = abap_true.

  • Get the reference for thr ROOTUIELEMENTCONTAINER

l_root_cnt ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

  • Call the method(generally starts with word new) of the corresponding class(UI specific)

here I have used textview, you can replace it with dropdrown UI element.

l_text_view = cl_wd_text_view=>new_text_view( id = 'TEXT_VIEW_ID'

text = 'YOUR TEXT' ).

l_root_cnt->add_child( l_text_view ).

  • Decide on the layout property of the UI Element. use the below class if rootuielementcontainer has "flowlayout".

l_flow_data = cl_wd_flow_data=>new_flow_data( element = l_text_view ).

ENDIF.

Regards

Anurag Chopra

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Aslam,

Is your question still unanswered ?

Regards

Anurag Chopra

Former Member
0 Kudos

Hi,

Its not completely solved. Just now i found that when i create table dynamically this layout error comes.

Code for creating table

CALL METHOD cl_wd_dynamic_tool=>create_table_from_node

EXPORTING

ui_parent = lr_container

table_id = 'MY_TABLE'

node = lo_nd_sflight

RECEIVING

table = lr_table.

so i added the following code to solve this.

CLEAR lr_matrix.

lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data( lr_TABLE ).

lr_table->set_layout_data( lr_matrix ).

CALL METHOD lr_container->add_child

EXPORTING

index = 1

the_child = lr_table.

Now what happens is my table is being created but twice. When i debug the code control goes to this place only once.

Is there anything with my second part of code which makes this table being created twice.

I referred the following link for creating this application.

http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application

I have only added the second part of code given above in addition to what ever is available in the link.

But i am not aware why the table is being created twice?

Former Member
0 Kudos

Hi,

Solved the problem.

I removed this part of code and now only one table is created.

  • CALL METHOD lr_container->add_child

  • EXPORTING

  • index = 1

  • the_child = lr_table.

Thanks all.

Special thanks to Anurag Chopra.