cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS deep level association - expose to service - problem

rosenpetrov
Explorer
0 Kudos
286

Hello i have 3 cds views and would like to expose the main view ZTEST_R1_ORD_MAIN as a service.
My aim is when the service is being executed to be able to return the data related to all items (view ZTEST_R1_ORD_VBAP) related to the root view and all schedule lines (view ZTEST_R1_ORD_VBEP) related to the items.
I.e. the structure is 3 levels deep:
ZTEST_R1_ORD_MAIN -> ZTEST_R1_ORD_VBAP -> ZTEST_R1_ORD_VBEP
and relations are performed via associations.
I export the root entity ZTEST_R1_ORD_MAIN via @odata.publlish:true

I perform tests via transaction /IWFND/GW_CLIENT.
I do have an access (via @expand=) to association which relates the 1st to the 2nd view (ZTEST_R1_ORD_MAIN -> ZTEST_R1_ORD_VBAP), i.e. association _item. And i can read the entries in _item association.
The problem is that i can NOT access association which relates 2nd to the 3rd view (ZTEST_R1_ORD_VBAP -> ZTEST_R1_ORD_VBEP), i.e. association: _schline. And i can NOT read the entities in _schline association.

I don't know if this is restriction of @odata.publish:true...
I have tried also with manually creating service and service binding - again without success.
Sap returns message like: _schline is not a recognizable object.

Here are the view definitions:

1st level view is exposed as a service via @odata.publish:true

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'x'
@Metadata.ignorePropagatedAnnotations: true
define root view entity ztest_r1_ord_main as select from vbak
association [1..*] to ztest_r1_ord_vbap as _item on $projection.vbeln = _item.vbeln
{
    key vbeln,
    vkorg,    
     
     _item
}

 2nd level view

@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'x'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #X,
    sizeCategory: #S,
    dataClass: #MIXED
}
define view entity ztest_r1_ord_vbap as select from vbap
association [1..*] to ztest_r1_ord_vbep as _schline on $projection.vbeln = _schline.vbeln and $projection.posnr = _schline.posnr

{
    key vbeln,
    key posnr,
    matnr,
    
    _schline    
}

3rd level view

@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'VBEP'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #X,
    sizeCategory: #S,
    dataClass: #MIXED
}
define view entity ztest_r1_ord_vbep as select from vbep
{
    key vbeln,
    key posnr,
    key etenr,
    
     @Semantics.quantity.unitOfMeasure: 'vrkme'
    bmeng,
    vrkme    
}

Please, give me an advice how to solve this.

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Kudos

how does your url look like? when you ask for third level data.

rosenpetrov
Explorer
0 Kudos

Here i apply the urls and resulting messages.
What bothers me more is that while strings "_item" and "to_item" (which are the IDs of association to the 2nd level) do exist in the service metadata file, the strings "_schline" and "to_schline" (which are the IDs of association to the 3rd level) do not exist in metadata file at all.
Also "vbap" exists in the metadata while "vbep" does not exist...

 

1) OK - root level only.

/sap/opu/odata/sap/ZTEST_R1_ORD_MAIN_CDS/ztest_r1_ord_main('5600010814')

2) OK - expand to vbap.

/sap/opu/odata/sap/ZTEST_R1_ORD_MAIN_CDS/ztest_r1_ord_main('5600010814')?$expand=to_item

 3) Error - expand to the deepest level - vbep - variant 1.

/sap/opu/odata/sap/ZTEST_R1_ORD_MAIN_CDS/ztest_r1_ord_main('5600010814')?$expand=to_item/to_schline

 Error message: Resource not found for the segment 'to_schline'.

4) Error - expand to the deepest level - vbep - variant 2.

/sap/opu/odata/sap/ZTEST_R1_ORD_MAIN_CDS/ztest_r1_ord_vbap?$filter=(vbeln eq '5600010814' )/to_schline

Error message: Left hand expression of memberaccess operator invalid

rosenpetrov
Explorer
0 Kudos

Here is the metadata, and i can see that the deepest view: ztest_r1_ord_vbep is not present here:

