cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of satic and dynamic buttons in a view

former_member262988
Active Contributor
0 Kudos

Hi,

I have created a dynamic button using the code..

DATA: lr_container TYPE REF TO cl_wd_uielement_container,
        lr_button TYPE REF TO cl_wd_button.

  CHECK first_time = abap_true.
  lr_container ?= view->get_element( id = 'ROOTUIELEMENTCONTAINER' ).
  cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).


  lr_button = cl_wd_button=>new_button( id         = 'BUTTON'
                                        text       = 'My Button'
                                        on_action  = 'ACTION' ).


  cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_button ).

  lr_container->add_child( the_child = lr_button ).

its working fine and iam able to see the button .....but when i create another button thorugh layout design its going for dump....whats the reason .?

Cant we create static and dynamic buttons at a time?

Thanks,.

Shailaja Ainala.

Accepted Solutions (1)

Accepted Solutions (1)

former_member40425
Contributor
0 Kudos

Hi,

Check the ID of button. Might be you are giving the same ID of both buttons.

And one more Imp thing as You are giving matrix layout while creating button dynamically. so the layout of rootuielementcontainer also should be matrix.

I hope it helps.

Regards,

Rohit

Answers (2)

Answers (2)

arjun_thakur
Active Contributor
0 Kudos

Hi Shailaja,

You can have a static and dynamic button in the same view. Make sure that the ID of both the buttons are different. And also make sure that the layout is matix layout , as you are using matix layout in your code to create a button.

If the problem still persists then plz paste the dump message.

Regards

Arjun

Former Member
0 Kudos

Hi Shailaja,

Yes you can add static and dynamic ui elements together in the same view.

The possible problem here could be the way in which the ui elements are added.

You have created the dynamic button under the root container uielement.

What about you static button ? Check your layout and layout data property.

Thank You,

Radhika.

former_member262988
Active Contributor
0 Kudos

Hi,

Yes i have created the static button under rootcontainer only...

Thanks,

Shailaja Ainala.

Former Member
0 Kudos

Shailaja,

Did you solve the issue ?

Try this.

Comment the following line from the code.

cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

Layout of the Root Container can be set directly in the layout tab of the view.

Radhika.