cancel
Showing results for 
Search instead for 
Did you mean: 

How to get label binding property

glauco
Active Contributor
0 Kudos

Hi friends.

In a dynamic way, I need to get the bind text of a label, which is an attribute of a context node.

I tryied to get it but without sucess.

In debbuging mode, I can see attribute name inside

LR_VIEW_ELEMENT-_PROPERTY_BINDINGS-PATH_NAME

and LR_VIEW_ELEMENT-_PROPERTY_BINDINGS-ATTRIBUTE_NAME


But I could not find how to get it and after that, get the value of context node.

I'm doing something like this:



IF p_i_r_root_element IS INITIAL.

       lr_comp_ctrl   ?= p_i_r_comp.

       lr_v_main_ctrl ?= lr_comp_ctrl->get_controller( name = p_i_view_name ).

       lr_v_root_elem ?= lr_v_main_ctrl->get_root_element( ).

       DATA: tt_v_elements TYPE wdr_element_tab,

             e_element     TYPE wdr_element_line,

             lc_label_text TYPE string.

       tt_v_elements = lr_v_main_ctrl->get_elements( ).

       LOOP AT tt_v_elements INTO e_element.

         IF e_element-view_element->_definition_name = 'LABEL'.

*** here I need to get label text/value. It's inside a context node named LABELS.attrib1...N

         ENDIF.

       ENDLOOP.

ENDIF.


thank you

Glauco

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You want to get the Value of Label or the Attribute to which it is bound? Try the below code to get both text and binding path.


DATA: lr_label TYPE REF TO cl_wd_label,

         lv_path  TYPE string,

         lv_text  TYPE string.

   lr_label ?= view->get_element( id = 'LABEL' ).

* Get Binding Path

   lv_path lr_label->bound_text( ).

*  Get Label Text

   lv_text = lr_label->get_text( ).

hope this helps,

Regards,

Kiran

glauco
Active Contributor
0 Kudos

It's simply perfect!

Now I can get the text and do not need to get path.

It works great like you said.


lc_label_text = lr_label->get_text( ).


Now I need to get element bind to label for property to see if it is mandatory. I think I must open another post to this new subject.


best regards friend.

Glauco

Answers (2)

Answers (2)

ramakrishnappa
Active Contributor
0 Kudos

Hi Glauco,

Please modify your code as below


IF p_i_r_root_element IS INITIAL. 

       lr_comp_ctrl   ?= p_i_r_comp. 

       lr_v_main_ctrl ?= lr_comp_ctrl->get_controller( name = p_i_view_name ). 

       lr_v_root_elem ?= lr_v_main_ctrl->get_root_element( ). 

       DATA: tt_v_elements TYPE wdr_element_tab, 

             e_element     TYPE wdr_element_line, 

             lr_label           type ref to cl_wd_label,

             lv_text               type string,

             lc_label_text TYPE string. 

       tt_v_elements = lr_v_main_ctrl->get_elements( ). 

       LOOP AT tt_v_elements INTO e_element. 

         IF e_element-view_element->_definition_name = 'LABEL'

*** here I need to get label text/value. It's inside a context node named LABELS.attrib1...N 

        

          " collect object into lr_label

           lr_label ?= e_element-view_element.

        

             "Get the text of label

              if lr_label is bound.

                  lv_text = lr_label->get_text( ). "use this text based on your requirement

               endif.

        

         ENDIF. 

       ENDLOOP. 

ENDIF.

Hope this helps you.

Regards,

Rama


glauco
Active Contributor
0 Kudos

Sorry for the long time to answer. I've stocked in another issues here in the project.

It's also perfect.

thank you.

Glauco

0 Kudos

Hi glauco,

                  will you please send the remaining code if possible so that i can check it