cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default value to a node attribute programmatically?

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts

How to set a default value to a context node attribute programmatically? Any code snippet will be really helpfull. I am talking about the attribute inside a node in context.

Note: This is for webdynpro for ABAP

Thanks

Gopal

Accepted Solutions (0)

Answers (1)

Answers (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Gopal,

To set value for attribute(ABC) inside Node.

wdContext.currentNodeElement().setABC("Data");

I hope this will help

Regards

Suresh KB

gopalkrishna_baliga
Participant
0 Kudos

Hi Suresh,

The code you gave I think is for Java. How do i do the same in ABAP? Which interface or class I have to use?

Thanks

Gopal

srinivasa_raghavachar
Participant
0 Kudos

Hi Gopal,

Assume you have the node called TEST and attribute called NAME then to set the value of NAME, you can use the following code say in WDDOINIT method or any other method.

data:

Node_Test type ref to If_Wd_Context_Node,

Elem_Test type ref to If_Wd_Context_Element,

Stru_Test type If_Componentcontroller=>Element_Test ,

Item_NAME like Stru_Test-NAME.

  • navigate from <CONTEXT> to <TEST> via lead selection

Node_Test = wd_Context->get_Child_Node( Name = wd_This->wdctx_Test ).

  • get element via lead selection

Elem_Test = Node_Test->get_Element( ).

  • set single attribute

Elem_Test->set_Attribute(

exporting

Name = `NAME`

Value = 'Value').

Note: You can use Weddynpro code wizard to get this code. (Ctrl+F7)

Regards,

Srini.