cancel
Showing results for 
Search instead for 
Did you mean: 

how to populate node with in node

Former Member
0 Kudos

Hi,

I have scnerio to populate a node which has Header and items.

For example Sales Order.

-> Order

!-> Order No.

|-> Items

-> Item_No

-> Material No

-> Quantity

-> Price

Order can have more than one item, so cardinality is 1..n for item.

How I can populate Order node, with a single order No. and multiple items.

Cheers,

Sam

Accepted Solutions (0)

Answers (1)

Answers (1)

shwetars
Advisor
Advisor
0 Kudos

Hi Senthil,

you need to have a order node with it header details of cardinality 1..n, under this have one more node called items with cardinality 0..n, within the method where you populate these nodes create the order node first and for each order node create its item nodes. the item node will act as its child nodes. they will exist only when the order node exists.

The hierarchy can be as follows:

Node: Order Cardinality: 1..n, Selection: 0..1, Initialization Lead Selection: true

--->attribute1 - OrderNo type aufnr

--->Node: Item Cardinality: 0..n, Selection: 0..1, Initialization Lead Selection: false

-->attribute1: Item_No

-->attribute2: Material_No

-->attribute3: Quantity

-->attribute4: Price

Sample code for data population:

node_order = wd_context->get_child_node( 'NODE_ORDER' ).

elem_order = node_order->get_element( ).

elem_order->set_attribute( 10000 ). "set order number

node_item = node_order->get_child_node( 'NODE_ITEM' ).

"here create an internal table of type items node fill it with appropriate data with respect to the order

node_item->bind_table( new_items = itab_items ).

Hope the idea is clear.

Regards,

Shweta

Former Member
0 Kudos

Hi,

Thank you for Ur reply.

While reading back Order context, I can just select the order and read child node item, so I will get the Order with respective items in that order. Right..

Cheers,

Senthil

shwetars
Advisor
Advisor
0 Kudos

Yes you are right.

For each order there will be an item list.

Former Member
0 Kudos

Hi Shweta,

I unable to upload data in to the context in the way we discussed.

How to relate the parent with child node.

Here is my code.

Parent node Operation contains a single attribute 'op_no' & 2 child nodes.

Child nodes Material & Services

Elem_Oper->get_Static_Attributes(

importing

Static_Attributes = Stru_Operation ).

Here after a getting operation data.

elem_material = node_operation->get_child_node( Name = wd_This->wdctx_Material ).

Do U think this will fetch the child node aith respect to the parent node.

I could see there is no relationship since we refer at the Node level not at the element level.

Cheers,

Senthil

Former Member
0 Kudos

Hi Senthilkumar.

You could use supply methods for the child nodes. As soon as a new Operations element is created the supply methods of the child nodes are called automatically.

In the supply method you have access to the parent element (Operation) and regarding the attributes of this operation you can select all materials or services and bind them to the child node.

Hope this helps.

Cheers,

Sascha