<edmx:DataServices m:DataServiceVersion="2.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="ZTEST_R1_ORD_MAIN_CDS" xml:lang="en" sap:schema-version="1">
<Annotation xmlns="http://docs.oasis-open.org/odata/ns/edm" Term="Core.SchemaVersion" String="1.0.0"/>
<EntityType Name="ztest_r1_ord_mainType" sap:label="x" sap:content-version="1">
<Key>
<PropertyRef Name="vbeln"/>
</Key>
<Property Name="vbeln" Type="Edm.String" Nullable="false" MaxLength="10" sap:display-format="UpperCase" sap:label="Sales Document"/>
<Property Name="vkorg" Type="Edm.String" MaxLength="4" sap:display-format="UpperCase" sap:label="Sales Organization"/>
<NavigationProperty Name="to_item" Relationship="ZTEST_R1_ORD_MAIN_CDS.assoc_387DEA92E80AB617BDBDCD4AE9F03350" FromRole="FromRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350" ToRole="ToRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350"/>
</EntityType>
<EntityType Name="ztest_r1_ord_vbapType" sap:label="x" sap:content-version="1">
<Key>
<PropertyRef Name="vbeln"/>
<PropertyRef Name="posnr"/>
</Key>
<Property Name="vbeln" Type="Edm.String" Nullable="false" MaxLength="10" sap:display-format="UpperCase" sap:label="Sales Document"/>
<Property Name="posnr" Type="Edm.String" Nullable="false" MaxLength="6" sap:display-format="NonNegative" sap:label="Sales Document Item"/>
<Property Name="matnr" Type="Edm.String" MaxLength="40" sap:display-format="UpperCase" sap:label="Material" sap:quickinfo="Material Number"/>
</EntityType>
<Association Name="assoc_387DEA92E80AB617BDBDCD4AE9F03350" sap:content-version="1">
<End Type="ZTEST_R1_ORD_MAIN_CDS.ztest_r1_ord_mainType" Multiplicity="1" Role="FromRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350"/>
<End Type="ZTEST_R1_ORD_MAIN_CDS.ztest_r1_ord_vbapType" Multiplicity="*" Role="ToRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350"/>
</Association>
<EntityContainer Name="ZTEST_R1_ORD_MAIN_CDS_Entities" m:IsDefaultEntityContainer="true" sap:message-scope-supported="true" sap:supported-formats="atom json xlsx">
<EntitySet Name="ztest_r1_ord_main" EntityType="ZTEST_R1_ORD_MAIN_CDS.ztest_r1_ord_mainType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1"/>
<EntitySet Name="ztest_r1_ord_vbap" EntityType="ZTEST_R1_ORD_MAIN_CDS.ztest_r1_ord_vbapType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1"/>
<AssociationSet Name="assoc_387DEA92E80AB617BDBDCD4AE9F03350" Association="ZTEST_R1_ORD_MAIN_CDS.assoc_387DEA92E80AB617BDBDCD4AE9F03350" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1">
<End EntitySet="ztest_r1_ord_main" Role="FromRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350"/>
<End EntitySet="ztest_r1_ord_vbap" Role="ToRole_assoc_387DEA92E80AB617BDBDCD4AE9F03350"/>
</AssociationSet>
</EntityContainer>
<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm" Target="ZTEST_R1_ORD_MAIN_CDS.ZTEST_R1_ORD_MAIN_CDS_Entities">
<Annotation Term="Common.ApplyMultiUnitBehaviorForSortingAndFiltering" Bool="true"/>
</Annotations>

 

junwu
SAP Champion
SAP Champion
0 Kudos
how about add that _item._schline to your root view?
rosenpetrov
Explorer
0 Kudos

_item._schline - not working

What do you think about missing view ztest_r1_ord_vbep in the service metadata ??

junwu
SAP Champion
SAP Champion
0 Kudos
how about creating project in segw and use rds to build your odata?
rosenpetrov
Explorer
0 Kudos
yes, segw is an option... what i have tried is to do this "in the new way", skipping segw
junwu
SAP Champion
SAP Champion
0 Kudos
pusblish:true, isn't that new, it just looks cool/neat. what is your system version?
rosenpetrov
Explorer
0 Kudos

What about manual service and binding definition, are there any annotations or whatever which could be used for explicit exposure of associations ? I tried with that too but without success.

The system version is:
SAP_ABA 75H
SAP_GWFND 757

rosenpetrov
Explorer
0 Kudos
Or maybe projection view ??