on 05-14-2013 8:28 PM
Dear All
We have a requirement to create an OData Services with complex type . Structure of this type is as follows
Zparent (Structure name)
| name- String
|--------| Table of ZChild (Structure name)
|-------- name- string
|---------value- String
Has anyone tried it and if yes what are the basic fundamental steps to accomplish it
I am a newbie therefore need some guidance
Points will be rewarded
Thanks in advance
Gaurav
Hi Gaurav,
Complex Type is not the right technique to represent a parent child relationship of cardinality 1:N. A complex type inside an Entity works a group of individual properties. This is useful when you want to reuse same group in many Entities(or in Action). For example, consider a service with entity Customer and Invoice. Entity Customer has properties a) HomeAddress b)OfficeAddress , entity Invoice has property ShippingAdress. So technically all three properties are of complex type Address . Moreover complex type is nothing but a structure, so it can not hold multiple values.
Now to address your requirement, you have to create Parent and Child entities separately. Then you have to create association between them where you can put your desired cardinality(here may be 1:N). Next you have to create a navigation property for the parent using this association. Hope this is helpful.
regards,
Atanu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply
I have few more questions , even though I am able to define the association and create a cardinality of 1 for parent and 1..n for child .
Do I necessarily need to create Entity Sets as well?
If yes , then how do I use the association defined earlier
Do we need to define any referential integrity constraints etc as well?
Hi Gaurav ,
These are the step for simple service ....
1. Create Two Entity ( Parent and Child ).
2. Create EntitySet (ParentCollection and ChildCollection) For about Entities
3. Create Association ParentAssnChild For Entity Parent and Child (based on ur scenario it will 1..n as u a mentioned above)
4. Create Association set ParentAssnSetChild for association ParentAssnChild with entityset ParentCollection and ChildCollection.
5. Goto Entity Parent create an navigation properties Provide Link name : ChildLink and Association ParentAssnChild which is created above
Regards,
Jibin Joy
Thanks a lot Jibin
So if understood correctly we can have atomic structures and defined their relationship or cardinallity by associations in Odata service .However if we have hierarchical structures then it may not work very well because get_entity_set method generally will return data only on one structure so even if we have hierarchical structure we cannot copy it to et_entity_set because entity set expects an atomic structure and not a hierarchical structure
Thanks in advance
Gaurav
Hi Gaurav,
this can be overcome by $expand parameter ....
Reference ...
2. http://scn.sap.com/thread/3238025
Regards,
Jibin Joy
Hello,
Am i right that with this approache i will able to have access to ChildSet during design time in DPC ?
I've create Parent which have ChildSet 1:n
I was wondering that at runtime i will have struct like this
ParentVal1
ParentVal2
ChildSet (like table)
Please answer or refer me to corect sources/tutorial
BR
Lucas
Hi Gaurav ,
There are two ways to making an complex Entity
1. Direct Way - Adding Complex Type in the Entity
Problem with this way is that it is a 1:1 relationship . Its behavior like "append" and "include" in DDIC But based on scenario, nested structure (ZChild) is a table so this technique is not possible .
2. In-direct Way - Making relationship between two entity using association
Based on my experience ur requirement can be done by creating two entity zparent as well as zchild . Cardinality can be handled in the association corresponding to this entity.
Regards,
Jibin Joy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.