on 07-25-2012 2:53 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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
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
.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.