Hello welcome again 🙂
Hope, you have gone through the below link for custom getter method GET_CTX_STAT_ATTR( )
Custom getter & setter methods in Webdynpro ABAP – Part 1
Now, let us look into to the method SET_CTX_STAT_ATTR( ).
Method: SET_CTX_STAT_ATTR( )
Signature:
Logic:
Header 1 |
---|
METHOD set_ctx_stat_attr. “—————————————————- “=================================== “based on node cardinality, bind data ELSE. ENDIF. |
Now let us create 2 private methods as below
- CTX_BIND_TABLE( ) – Bind table to context node – For Internal use only
- CTX_BIND_STRUCTURE( ) – Bind structure to context node – For Internal use only
Method: CTX_BIND_TABLE( )
Signature:
Logic:
CTX_BIND_TABLE |
---|
METHOD CTX_BIND_TABLE. FIELD-SYMBOLS: <lt_stat_attr> TYPE STANDARD TABLE. CLEAR: ed_error_message, IF io_node IS BOUND. “check if the type name is used from context node IF lv_id_type_name EQ lv_temp_type_name. IF lv_id_type_name EQ lv_nd_type_name. |
Method: CTX_BIND_STRUCTURE( )
Signature:
Logic:
CTX_BIND_STRUCTURE |
---|
METHOD CTX_BIND_STRUCTURE. DATA lo_str_descr TYPE REF TO cl_abap_structdescr. CLEAR: ed_error_message, IF io_node IS BOUND. |
Now, let us see how to bind data to context node by using method SET_CTX_STAT_ATTR( ).
Example:
Set 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=>set_ctx_stat_attr
EXPORTING
io_context = wd_context " WD Context ref
id_node_name = 'MY_NODE_T' " Ctx Node Name
id_stat_attr = lt_my_node_t
* id_set_dirty = ABAP_FALSE
IMPORTING
ed_error_message = lv_error_message.
Set 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->elements_my_node_s.
DATA lv_error_message TYPE string.
CALL METHOD zcl_wd_helper_class=>set_ctx_stat_attr
EXPORTING
io_context = wd_context " WD Context ref
id_node_name = 'MY_NODE_s' " Ctx Node Name
id_stat_attr = ls_my_node_s
* id_set_dirty = ABAP_FALSE
IMPORTING
ed_error_message = lv_error_message.
Hope this helps for those who are looking for a common logic in place to get and set data from/to context node in WDA applications 🙂 🙂 🙂
I appreciate your comments/feedback 🙂
Hi Ramakrishnappa,
Its as informative as first part of series. Keep up good work. Thanks for this informative step by step guide.
Regards,
Saurabh
Hi Saurabh,
Thank you for going through the document and I appreciate your compliments 🙂
Happy that you are finding this document as useful.
I would be looking forward to you as an active member and keep going 😉
Regards,
Rama