Hi,
I have come across many scn threads which refer to "How to read / get data from a dynamic node" .
Here I would like to demonstrate, the steps to read the data from a node ( either static / dynamic node ) in Webdynpro ABAP.
I have divided the task into 3 methods
All you need to do is ... just create these 3 methods as is and start using for reading data from a given node ( either static node / dynamic node )
Now, let us look into the code of each method as below
GET_NODE_INFO( )
Parameters:
Parameter | Type | Ref To | Optional | Associated Type | Description |
---|---|---|---|---|---|
ID_NODE_NAME | Importing | STRING | Node Name | ||
IO_PARENT_NODE | Importing | Checked | Yes | IF_WD_CONTEXT_NODE | Parent Node Reference |
EO_NODE_INFO | Exporting | Checked | IF_WD_CONTEXT_NODE_INFO | Node info reference | |
ED_ERROR_MESSAGE | Exporting | STRING | error message | ||
EO_NODE | Exporting | Checked | IF_WD_CONTEXT_NODE | Node reference |
Logic:
GET_NODE_INFO |
---|
METHOD get_node_info .
TRY. "============================================= "=============================================
CATCH cx_root INTO lx_root.
|
----------------------------------------------------------
GET_NODE_DATA_TYPE( )
Parameters:
Parameter | Type | Ref To | Optional | Associated Type | Description |
---|---|---|---|---|---|
IO_NODE_INFO | Importing | Checked | IF_WD_CONTEXT_NODE_INFO | Node info Reference | |
ED_ERROR_MESSAGE | Exporting | STRING | Error message | ||
EO_DATA | Exporting | Checked | DATA | Node data type ref | |
ET_FCAT | Exporting | LVC_T_FCAT | Attributes/fields list |
Logic:
GET_NODE_DATA_TYPE |
---|
METHOD GET_NODE_DATA_TYPE .
IF io_node_info IS NOT BOUND. ENDIF.
LOOP AT lt_attr INTO ls_attr. ENDLOOP. cl_alv_table_create=>create_dynamic_table(
CREATE DATA eo_data LIKE LINE OF <lt_table>. ENDIF. |
----------------------------------------------------------
GET_DATA( )
Parameters:
Parameter | Type | Ref To | Optional | Associated Type | Description |
---|---|---|---|---|---|
IO_NODE | Importing | Checked | IF_WD_CONTEXT_NODE | Node reference | |
ED_ERROR_MESSAGE | Exporting | STRING | Error message | ||
EO_DATA | Exporting | Checked | DATA | Data | |
ET_FCAT | Exporting | LVC_T_FCAT | Fields |
Logic:
GET_DATA |
---|
METHOD GET_DATA .
FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE,
IF io_node IS NOT BOUND.
" Return if any error or data type is not bound RETURN.
" get the no. of elements available in context node " do for each element " collect index value " Create a blank line and get the ref into <ls_dat> " Loop over each field/attribute and get the data ASSIGN COMPONENT ls_fcat-fieldname IF <lv_value> IS ASSIGNED. io_node->get_attribute( ENDLOOP. ENDDO. CATCH cx_root INTO lx_root. |
----------------------------------------------------
Example:
Scenario: Let us say we need to read data from a node "NODE_DYN".
Example |
---|
-------------------------- " Data declarations
FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.
" Get node information wd_this->get_node_info(
" Get the data from context node
wd_this->get_data( " assign data into dynamic table
ASSIGN lo_data->* to <lt_data>. -------------------------- |
The internal table <lt_data> contains the data of our node "NODE_DYN"
Hope this helps for those looking for reading the data of any given node ( dynamicnode / static node )
I appreciate if any comments/suggestions from you :smile:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 |