SET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to assign value to individuale context attribute
The SET_ATTRIBUTE method assignes a value to an individual field of context element.
* Set single value within context structure
Data: it_scarr type standard table of if_MAIN=>element_CARRIERS, "view name = MAIN, context = CARRIERS
wa_scarr like line of it_scarr,
context_node type ref to if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element.
* bind this data to the context of the flat structure
context_node = wd_context->get_child_node( name = 'CARRIERS').
* CARRIERS' is the name of the context node
lr_element = context_node->get_element( ).
lr_element->set_attribute(
EXPORTING
value = '1234' " Attribute Value
name = 'CARRID' ). " Web Dynpro: Name of Context Element
The abap code below assigns a value to the CARRID field within the context table CARRIERS. The code below loops around each row recieved and updates the field on every row.
* Set single value within context structure
Data: it_scarr type standard table of if_MAIN=>element_CARRIERS, "view name = MAIN, context = CARRIERS
wa_scarr like line of it_scarr,
context_node type ref to if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element.
* Retrieve new data
select *
from scarr
into table it_scarr
where CARRID = 'AA' .
context_node = wd_context->get_child_node( name = 'CARRIERS').
* CARRIERS' is the name of the context node
* bind this data to the context of the table
context_node->bind_table( it_scarr ).
if sy-subrc eq 0.
loop at it_scarr into wa_scarr.
free lr_element.
free context_node.
context_node = wd_context->get_child_node( name = 'CARRIERS').
lr_element = context_node->get_element( sy-tabix ). "sy-tabix represents table row to reference
lr_element->set_attribute(
EXPORTING
value = '1234' " Attribute Value
name = 'CARRID' ). " Web Dynpro: Name of Context Element
endloop.
endif.
Also see here for how to use set_attribute to see how to bind all values within structure
using one abap statement.
|
||||