on 2021 Feb 11 6:17 AM
I am extending the functionality of the SAP Asset Manager (SAM) v2005 MDK mobile application. My MDK iOS client was built using MDK Client SDK v4.3.2. I have extended SAM to interface with a non-SAP OData data source using the offline approach. I have one entity set named "Submissions" that is provided/managed by my non-SAP OData service. So far, with my extended SAM functionality I can...
All the above works as expected. However, I run into an issue when I attempt to update the downloaded Submission entity using the same UpdateEntity Action that was used to successfully update the "local" Submission entities previously. At this point, the MDK Client crashes. No reason for the crash is provided. Only a stack trace is output to the console...
NativeScript caught signal 11.
Native Stack:
1 0x104b10251 sig_handler(int)
2 0x7fff522ab5fd _sigtramp
3 0xffff000112d902d7
4 0x112c9d6b0 lodata::ModifyHandler::performLocalModify(lodata::ModifyRequest*, lodata::RequestStatus*, lodata::EntityTypeInstance const*, lodata::EntitySet const*, lodata::EntityTypeInstance const*, lodata::EntitySet const*, lodata::TransactionInfo*, bool)
JS Stack unavailable. Current thread hasn't initialized a {N} runtime
Using the debugging facility of the Visual Studio Code MDK extension to inspect the Submission entity read (i.e.- queried) from the local non-SAP OData data store, I can see distinct differences between "local" Submission entities versus Submission entities "downloaded" from the non-SAP OData data source. The following two pictures show a subset of data attributes associated with the same entity. The first picture reflects when the entity was initially "local". The second picture reflects the entity after is was uploaded and processed by the non-SAP OData data source, and subsequently downloaded back to the same SAM mobile app instance.
"Local" Submission properties...
"Downloaded" Submission properties...
This is the "Create Submission Entity" Action...
This is the "Update Submission Entity" Action...
I enabled OData tracing in the MDK Client. Unfortunately, no trace information is output when the exception occurs.
Based on the "lodata" references in both the exception stack trace, as well as in the "local" entity's assigned UID value, it appears that the "UpdateEntity" Action is (possibly) expecting to only target a "local" (i.e.- a locally created) entity.
What do I need to differently when I need to update an entity that has been downloaded from an OData data source?
Or am I possibly missing required configuration information in my OData data source's EDM and/or in my Mobile Services destination for the non-SAP OData data source?
Thank you.
The MDK client crash was due to the fact that our JSON representation of entities from our non-SAP OData data source did not include the "__metadata" key/value pair.
In the limited OData v2 documentation we were able to find, the "__metadata" key is described as being optional - except for Media Link Entries. Upon adding the "__metadata" key (whose value is an object that contains the keys "id" and "uri") to all our entity data representations, the MDK client crash no longer occurs when attempting to update an entity that was downloaded from our remote OData data source.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Update Entity action does not have any special knowledge of online or offline. It can be defined against either type of service and when offline can be used to update both an existing (i.e. downloaded item) or a locally created item that has not been synchronized to the backend.
Offline odata adds the two additional properties you mentioned to help developers understand the state of the record.
@sap.isLocal true indicates the record was created locally and has not been synchronized to the backend yet.
@sap.hasPendingChanges true indicates that the record has been changed locally and not synchronized to the backend yet.
So for a newly created record both @sap.isLocal and @sap.hasPendingChanges will be true. For a downloaded record that has been updated only @sap.hasPendingChanges would be true.
For record just downloaded from your odata service, both would be false.
You should not have to do anything different in your Update action depending on if the record is locally created versus just downloaded from the backend.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.