on 08-23-2011 7:59 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.