cancel
Showing results for 
Search instead for 
Did you mean: 

adding a node element violates cardinality

Former Member
0 Kudos

I have the following component context structure (cardinality of each node is in brackets):

CONTEXT

BAPI_RESERVATION_CRE (1..1)

CHANGING (1..1)

RESERVATIONITEMS (0..n)

the context node RESERVATIONITEMS has a supply function called FILL_DATA that has the code below: I am getting an error "Number of Elements of the Collection of Node COMPONENTCONTROLLER.

1.BAPI_RESERVATION_CRE.1.CHANGING.1.RESERVATIONITEMS Violates the Cardinality". Can somebody help me?

method FILL_DATA .

DATA: node_level1 type ref to if_wd_context_node,

node_level2 type ref to if_wd_context_node,

node_items type ref to if_wd_context_node.

node_level1 = wd_context->get_child_node( name = 'BAPI_RESERVATION_CRE' ).

node_level2 = node_level1->get_child_node( name = 'CHANGING' ).

node_items = node_level2->get_child_node( name = 'RESERVATIONITEMS' ).

node_items->create_element( ).

endmethod.

Accepted Solutions (1)

Accepted Solutions (1)

former_member215843
Active Participant
0 Kudos

Hi Tiberiu,

Your supply function does not do much, and after this function is executed, the number of elements in the node is <b>0</b>!

First of all: Why do you navigate to the node? It is passed as a parameter to the supply function. Navigation is always dangerous, because you will always navigate along the lead-selection path, and if you want to fill a different node instance, this does not work.

Use the parameter <b>node</b>!

At the end of this method one element is created, but it is not bound to the node. Therefore calling a "bind"-method is necessary.

You could use

node->bind_element( )

with the element you just created.

But you could also fill a structure with the data you want to add to the node, and the call

node->bind_structure( my_structure )

or you could fill an internal table with some lines of data, and call

node->bind_table( )

.

Anyway, I cannot believe that an error is raised in this case, because 0 elements is quite valid for a node with cardinality 0..n.

Only if you have declared it as "1..1" or "1..n" it should raise the error.

Ciao, Regina

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

When you specify a supply function name in your context, the parameter Node will be automatically available in it. All you have to do is fetch the data that you want and bind it. That will do the needful.

Regards

Nithya

mohammed_anzys
Contributor
0 Kudos

Hi

If you are assigning a supply function to a node , then the cardinality cannot be set as 0.It should be set as 1-n or 1-1 according to your specifications.In short, if you have assigned a supply function , the cardinality shoudl be atleast 1 else it will throw error.

Thanks

Anzy