cancel
Showing results for 
Search instead for 
Did you mean: 

Filling Node and Subnode..

Former Member
0 Kudos

Hey Everyone, i have a node (1..n) and subnode (1..n). The node has two other attributes as well. And subnode has mutliple other attributes.

so like:

Node:

-subnode

->>s_att1

->>s_att2

-att1

-att2

the node gets values from one table and the subnode from another table.

So what i want to do is, select values for att1 and att1 into an internal table, then within a loop pass values for subnode for each corresponding att1,att2.

i have tried diffent ways but it keep getting, Node violates cardinality. - so i am not filling the node/subnode the right way.

thanks..

Edited by: imatari on Apr 5, 2010 5:13 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Your node and subnode have cardinality as 1..N, generally when you bind your nodes to table control, your cardinality should be 0..N as table might not have any result row also.

In your case, you are fetching attr1 and attr2 and then try to fill subnode. May be ur trying to get the node element reference which is not there hence you are getting an error, just change the cardinality of subnode to 0..N

Hope this helps

Regards

Manas Dua

Former Member
0 Kudos

Hey Manas,

i changed the cardinality ofthe subnode to 0..n but i still get : subnode violation cardinality.

So i think i am still not filling the node right.. this is what i am doing...

"i give values to the att1, att2, of node. and bind with :

node->bind_structure( new_item = ls_node set_initial_elements = abap_true ).

'then i select all the values for subnode put it into a table.. lt_subnode. then i bind it to subnode.

subnode->bind_table( new_items = lt_subnode set_initial_elements = abap_true ).

Edited by: imatari on Apr 5, 2010 8:53 PM

Edited by: imatari on Apr 5, 2010 8:54 PM

Edited by: imatari on Apr 5, 2010 9:28 PM

Former Member
0 Kudos

Hey every, now i can get the display to work without error.. BUT :

Node is filled alright, but the subnode all its elements are under Node (att1). Nothing is populated under Node(att2).

i think its something to do with the way filling the subnode..

is there a way to call the node depending on the index.. so that each time i will call the index of subnode that i want to fill.

thanks

Former Member
0 Kudos

I found the solution...

All you have to do is :..

1. fill the att1, att2 of Node using : make sure set_initial_elements = false . the next row...

lo_nd_node->bind_structure( new_item = ls_node set_initial_elements = abap_false ).

2. fill the subnode via index...

pass the subnode index you are filling. I was looping so i passed sy-tabix. You also might need to CONDENSE index_str NO-GAPS.

index_str = sy-tabix.

make the string path.. the format is like, rootnode.index.subnode... so in my case Node.1.subnode : for first row, etc

CONCATENATE `Node.` index_str `.Subnode` into node_path.

get the node using nodepath you made

lo_nd_subnode = wd_context->path_get_node( path = node_path ).

bind an internal table with contents you want to fill the subnode with.

lo_nd_subnode->bind_table( lt_subnode ).

Note. Like Manas mentioned, watchout for cardinality of your nodes, If you get Error Messages like: Assert Condition Failed, Subnode Violates Cardinality, its probably because of your Cardinality..

Thanks..

Edited by: imatari on Apr 6, 2010 10:28 PM

Answers (0)