cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the ID of a Button

graghavendra_sharma
Contributor
0 Kudos

Hi,

There is an interface IF_WD_VIEW_ELEMENT inside the class CL_WD_BUTTON whi has two methods: GET_ID and GET_VIEW.

My problem is i have to get the ID of a button at runtime inorder to get the text associated with it. can anybody pls let me know how to get that?

Points will be rewarded

Regards

raghav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

if you need the id when clicking it,

you should only add ID type string to the importing parameters of the action handler,

from there you can work via view->get_element(id).

grtz,

Koen

graghavendra_sharma
Contributor
0 Kudos

Dear Koen,

Thanks for your response!! Can you please explain a bit of more details?

Regards

Raghav

Former Member
0 Kudos

Hi,

when you create an action to your button, in the on action parameter, you put a name for the action.

the system creates in the view an action handler with name onaction<name>

there in the signature of the method, you find parameters, the wdevent is always

there, add a parameter with name ID type string.

data: lo_button type ref to cl_wd_button,

lv_text type string.

lo_button = wd_this->m_view->get_element( ID ).

lv_text = lo_button->get_text().

grtz,

Koen

graghavendra_sharma
Contributor
0 Kudos

Hi

Thank you very much for your patience.

I am facing a problem in accessing "m_view". I understand this is VIEW, but it is only visible in WDDOMODIFYVIEW method.

lo_button = wd_this->m_view->get_element( ID ).

i am getting error in the abvoe line.

Can you please help me?

Regards

Raghav

Former Member
0 Kudos

hi,

in the attributes tab of the view controller you should add

m_view type ref to if_wd_view

in WDDOMODIFYVIEW:

if first_time is abap_true.

wd_this->m_view = view.

endif.

grtz,

Koen

graghavendra_sharma
Contributor
0 Kudos

Dear Koen,

Thanks a lot!!

Finally I am able to resolve the issue with your help!!

But why I tried your last posting still i was getting error!!

"lo_button = wd_this->m_view->get_element( ID )."

i did a minor correction to the above statement as follows:

lo_button <b>?</b>= wd_this->m_view->get_element( ID ).

-


But to my surprise what is the purpose of the method <b>IF_WD_VIEW_ELEMENT~GET_ID</b>? When can we use this?

This is just for my information.

If you have time, please let me know

Thanks & Regards

Raghav

Former Member
0 Kudos

Hi,

that is more eg:

lo_inputfield = cl_wd_input_field=>new_input_field( ).

lv_id = lo_inputfield->get_id( ).

lo_label = cl_wd_label=>new_label( for = id ).

if you generate your ui-elements and you don't bother about the id's,

but like in the example you have to add a label to the inputfield,

you can get the id of the just created inputfield like this

grtz,

Koen

graghavendra_sharma
Contributor
0 Kudos

Thank you Koen

Answers (0)