cancel
Showing results for 
Search instead for 
Did you mean: 

simpler way to move 1 attribute to another

Former Member
0 Kudos

Hi,

in AWD i have 2 nodes and subnodes with attributes under the subnodes.

If I have a attribute that I want to move to another attribute, what is the simpliest way?

What I do now is GET the on and SET the other one. I use the wizzard to greate the code, but even for 1 attribute it is quite a lot of code.

Regards

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You could create simple methods for GETting and SETting context attributes, then just invoke these from wherever you needed. Something like this:

lv_my_attribute_value = wd_this->get_attribute( 'ATTRIBUTE1' ).

then, for setting the next attribute:

wd_this->set_attribute( exporting attribute_name = 'ATTRIBUTE2' value = lv_my_attribute_value ).

In the get_attribute and set_attribute methods, you'd have code resembling the code from the wizard, just making it dynamically so that the attribute name could be passed to the methods. This would slim down the application considerably, compared to using the wizard everywhere.

Hope this helps,

Trond

Former Member
0 Kudos

I did this : lv_my_attribute_value = wd_this->get_attribute( 'FROM' ).

but getting (Method "GET_ATTRIBUTE" is unknown or PROTECTED or PRIVATE) when I want to activate.

Former Member
0 Kudos

I'm afraid Get and Set is the simplest way.

When you get a little familiar with the WD4A in the future, You will get used to it.

The code wizard can help beginner to program, but not handful at all.

Former Member
0 Kudos

Hi Kobus,

Try using lv_my_attribute_value = wd_context->get_attribute( 'FROM' ).

But this will work considering the fact that you are working with some context attribute ( attribute defined in context not under any node ).

If you want to access any context attribute then you need to get the ref of the node and then only you can access it.

if you use code wizard every time it will generate long code containing ref of context node ( lo_nd_<node_name> ) , and ref to context element ( lo_el_<node_name>).

You can omit these parts next time when you get / set any attribute from the same node.

just define the type of the attribute and use set get method accordingly.

DATA LV_<attribute-name> TYPE WD_THIS->ELEMENT_CTX_VN_<node_name>.

  • get single attribute

LO_EL_<node_name>->GET_ATTRIBUTE(

EXPORTING

NAME = `<attribute-name>`

IMPORTING

VALUE = LV_<attribute-name>.

Thanks & Regards,

Monishankar Chatterjee

Former Member
0 Kudos

You'll have to write the method yourself. Inside it, you can use the wizard to come up with a suggestion for the code, then alter it slightly to make it dynamically (using the attribute name as an input parameter).

Shouldn't be too hard

Lukas_Weigelt
Active Contributor
0 Kudos

Using SET and GET is the easiest and cleanest way in my opinion. In addition with the code wizard (which you said you use) it isn't really much work