Hello... Welcome :smile:
While developing complex WDA applications, we may have to have many context nodes defined and its very much required to get and set data from/to these context nodes.
For getting and setting data from/to a context node, we need to follow the below process
If we have many nodes in our application, say around 10-15 context nodes, we have to repeat above steps for each read/write data access
So, its better idea to have a common method for getting data from context node / for setting data to context node.
HELPER CLASS:
You would be wondering why this HELPER CLASS is needed ?,
It very much helpful to have all common methods in a class and it can be called from any view/ controller method.Hence,it is named as helper class to my application.
I have created the below 2 static methods in class ZCL_WD_HELPER_CLASS
Now, let us look at these methods signature & logic :smile:
Method: GET_CTX_STAT_ATTR( ).
Signature:
Logic:
GET_CTX_STAT_ATTR |
---|
METHOD get_ctx_stat_attr. FIELD-SYMBOLS: <lt_stat_attr> TYPE STANDARD TABLE, "===================================
" Return if node is not dirty, and caller wants values only if dirty "get node info "get the type descriptor of node lv_type_name = lo_nd_struct_descr->get_relative_name( ). "============================================ IF lo_nd_info->is_multiple( ) EQ abap_true AND "============================================ IF lo_typedescr_target->kind NE "create data object based cardinality ASSIGN lo_stat_data->* TO <lt_stat_attr>.
ed_stat_attr = <lt_stat_attr>. "============================================
"create data object based cardinality ASSIGN lo_stat_data->* TO <ls_stat_attr>. IF <ls_stat_attr> IS ASSIGNED.
|
Okay, now let us see how to use the method GET_CTX_STAT_ATTR( ) to get data from context node
Example:
Get data : Let us say we have a context node MY_NODE_T in component controller context with cardinality 0....n /1..n
DATA lt_my_node_t TYPE wd_this->elements_my_node_t.
DATA lv_error_message TYPE string.
CALL METHOD zcl_wd_helper_class=>get_ctx_stat_attr
EXPORTING
io_context = wd_context
id_node_name = 'MY_NODE_T'
* id_index = 0
* ib_only_if_dirty = ABAP_FALSE
IMPORTING
ed_stat_attr = lt_my_node_t
ed_error_message = lv_error_message.
Get data : Let us say we have a context node MY_NODE_S in component controller context with cardinality 0....1 / 1...1
DATA ls_my_node_s TYPE wd_this->element_my_node_s.
DATA lv_error_message TYPE string.
CALL METHOD zcl_wd_helper_class=>get_ctx_stat_attr
EXPORTING
io_context = wd_context
id_node_name = 'MY_NODE_S'
* id_index = 0
* ib_only_if_dirty = ABAP_FALSE
IMPORTING
ed_stat_attr = ls_my_node_s
ed_error_message = lv_error_message.
Continued.......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |