Hi colleagues,
I’m hoping someone will be able to help or at least point me into the right direction.
I’m facing some problems with my project being developed using Fiori/ SAP UI5 (using Web IDE for UI development, Fiori template) and HANA database (HANA features installed on Eclipse Luna). I use xsodata service to expose my tables to the UI. At the moment my main concern are intersection tables that are used to resolve the many to many relationships in the database.
To illustrate the problem I’ll use a simplified ERD just with 3 tables:
Image may be NSFW.
Clik here to view.
As you can see the same information has to be written to 2 tables at a time. When saving from the UI the service is supposed to:
- Increment PRODUCT INFO ID (Primary Key) in the PRODUCT INFORMATION table and save OTHER INFO (simplified here);
- Pass the newly created PRODUCT INFO ID to the Intersection table;
- As only PRODUCT NAME (PRODUCT table) is displayed in the UI, it should be possible to retrieve the relevant PRODUCT ID (Primary Key) from the PRODUCT NAME (chosen/entered in the UI) in the PRODUCT table and pass the ID (as Foreign Key) to the Intersection table.
- The PRODUCT ID and PRODUCT INFO ID in the Intersection table together create a unique combination and the VERSION should be incremented based on that (i.e. the same product can have multiple product information entries and based on that combination a version number should be created for the newly created entry).
Point 1 is solved at the moment using an xsjslib file, which is preparing an insert statement and auto incrementing the primary key in the PRODUCT INFORMATION table. I struggle with the other points, I think it could be solved through the xsjslib, but it is more complicated and I don’t have enough knowledge I’m afraid. E.g. in point 2 I get the foreign key constraint violation, because the auto incremented PRODUCT INFO ID is not read properly from point 1.
I have more relations like that or similar in database, but I hope that once one is solved, the other ones should be easier to cover.
Another problem I have is the navigation and association between the ‘main’ and intersection tables. Similar to point 3 I believe. The navigation in Fiori works OK for 2 tables/views using navigation property.
If however I need to display e.g. PRODUCT_NAME from PRODUCT table and the context path/ binding available in Fiori is PRODUCT INFO ID from PRODUCT INFORMATION table I have a problem to retrieve the product name using the Intersection table, which I believe should be possible through the Foreign Keys. The reason behind is that I already have other table/attribute view bound to 1 part of the UI, hence the context path is different to what I need for a 2nd part within the same UI.
I’ve tried to hardcode the path, used $expand operator, none of them seem to work, the $expand works fine when parsing the oData link, when used in Fiori it throws an error: "Query parameter '$expand' is specified, but it should be specified exactly once."
Please note that I’m quite new to the UI5, Fiori and Hana.
Thanks a lot in advance for any support!