on 05-09-2007 1:19 PM
Hi all,
I need to add a new element inoto a node of cardinality 0..n.
Just like "add" method in webdynpros for JAVA. is there any method which would dothe same here in ABAP dynpros.
Thanks in advance,
Sethu
Hi,
see the Add methods mentioned <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/7e/a23742c4f5b16be10000000a155106/frameset.htm">here</a>
Regards, Heidi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
In WD ABAP, adding a new element to a node is performed in two steps. The first step is to create an element that can be added to a certain context node later. After the attribute values have been defined, the new element can be added to the context node. This is like the process of adding a new line to an internal table. The first step is to define the cell values of a work area having the correct line type, and the second step is to insert the work area into the internal table. Creating a New Node Element In order to create an element that can be added to a certain context node, the reference to this node has to be determined first. This is done by using the get_child_node( ) method of the standard attribute WD_CONTEXT, pointing to the context root node. Getting the Reference to a Context Node Once you have obtained this reference, the method create_element( ) is used to create the new element. Initial values for the static attributes can be submitted using the static_attribute_values parameter or the attribute values can be defined using the setter methods set_attribute( ) or set_static_attributes( ).
Caution: The new element is not yet part of the context node!.
Finally, an element, which is not yet part of the context node can be added to the node using the method bind_element( ) related to the node reference. This method has two import parameters: • The element reference is submitted via the parameter new_item. • Theparameterset_initial_elements defines if the new element is just added to the element collection (value = abap_false) or if the new element replaces all existing elements in the collection (value = abap_true).
Sample code:
DATA:
stru_person_01 TYPE if_componentcontroller=>element_person_01,
stru_person_11 TYPE if_componentcontroller=>element_person_11.
PERSON_01 ***************************************
Get reference to context node PERSON_01
wd_this->node = wd_context->get_child_node( name = `PERSON_01` ).
Create context element
wd_this->element = wd_this->node->create_element( ).
Set attribute values
stru_person_01-name = 'Ehret'.
stru_person_01-first_name = 'Stefan'.
stru_person_01-birthday = '20060316'.
wd_this->element->set_static_attributes( static_attributes = stru_person_01 ).
Add element to context node - Existing elements will not be deleted
wd_this->node->bind_element( new_item = wd_this->element
set_initial_elements = abap_false ).
You can refer Web Dynpro component NET310_CONR_D1.
Best regards,
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
METHOD onactionon_add .
DATA:
node_bo TYPE REF TO if_wd_context_node,
elem_bo TYPE REF TO if_wd_context_element,
stru_bo TYPE if_first1_view=>element_bo ,
item_object LIKE stru_bo-object.
navigate from <CONTEXT> to <BO> via lead selection
node_bo = wd_context->get_child_node( name = if_first1_view=>wdctx_bo ).
get element via lead selection
elem_bo = node_bo->get_element( ).
get single attribute
elem_bo->get_attribute(
EXPORTING
name = `OBJECT`
IMPORTING
value = item_object ).
DATA:
node_list TYPE REF TO if_wd_context_node,
elem_list TYPE REF TO if_wd_context_element,
stru_list TYPE if_first1_view=>element_list ,
item_steps LIKE stru_list-steps.
navigate from <CONTEXT> to <LIST> via lead selection
node_list = wd_context->get_child_node( name = if_first1_view=>wdctx_list ).
get element via lead selection
elem_list = node_list->get_element( ).
get single attribute
elem_list->get_attribute(
EXPORTING
name = `STEPS`
IMPORTING
value = item_steps ).
DATA:
lt_attributes type standard table of if_first1_view=>elements_workflow ,
wa_attributes type if_first1_view=>element_workflow ,
wa_attributes like line of lt_attributes,
node_workflow TYPE REF TO if_wd_context_node,
elem_workflow TYPE REF TO if_wd_context_element .
.
navigate from <CONTEXT> to <WORKFLOW> via lead selection
node_workflow = wd_context->get_child_node( name = if_first1_view=>wdctx_workflow ).
wa_attributes-STEPS = item_steps.
wa_attributes-OBJECT = item_object.
*insert wa_attributes into table lt_attributes.
node_workflow->bind_element(
new_item = wa_attributes
set_initial_elements = abap_false
).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.