Hi Deepak,
You can create a Context Attribute, named 'MY_CXT_ATTRIBUTE' of cardinality 1..1 with type STRING and bind it to Text property of the Button UI element. Then, after you get the text selected by user, just access this context attribute and modify it to the value selected by the user:
data: l_node type ref to IF_WD_CONTEXT_NODE,
l_my_string type string.
l_node = wd_context->get_child_node( wd_this->wdctx_node_1 ).
l_node->SET_ATTRIBUTE(
EXPORTING
NAME = 'MY_CXT_ATTRIBUTE'
VALUE = l_my_string ).
Regards,
Felipe