cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the NAME of the attribute?

Former Member
0 Kudos

Hi Experts,

I am doing an application of WD Abap, and i have a scenario where in I have to read the 'Name' of the attribute. Can you please help if there is any method which gives me the name? Please help with the code if any.

eg:

i have 1 node  - A

under node A, i have 1 attribute - PERNR

now, on screen, when i enter some value in input field "PERNR", i want to read the name of attribute  i.e. 'PERNR' along with the value of it. I do not want to hardcode this name in method GET_ATTRIBUTE...

hope i am clear with my question. please help.

thanks

prateek

Accepted Solutions (0)

Answers (1)

Answers (1)

amy_king
Active Contributor
0 Kudos

Hi Parteek,

If you are in an event handler method, e.g., for the onEnter event of an InputField, you can read the name of the field's bound context attribute by reading WDEVENT's PARAMETERS table. The record where NAME=ID shows you the field's bound context attribute.

lv_the_attribute_name = wdevent->get_string( name = 'ID' ).

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

Thanks for the response, but in the event handler get_string gives me the FIELD i.e. UI Element to which the value is bound....

however, i want to know the name of the attribute (in the context node) to which that field is binded...

please help how to read the name of the ATTRIBUTE in the CONTEXT node, as the above method just gives me the UI Field name...

thanks in advance.

amy_king
Active Contributor
0 Kudos

Oops, you are right. I have named each of my fields the same as the context attribute name, which caused my confusion, though this approach might still solve your problem. If your field name always equals your context attribute name, you can use wdevent to derive the context attribute name. So one solution may lie in how you apply a naming convention to your fields.

Cheers.

Former Member
0 Kudos

Hi Amy,

Yes, thats one thing.......... but is there a way we can actually read the Attribute name as well? not considering the naming part right now...

thanks.

chandani_kaur
Active Participant
0 Kudos

Hello Parteek,

You can write below code in View to get all the attribute names for a Node.

DATA lo_context TYPE REF TO IF_WD_CONTEXT.
lo_context = wd_this->WD_GET_API( )->GET_CONTEXT( ).
DATA lo_node_info TYPE REF TO IF_WD_CONTEXT_NODE_INFO.
DATA LO_child_info TYPE REF TO IF_WD_CONTEXT_NODE_INFO.
lo_node_info = lo_context->ROOT_NODE_INFO.
CALL METHOD LO_CHILD_INFO->GET_CHILD_NODE
  EXPORTING
    NAME       = 'CHILD_NODE_NAME'
  RECEIVING
    CHILD_NODE = LO_child_info
DATA lt_parameters TYPE STRING_TABLE.
CALL METHOD LO_child_INFO->GET_ATTRIBUTE_NAMES
  RECEIVING
    ATTRIBUTE_NAMES = lt_parameters.

Thanks & Regards,

Chandani

Former Member
0 Kudos

Hi Parteek,

You can get a list of names of attributes of a node using method GET_ATTRIBUTE_NAMES of IF_WD_CONTEXT_NODE_INFO.

Former Member
0 Kudos

Guys,

thanks for your response. but i DO NOT need the attributes names.. i just need the 1 attribute name to which the FIELD of UI element is mapped.

I know I can read all attributes of a node, but here I want to read the name of just 1 attribute which is in use now.

thanks

chandani_kaur
Active Participant
0 Kudos

Hello Parteek,

You can get the path to the context attribute and the element reference by calling method BOUND_VALUE of the input field. The last part of the path is the attribute name. Each UI element classe has methods BOUND_* for all bindable properties.

Write the code in WDDOMODIFYVIEW

   DATA lo_element type REF TO CL_WD_INPUT_FIELD.
  DATA lv_path TYPE string.
  lo_element ?= view->get_element( 'ROOTUIELEMENTCONTAINER_USERID' ).
  CALL METHOD LO_ELEMENT->BOUND_VALUE
*    EXPORTING
*      CONTEXT_ELEMENT        =
*      CONTEXT_NODE_PATH_NAME =
    RECEIVING
      PATH                   = lv_path

Thanks & Regards,

Chandani


      .