3 weeks ago - last edited 3 weeks ago
Hello everyone,
I want to create a parent child relationship as shown here:
The problem is when I want to create the behavior definition of the sub-child in the same BDEF as its grand parent (root view) exist, I can't define the lock dependency for the sub-child because there is no direct association between root entity and sub-child entity. it would give the following error:
"The behavior definition is "managed", which means that every entity must be flagged either as a "lock master" or as "lock dependent". So, how to define the behavior of sub-child in the same behavior definition file of its grand parent?
Note: The association is sub-child to child and from child to root.
The second question is: How to expose the child and sub-child entities as embedded element of the parent entity? Now I can access the child entity with "/to_child" but I want to be able to use $expand parameter in the URI. Service bind is based on "OData V2 - Web API".
I mean something like:
<Root>
<element1></element1>
<element2></element2>
<childElement>
<element1></element1>
<subChildElement></subChildElement>
</childElement>
</Root>
Source Codes:
1. Root view
define root view entity /CYCLES/t811c_view
as select from t811c
composition [0..*] of /CYCLES/t811s_view as _segments
composition [1..*] of /CYCLES/T811G_view as _groups
{
key tab,
key cycle,
key sdate,
edate,
rstatus,
_segments,
_groups
}
2. Child View
define view entity /CYCLES/t811s_view
as select from t811s
association to parent /CYCLES/t811c_view as _header on $projection.tab = _header.tab
and $projection.cycle = _header.cycle
and $projection.sdate = _header.sdate
composition [1..*] of /CYCLES/T811k_view as _keyfields
composition [1..*] of /CYCLES/T811F_view as _elementtable
{
key tab,
key cycle,
key sdate,
key seqnr,
name,
_header,
_keyfields,
_elementtable
}
3. Sub-child View
define view entity /CYCLES/T811k_view
as select from t811k
association to parent /CYCLES/t811s_view as _segment on $projection.tab = _segment.tab
and $projection.cycle = _segment.cycle
and $projection.sdate = _segment.sdate
and $projection.seqnr = _segment.seqnr
{
key tab,
key cycle,
key sdate,
key seqnr,
key setkind,
key pos,
field,
setname,
valmin,
valmax,
setid,
/* Association */
_segment
}
4. Behavior Definition of Root view
managed implementation in class /cycles/bp_t811c_view unique;
define behavior for /CYCLES/t811c_view alias header
persistent table t811c
lock master
//authorization master ( instance )
//etag master <field_name>
{
create;
update;
delete;
association _groups { create; }
association _segments { create; }
}
define behavior for /CYCLES/T811G_view alias group
persistent table t811g
lock dependent by _header
//authorization dependent by <association>
//etag master <field_name>
{
update;
delete;
field ( readonly ) tab,cycle,sdate;
association _header;
}
define behavior for /CYCLES/t811s_view alias segments
persistent table t811s
lock dependent by _header
//authorization dependent by <association>
//etag master <field_name>
{
update;
delete;
field ( readonly ) tab,cycle,sdate;
association _header;
}
/************************************
Here it gives the error
************************************/
define behavior for /cycles/t811k_view alias keyfields
persistent table t811k
{
update;
delete;
field ( readonly ) tab,cycle,sdate,seqnr;
association _segment;
}
Thanks in advance.
User | Count |
---|---|
78 | |
11 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.