namespace db;
using db.types as types from '../data-Model/types';
entity PRODUCTS {
key ID : UUID;
@title: 'Product Name'
PROD_NAME : String(256);
@title: 'Product Price'
PROD_PRICE : Int64;
@title: 'Currency'
CURRENCY : String(256);
@title: 'Product Type'
PROD_TYPE : String(256);
@title: 'Supplier Name'
SUPPLIER_NAME : String(256);
@title: 'Customer Name'
CUSTOMER_NAME : String(256);
@title: 'History'
HISTORY : types.HistoryT;
@title: 'Agreement'
AGREEMENT : Boolean default false;
@title:'Date of Manufacture'
DOB: Date;
LINK_TO_SUPPLIER : Association[1.. 1] to SUPPLIER
on LINK_TO_SUPPLIER.ID = SUPPLIER_NAME;
LINK_TO_CUSTOMER : Association[1.. 1] to CUSTOMER
on LINK_TO_CUSTOMER.ID = CUSTOMER_NAME;
}
entity SUPPLIER {
key ID : String(256);
DESCRIPTION : String(256);
}
entity CUSTOMER {
key ID : String(256);
DESCRIPTION : String(256);
}
namespace db.types;
using {
managed,
sap
} from '@sap/cds/common';
type AppIdT : String(40);
type UserT : String(256);
type HistoryT {
@readonly
@Common.Label : 'Created By'
@cds.on.insert: $user
CRTD_BY : UserT;
@readonly
@Common.Label : 'Created On'
@cds.on.insert: $now
CRTD_DATE : DateTime;
@UI.Hidden
CRTD_APP_ID : AppIdT;
@readonly
@Common.Label : 'Changed By'
@cds.on.insert: $user
@cds.on.update: $user
CHNG_BY : UserT;
@readonly
@Common.Label : 'Changed On'
@cds.on.insert: $now
@cds.on.update: $now
CHNG_DATE : DateTime;
@UI.Hidden
CHNG_APP_ID : AppIdT;
};
using db as db from '../db/data-Model/data-Model';
using db.types as types from '../db/data-Model/types';
service CatalogService @(requires: 'authenticated-user') {
@odata.draft.enabled
entity Products as projection on db.PRODUCTS {
*,
LINK_TO_SUPPLIER : redirected to Suppliers,
LINK_TO_CUSTOMER : redirected to Customers,
};
entity Suppliers as projection on db.SUPPLIER;
entity Customers as projection on db.CUSTOMER;
}
{
"_version": "1.49.0",
"sap.app": {
"id": "productsapp",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "0.0.1"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"resources": "resources.json",
"sourceTemplate": {
"id": "@sap/generator-fiori:lrop",
"version": "1.10.3",
"toolsId": "ff8013c8-3b87-45a2-b24e-657be8404fec"
},
"dataSources": {
"CatalogService": {
"uri": "/odata/v4/catalog/",
"type": "OData",
"settings": {
"annotations": [],
"localUri": "localService/metadata.xml",
"odataVersion": "4.0"
}
}
},
"crossNavigation": {
"inbounds": {
"productsapp-inbound": {
"signature": {
"parameters": {},
"additionalParameters": "allowed"
},
"semanticObject": "products",
"action": "manage",
"title": "{{flpTitle}}",
"subTitle": "{{flpSubtitle}}",
"icon": ""
}
}
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"flexEnabled": true,
"dependencies": {
"minUI5Version": "1.116.0",
"libs": {
"sap.m": {},
"sap.ui.core": {},
"sap.ushell": {},
"sap.fe.templates": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "productsapp.i18n.i18n"
}
},
"": {
"dataSource": "CatalogService",
"preload": true,
"settings": {
"synchronizationMode": "None",
"operationMode": "Server",
"autoExpandSelect": true,
"earlyRequests": true
}
},
"@i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
}
},
"resources": {
"css": []
},
"routing": {
"config": {},
"routes": [
{
"pattern": ":?query:",
"name": "ProductsList",
"target": "ProductsList"
},
{
"pattern": "Products({key}):?query:",
"name": "ProductsObjectPage",
"target": "ProductsObjectPage"
}
],
"targets": {
"ProductsList": {
"type": "Component",
"id": "ProductsList",
"name": "sap.fe.templates.ListReport",
"options": {
"settings": {
"entitySet": "Products",
"initialLoad": "Enabled",
"variantManagement": "Page",
"navigation": {
"Products": {
"detail": {
"route": "ProductsObjectPage"
}
}
}
}
}
},
"ProductsObjectPage": {
"type": "Component",
"id": "ProductsObjectPage",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"editableHeaderContent": false,
"entitySet": "Products"
}
}
}
}
}
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
}
}
using CatalogService as service from './cat-service';
/**
* Annotations for Products
*/
annotate service.Products with {
ID @title: 'ID';
AGREEMENT @title: 'Agreement';
}
// UI code for object ProductsList
annotate service.Products with @(
UI.HeaderInfo : {
TypeName : 'Products',
TypeNamePlural: 'Products',
Title : {
$Type: 'UI.DataField',
Value: PROD_NAME
},
Description : {
$Type: 'UI.DataField',
Value: PROD_TYPE
}
},
UI.SelectionFields: [
PROD_NAME,
PROD_TYPE,
SUPPLIER_NAME,
CUSTOMER_NAME
],
UI.LineItem : [
{
$Type : 'UI.DataField',
Label : 'ID',
Value : ID,
![@UI.Hidden]: true,
},
{
$Type: 'UI.DataField',
Label: 'Product Name',
Value: PROD_NAME,
},
{
$Type: 'UI.DataField',
Label: 'Product Type',
Value: PROD_TYPE,
},
{
$Type: 'UI.DataField',
Label: 'Customer Name',
Value: CUSTOMER_NAME,
},
{
$Type: 'UI.DataField',
Label: 'Supplier Name',
Value: SUPPLIER_NAME,
},
{
$Type: 'UI.DataField',
Label: 'Product Price',
Value: PROD_PRICE,
},
{
$Type: 'UI.DataField',
Label: 'Product Price',
Value: CURRENCY
},
{
$Type: 'UI.DataField',
Label: 'Agreement',
Value: AGREEMENT,
}
]
);
// UI code for object ProductsObjectPage
annotate service.Products with @(
UI.FieldGroup #GeneratedGroup1: {
$Type: 'UI.FieldGroupType',
Data : [
{
$Type: 'UI.DataField',
Label: 'ID',
Value: ID
// ![@UI.Hidden] : true,
},
{
$Type: 'UI.DataField',
Label: 'Product Name',
Value: PROD_NAME
},
{
$Type: 'UI.DataField',
Label: 'Product Type',
Value: PROD_TYPE
}
],
},
UI.FieldGroup #GeneratedGroup2: {
$Type: 'UI.FieldGroupType',
Data : [
{
$Type: 'UI.DataField',
Label: 'Customer Name',
Value: CUSTOMER_NAME
},
{
$Type: 'UI.DataField',
Label: 'Supplier Name',
Value: SUPPLIER_NAME
},
{
$Type: 'UI.DataField',
Label: 'Product Price',
Value: PROD_PRICE
},
{
$Type: 'UI.DataField',
Label: 'Agreement',
Value: AGREEMENT
},
{
$Type: 'UI.DataField',
Label: 'Currency',
Value: CURRENCY
},
{
$Type: 'UI.DataField',
Label: 'Date of Manufacture',
Value: DOB
}
]
},
UI.FieldGroup #GeneratedGroup3: {
$Type: 'UI.FieldGroupType',
Data : [
{
$Type: 'UI.DataField',
Label: 'Created By',
Value: HISTORY_CRTD_BY
},
{
$Type: 'UI.DataField',
Label: 'Created On',
Value: HISTORY_CRTD_DATE
},
{
$Type: 'UI.DataField',
Label: 'Changed By',
Value: HISTORY_CHNG_BY
},
{
$Type: 'UI.DataField',
Label: 'Changed On',
Value: HISTORY_CHNG_DATE
}
]
},
UI.Facets : [
{
$Type : 'UI.ReferenceFacet',
ID : 'GeneratedFacet1',
Label : 'General Information',
Target: '@UI.FieldGroup#GeneratedGroup1',
},
{
$Type : 'UI.ReferenceFacet',
ID : 'GeneratedFacet2',
Label : 'Additional Information',
Target: '@UI.FieldGroup#GeneratedGroup2',
},
{
$Type : 'UI.ReferenceFacet',
ID : 'GeneratedFacet3',
Label : 'History',
Target: '@UI.FieldGroup#GeneratedGroup3',
}
]
);
// Making Mandatory fields
annotate service.Products with {
PROD_NAME
@(Common: {FieldControl: #Mandatory});
SUPPLIER_NAME
@(Common: {FieldControl: #Mandatory})
};
// Creating Drop down and value help
annotate service.Products with {
SUPPLIER_NAME @(Common: {
Text : LINK_TO_SUPPLIER.DESCRIPTION,
TextArrangement: #TextOnly,
ValueList : {
CollectionPath: 'Suppliers',
Label : 'Supplier Name',
Parameters : [
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'DESCRIPTION',
},
{
$Type : 'Common.ValueListParameterInOut',
LocalDataProperty: SUPPLIER_NAME,
ValueListProperty: 'ID',
}
],
}
});
CUSTOMER_NAME @(Common: {
Text : LINK_TO_CUSTOMER.DESCRIPTION,
TextArrangement: #TextOnly,
ValueListWithFixedValues,
ValueList : {
CollectionPath: 'Customers',
Label : 'Customers',
Parameters : [
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'DESCRIPTION',
},
{
$Type : 'Common.ValueListParameterInOut',
LocalDataProperty: CUSTOMER_NAME,
ValueListProperty: 'ID',
}
],
}
});
};
annotate service.Products with @(Capabilities.FilterRestrictions: {FilterExpressionRestrictions: [{
Property : SUPPLIER_NAME,
AllowedExpressions: 'SingleValue'
}]});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
10 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 |