Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Showcase how to integrate DB-specific functions (#201)
Augment `AdminService.Author` by 2 fields `age` and `lifetime` whose values are computed by SQLite and HANA-specific functions. Don't do this in bookshop directly, to keep it simple. Instead, use the fiori module, which also allows to integrate the fields in the UI. Co-authored-by: Daniel <daniel.hutzel@sap.com>
- Loading branch information
Showing
8 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // | ||
| // Add Author.age and .lifetime with a DB-specific function | ||
| // | ||
|
|
||
| using { AdminService } from '..'; | ||
|
|
||
| extend projection AdminService.Authors with { | ||
| YEARS_BETWEEN(dateOfBirth, dateOfDeath) as age: Integer, | ||
| YEAR(dateOfBirth) || ' – ' || YEAR(dateOfDeath) as lifetime : String | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using { sap.capire.bookshop } from '@capire/bookshop'; | ||
|
|
||
| // Forward-declare calculated fields to be filled in database-specific ways | ||
| // TODO find a better way to have 'default' fields that still can be overwritten. | ||
| extend bookshop.Authors with { | ||
| virtual age: Integer; | ||
| virtual lifetime: String; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // | ||
| // Add Author.age and .lifetime with a DB-specific function | ||
| // | ||
|
|
||
| using { AdminService } from '..'; | ||
|
|
||
| extend projection AdminService.Authors with { | ||
| strftime('%Y',dateOfDeath)-strftime('%Y',dateOfBirth) as age: Integer, | ||
| strftime('%Y',dateOfBirth) || ' – ' || strftime('%Y',dateOfDeath) as lifetime : String | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters