cancel
Showing results for 
Search instead for 
Did you mean: 

Model provider issue

Former Member
0 Kudos

Hi,

I've created a custom class that inherits from /IWBEP/CL_MGW_ABS_MODEL.

In the class I have defined types:

*----


types:

begin of HEARTBEAT_S,

SERVERID type /SKY/YECSSRVID,

SERVERTYPE type /SKY/YECSSRVTYP,

TITLE type string,

end of HEARTBEAT_S.

types:

HEARTBEAT_T type standard table of HEARTBEAT_S.

*----


I've then redfined my DEFINE method:

*----


data: lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ,

lo_property type ref to /iwbep/if_mgw_odata_property.

  • Setup Heartbeat entity

lo_entity_type = model->create_entity_type( 'Heartbeat' ).

  • Setup properties

lo_property = lo_entity_type->create_property( iv_property_name = 'ServerId'

iv_abap_fieldname = 'SERVERID' ).

lo_property->set_is_key( ).

lo_property = lo_entity_type->create_property( iv_property_name = 'ServerType'

iv_abap_fieldname = 'SERVERTYPE' ).

lo_property = lo_entity_type->create_property( iv_property_name = 'Title'

iv_abap_fieldname = 'TITLE' ).

lo_property->set_as_title( iv_keep_in_content = abap_false ).

  • Bind the structure & create the entity set

lo_entity_type->bind_structure( 'Z_CL_TIM_MODEL_PROVIDER=>HEARTBEAT_S' ).

lo_entity_type->create_entity_set( 'Heartbeats' ).

*----


I've created an empty data provider class that inherits from /IWBEP/CL_MGW_ABS_DATA & then created the technical model that links the model provider class & data provider class & activated the service.

The issue I'm facing is that when I hit the URL to view the xml, the document provided back is missing the collection details:

*----


<?xml version="1.0" encoding="utf-8"?>

<app:service

xml:base="http://nplhost:8042/sap/opu/sdata/sap/HEARTBEAT/"

xmlns:app="http://www.w3.org/2007/app"

xmlns:atom="http://www.w3.org/2005/Atom"

xmlns:sap="http://www.sap.com/Protocols/SAPData">

<app:workspace sap:semantics="things">

<atom:title>Things</atom:title>

</app:workspace>

<app:workspace sap:semantics="data">

<atom:title>Data</atom:title>

</app:workspace>

</app:service>

*----


Any assistance would be greatly appreciated.

Tim

Accepted Solutions (1)

Accepted Solutions (1)

wbrown
Participant
0 Kudos

Hi Tim,

I was able to get the collection details back from your example. (The only thing that I had to change was define /SKY/YECSSRVID and /SKY/YECSSRVTYP locally, just a simple char string).

<?xml version="1.0" encoding="utf-8" ?>

- <app:service xml:base="http://nplhost:8042/sap/opu/sdata/sap/Z_TIM_MODELGRP/" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:gp="http://www.sap.com/Protocols/SAPData/GenericPlayer" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

- <app:workspace sap:semantics="things">

<atom:title>Things</atom:title>

</app:workspace>

- <app:workspace sap:semantics="data">

<atom:title>Data</atom:title>

- <app:collection href="Heartbeats" sap:content-version="1">

<atom:title>HeartbeatCollection</atom:title>

<sap:member-title>Heartbeat</sap:member-title>

</app:collection>

</app:workspace>

</app:service>

and the metadata returned was

<?xml version="1.0" encoding="utf-8" ?>

- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:gp="http://www.sap.com/Protocols/SAPData/GenericPlayer" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData">

- <edmx:DataServices m:DataServiceVersion="2.0">

- <Schema Namespace="Z_TIM_MODELGRP" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

- <EntityType Name="Heartbeat" sap:content-version="1">

- <Key>

<PropertyRef Name="ServerId" />

</Key>

<Property Name="ServerId" Type="Edm.String" Nullable="false" MaxLength="48" sap:filterable="false" />

<Property Name="ServerType" Type="Edm.String" MaxLength="60" sap:filterable="false" />

<Property Name="Title" Type="Edm.String" sap:filterable="false" m:FC_TargetPath="SyndicationTitle" m:FC_KeepInContent="false" />

</EntityType>

- <EntityContainer Name="Z_TIM_MODELGRP" m:IsDefaultEntityContainer="true">

<EntitySet Name="Heartbeats" EntityType="Z_TIM_MODELGRP.Heartbeat" sap:content-version="1" />

</EntityContainer>

</Schema>

</edmx:DataServices>

</edmx:Edmx>

How did you define the Ojbect Model and the Service in the IMG?

Under,

SAP NetWeaver->SAP NetWeaver Gateway Business Suite Enablement->Backend OData Channel -> Maintain Object Models and Maintain Service

Then activate the services under

SAP NetWeaver->Gateway->Administration->OData Channel->Activate Services

Please let me know if I missed something,

Hope this helps.

Regards,

Wayne

Former Member
0 Kudos

Hello Wayne,

I suspect if the issue is due to the types /SKY/YECSSRVID and /SKY/YECSSRVTYP.

I suspect the issue can be due to caching of metadata in Gateway.

@Tim,

If you have redefined the method GET_LAST_MODIFIED in the model provider class, make sure that the method returns the latest timestamp when the model got changed.

Secondly try refreshing the metadata cache for your model in Gateway. The IMG is SAP NetWeaver->Gateway->Administration->Cache Settings->Metadata->Cleanup Cache.

I hope this solves the issue.

Cheers

Chandan

Former Member
0 Kudos

Hi Chandan,

Thanks for the info.

I hadn't redefined the GET_LAST_MODIFIED method in my model class.

I checked the metadata cache - strangely my model wasn't listed ???

Regardless, I ticked the clear all checkbox & now when I hit the URL for the service metadata all is displayed.

Thanks for your help.

Tim

justin_starr
Explorer
0 Kudos

I had the same problem and refreshing the cache in SPRO. My Model didn't show up in the list of models either but the "Cleanup Cache for all Models" worked.

However, I've also now redefined the GET_LAST_MODIFIED method and set a breakpoint. But it never seems to be called unless I clean up the cache. And then it doesn't get called until I clean up the cache again. I looked for an OSS Note on this issue but I haven't found one.

Answers (0)