on 03-15-2012 1:12 PM
In 7.02, method chaining in ABAP is allowed, which means that we can write less code and use fewer temporary variables. In a web dynpro view method, is there a method for reading the contents of a context node into a structure using just one line of code? I tried this:
ls_old_material = wd_context->get_child_node( name = wd_this->wdctx_old_material )->get_static_attributes( )
This does not work because get_attributes() does not have a returning parameter.
So I have to do it this way:
lo_el_old_material = wd_context->get_child_node( name = wd_this->wdctx_old_material )->get_element( ).
lo_el_old_material->get_static_attributes( IMPORTING static_attributes = ls_old_material ).
Any tips on how to squeeze this into on line?
thanks!
Frank
Yes, use GET_STATIC_ATTRIBUTES_REF instead:
data ls_selection_criteria type ref to wd_this->element_selection_criteria.
ls_selection_criteria ?= wd_context->get_child_node(
name = wd_this->wdctx_selection_criteria )->get_element( )->get_static_attributes_ref( ).
append ls_selection_criteria->* to it_name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know. Personally once I got used to data references I really like them. Treating a field in a structure the same as an attribute of a class instance starts to make sense. I started using the data references for the content becuase of the method chaining, but now I find myself using them with the context whenever possible.
It can be more memory efficient as well. There is a lot of dynamic type creation involved with the other approach. The reference approach is much lighter since the original data reference can just be passed around.
Thomas, I just went ahead with your suggestion and I realized that I can reference a field in a structure using the -> just like an object. I did not know that was possible until now, but I have to say I like it. It makes sense to me to treat structures as objects with attributes and no methods. Im sold!
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.