Simplified Extension Example

This commit is contained in:
nkaputnik
2021-05-26 11:55:16 +02:00
parent 1e034e964e
commit bbd09b1697
13 changed files with 535 additions and 345 deletions

View File

@@ -1,65 +1,44 @@
using {sap.capire.bookshop} from '_base/db/schema';
using {sap.capire.orders} from '_base/db/schema';
using from '_base/db/capire_common';
using {
cuid, managed, Country, sap.common.CodeList
} from '@sap/cds/common';
namespace Z_bookshop.extension;
// extend existing entity
extend orders.Orders with {
Z_Customer : Association to one Z_Customers;
Z_SalesRegion : Association to one Z_SalesRegion;
Z_priority : String @assert.range enum {high; medium; low} default 'medium';
Z_Remarks : Composition of many Z_Remarks on Z_Remarks.parent = $self;
}
// new entity - as association target
entity Z_Customers : cuid, managed
{
email : String;
firstName : String;
lastName : String;
creditCardNo : String;
dateOfBirth : Date;
status : String @assert.range enum {platinum; gold; silver; bronze} default 'bronze';
creditScore : Decimal @assert.range: [ 1.0, 100.0 ] default 50.0;
PostalAddresses : Composition of many Z_CustomerPostalAddresses on PostalAddresses.Customer = $self;
}
// new unique constraint (secondary index)
annotate Z_Customers with @assert.unique: { email: [ email ] }
{
email @mandatory; // mandatory check
}
// new entity - as composition target
entity Z_CustomerPostalAddresses : cuid, managed
{
Customer : Association to one Z_Customers;
description : String;
street : String;
town : String;
country : Country;
}
// new entity - as code list
entity Z_SalesRegion: CodeList {
key regionCode : String(11);
}
// new entity - as composition target
entity Z_Remarks : cuid, managed
{
parent : Association to one orders.Orders;
number : Integer;
remarksLine : String;
}
using {sap.capire.bookshop} from '_base/db/schema';
using {sap.capire.orders} from '_base/db/schema';
using from '_base/db/capire_common';
//using {Z_bookshop.fieldExtension as field} from './field_extension';
using {
cuid, managed, Country, sap.common.CodeList
} from '@sap/cds/common';
namespace Z_bookshop.assocExtension;
// extend existing entity
extend orders.Orders with {
Z_Customer : Association to one Z_Customers;
Z_SalesRegion : Association to one Z_SalesRegion;
}
// new entity - as association target
entity Z_Customers : cuid, managed
{
email : String;
firstName : String;
lastName : String;
creditCardNo : String;
dateOfBirth : Date;
status : String @assert.range enum {platinum; gold; silver; bronze} default 'bronze';
creditScore : Decimal @assert.range: [ 1.0, 100.0 ] default 50.0;
}
// new unique constraint (secondary index)
annotate Z_Customers with @assert.unique: { email: [ email ] }
{
email @mandatory; // mandatory check
}
// new entity - as code list
entity Z_SalesRegion: CodeList {
key regionCode : String(11);
}

41
db/comp_extension.cds_ Normal file
View File

@@ -0,0 +1,41 @@
using {sap.capire.bookshop} from '_base/db/schema';
using {sap.capire.orders} from '_base/db/schema';
using from '_base/db/capire_common';
using {Z_bookshop.assocExtension as assoc} from './assoc_extension';
using {
cuid, managed, Country, sap.common.CodeList
} from '@sap/cds/common';
namespace Z_bookshop.compExtension;
// extend existing entity
extend orders.Orders with {
Z_Remarks : Composition of many Z_Remarks on Z_Remarks.parent = $self;
}
// new entity - as composition target
entity Z_CustomerPostalAddresses : cuid, managed
{
Customer : Association to one assoc.Z_Customers;
description : String;
street : String;
town : String;
country : Country;
}
// new entity - as composition target
entity Z_Remarks : cuid, managed
{
parent : Association to one orders.Orders;
number : Integer;
remarksLine : String;
}
extend assoc.Z_Customers with {
PostalAddresses : Composition of many Z_CustomerPostalAddresses on PostalAddresses.Customer = $self;
}

View File

@@ -1,5 +1,5 @@
ID;modifiedAt;createdAt;createdBy;modifiedBy;Customer_ID;description;street;town;country_code
1e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Home;Hauptstrasse 11;Berlin;DE
24e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Home;Main Street 22;London;GB
3e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Work;Siemensstrasse 21;Berlin;DE
44e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Work;Work Street 34;London;GB
ID;modifiedAt;createdAt;createdBy;modifiedBy;Customer_ID;description;street;town;country_code
1e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Home;Hauptstrasse 11;Berlin;DE
24e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Home;Main Street 22;London;GB
3e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Work;Siemensstrasse 21;Berlin;DE
44e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Work;Work Street 34;London;GB

View File

@@ -1,3 +1,3 @@
ID;modifiedAt;createdAt;createdBy;modifiedBy;email;firstName;lastName;creditCardNo;dateOfBirth;status;creditScore
8e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;john.doe@test.com;John;Doe;9977-6655-4433-2211;1970-01-01;gold;80.0
ID;modifiedAt;createdAt;createdBy;modifiedBy;email;firstName;lastName;creditCardNo;dateOfBirth;status;creditScore
8e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;john.doe@test.com;John;Doe;9977-6655-4433-2211;1970-01-01;gold;80.0
74e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;jane.doe@sap.com;Jane;Doe;2211-3344-5566-7788;1980-11-11;platinum;100.0

View File

@@ -1,4 +1,4 @@
regionCode;name;descr
AMER;Americas;North, Central and South America
EMEA;Europe, the Middle East and Africa;Europe, the Middle East and Africa
regionCode;name;descr
AMER;Americas;North, Central and South America
EMEA;Europe, the Middle East and Africa;Europe, the Middle East and Africa
APJ;Asia Pacific and Japan;Asia Pacific and Japan

View File

@@ -1,3 +1,3 @@
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_Customer_ID;Z_priority;Z_SalesRegion_regionCode
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;8e2f2640-6866-4dcf-8f4d-3027aa831cad;high;EMEA
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;74e718c9-ff99-47f1-8ca3-950c850777d4;low;APJ
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_orderInfo;Z_internalNo;Z_expectedDelivery;Z_priority;Z_discount;
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;Webshop order;202001;2019-03-31;high;5.0
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;Walk in order;202002;2019-04-15;low;10.0
1 ID ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_orderInfo;Z_internalNo;Z_expectedDelivery;Z_priority;Z_discount; createdAt createdBy buyer OrderNo currency_code Z_Customer_ID Z_priority Z_SalesRegion_regionCode
2 7e2f2640-6866-4dcf-8f4d-3027aa831cad 7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;Webshop order;202001;2019-03-31;high;5.0 2019-01-31 john.doe@test.com john.doe@test.com 1 EUR 8e2f2640-6866-4dcf-8f4d-3027aa831cad high EMEA
3 64e718c9-ff99-47f1-8ca3-950c850777d4 64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;Walk in order;202002;2019-04-15;low;10.0 2019-01-30 jane.doe@test.com jane.doe@test.com 2 EUR 74e718c9-ff99-47f1-8ca3-950c850777d4 low APJ

View File

@@ -0,0 +1,3 @@
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_Customer_ID;Z_priority;Z_SalesRegion_regionCode
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;8e2f2640-6866-4dcf-8f4d-3027aa831cad;high;EMEA
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;74e718c9-ff99-47f1-8ca3-950c850777d4;low;APJ

38
db/field_extension.cds Normal file
View File

@@ -0,0 +1,38 @@
using {sap.capire.bookshop} from '_base/db/schema';
using {sap.capire.orders} from '_base/db/schema';
using from '_base/db/capire_common';
using {
cuid,
managed,
Country,
sap.common.CodeList
} from '@sap/cds/common';
namespace Z_bookshop.fieldExtension;
// extend existing entity
extend orders.Orders with {
Z_orderInfo : String default 'Webshop order';
Z_internalNo : Integer; // uniqiue constraint
Z_expectedDelivery : Date; //mandatory
Z_priority : String
@assert.range enum {
high;
medium;
low
} default 'medium';
Z_discount : Decimal
@assert.range : [
0.0,
99.9
] default 0.0;
}
// new unique constraint (secondary index)
annotate orders.Orders with @assert.unique : {Z_internalNo : [Z_internalNo]} {
Z_expectedDelivery @mandatory; // mandatory check
}

View File

@@ -2,11 +2,5 @@ using from '_base/srv/admin-service';
using from '_base/srv/cat-service';
using from '_base/srv/orders-service';
using { Z_bookshop.extension as ext } from '../db/extension';
extend service OrdersService with {
entity Z_Customers as projection on ext.Z_Customers;
entity Z_SalesRegion as projection on ext.Z_SalesRegion;
}
using from '../db/field_extension';

View File

@@ -0,0 +1,14 @@
using from '_base/srv/admin-service';
using from '_base/srv/cat-service';
using from '_base/srv/orders-service';
using from '../db/field_extension';
using { Z_bookshop.compExtension as comp } from '../db/comp_extension';
using { Z_bookshop.assocExtension as assoc } from '../db/assoc_extension';
extend service OrdersService with {
entity Z_Customers as projection on assoc.Z_Customers;
entity Z_SalesRegion as projection on assoc.Z_SalesRegion;
}

View File

@@ -1,260 +0,0 @@
using from '_base/app/services';
using OrdersService from './extension_service';
// new entity -- draft enabled
annotate OrdersService.Z_Customers with @odata.draft.enabled;
// new codelist entity -- draft enabled
annotate OrdersService.Z_SalesRegion with @odata.draft.enabled;
// new entity -- titles
annotate OrdersService.Z_Customers with {
ID @(
UI.Hidden,
Common : {Text : email}
);
firstName @title : 'First Name';
lastName @title : 'Last Name';
email @title : 'Email';
creditCardNo @title : 'Credit Card No';
dateOfBirth @title : 'Date of Birth';
status @title : 'Status';
creditScore @title : 'Credit Score';
}
// new entity -- titles
annotate OrdersService.Z_CustomerPostalAddresses with {
ID @(
UI.Hidden,
Common : {Text : description}
);
description @title : 'Description';
street @title : 'Street';
town @title : 'Town';
country @title : 'Country';
}
// new entity -- titles
annotate OrdersService.Z_SalesRegion with {
regionCode @title: 'Region Code';
}
// new entity -- titles
annotate OrdersService.Z_Remarks with {
number @title: 'Remark Number';
remarksLine @title: 'Remark';
}
// new entity in service -- UI
annotate OrdersService.Z_Customers with @(UI : {
HeaderInfo : {
TypeName : 'Customer',
TypeNamePlural : 'Customers',
Title : {
$Type : 'UI.DataField',
Value : email
}
},
LineItem : [
{Value : firstName},
{Value : lastName},
{Value : email},
{Value : status},
{Value : creditScore}
],
Facets : [
{$Type: 'UI.ReferenceFacet', Label: 'Main', Target : '@UI.FieldGroup#Main'},
{$Type: 'UI.ReferenceFacet', Label: 'Customer Postal Addresses', Target: 'PostalAddresses/@UI.LineItem'}
],
FieldGroup #Main : {Data : [
{Value : firstName},
{Value : lastName},
{Value : email},
{Value : status},
{Value : creditScore}
]}
} ) ;
// new entity -- UI
annotate OrdersService.Z_CustomerPostalAddresses with @(UI : {
HeaderInfo : {
TypeName : 'CustomerPostalAddress',
TypeNamePlural : 'CustomerPostalAddresses',
Title : {
$Type : 'UI.DataField',
Value : description
}
},
LineItem : [
{Value : description},
{Value : street},
{Value : town},
{Value : country_code}
],
Facets : [
{$Type: 'UI.ReferenceFacet', Label: 'Main', Target : '@UI.FieldGroup#Main'}
],
FieldGroup #Main : {Data : [
{Value : description},
{Value : street},
{Value : town},
{Value : country_code}
]}
}, ) {
};
// new entity -- UI
annotate OrdersService.Z_SalesRegion with @(
UI: {
HeaderInfo: {
TypeName: 'Sales Region',
TypeNamePlural: 'Sales Regions',
Title : {
$Type : 'UI.DataField',
Value : regionCode
}
},
LineItem: [
{Value: regionCode},
{Value: name},
{Value: descr}
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: 'Main', Target: '@UI.FieldGroup#Main'}
],
FieldGroup#Main: {
Data: [
{Value: regionCode},
{Value: name},
{Value: descr}
]
}
},
) {
};
// new entity -- UI
annotate OrdersService.Z_Remarks with @(
UI: {
HeaderInfo: {
TypeName: 'Remark',
TypeNamePlural: 'Remarks',
Title : {
$Type : 'UI.DataField',
Value : number
}
},
LineItem: [
{Value: number},
{Value: remarksLine}
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: 'Main', Target: '@UI.FieldGroup#Main'}
],
FieldGroup#Main: {
Data: [
{Value: number},
{Value: remarksLine}
]
}
},
) {
};
// extend existing entity Orders with new extension fields and new composition
@odata.draft.enabled
annotate OrdersService.Orders with @(
UI: {
SelectionFields: [ createdAt, createdBy ],
LineItem: [
{Value: OrderNo, Label:'OrderNo'},
{Value: Z_Customer_ID, Label:'Customer'}, // extension field
{Value: Z_SalesRegion_regionCode, Label:'Sales Region'}, // extension field
{Value: Z_priority, Label:'Priority'}, // extension field
{Value: createdAt, Label:'Date'}
],
HeaderInfo: {
TypeName: 'Order', TypeNamePlural: 'Orders',
Title: {
Label: 'Order number ', //A label is possible but it is not considered on the ObjectPage yet
Value: OrderNo
},
Description: {Value: createdBy}
},
Identification: [ //Is the main field group
{Value: createdBy, Label:'Customer'},
{Value: createdAt, Label:'Date'},
{Value: OrderNo },
],
HeaderFacets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Created}', Target: '@UI.FieldGroup#Created'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Modified}', Target: '@UI.FieldGroup#Modified'},
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: 'Items/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: 'Remarks', Target: 'Z_Remarks/@UI.LineItem'} // new composition
],
FieldGroup#Details: {
Data: [
{Value: currency_code, Label:'Currency'},
{Value: Z_Customer_ID, Label:'Customer'}, // extension field
{Value: Z_SalesRegion_regionCode, Label:'Sales Region'}, // extension field
{Value: Z_priority, Label:'Priority'} // extension field
]
},
FieldGroup#Created: {
Data: [
{Value: createdBy},
{Value: createdAt},
]
},
FieldGroup#Modified: {
Data: [
{Value: modifiedBy},
{Value: modifiedAt},
]
},
},
)
{
createdAt @UI.HiddenFilter:false;
createdBy @UI.HiddenFilter:false;
}
;
// new field in existing service -- exchange ID with text
annotate OrdersService.Orders with {
Z_Customer @(
Common: {
//show email, not id for Customer in the context of Orders
Text: Z_Customer.email , TextArrangement: #TextOnly,
ValueList: {
Label: 'Customers',
CollectionPath: 'Z_Customers',
Parameters: [
{ $Type: 'Common.ValueListParameterInOut',
LocalDataProperty: Z_Customer_ID,
ValueListProperty: 'ID'
},
{ $Type: 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'email'
}
]
}
}
);
}

View File

@@ -0,0 +1,311 @@
using from '_base/app/services';
using OrdersService from './extension_service';
// new entity -- draft enabled
annotate OrdersService.Z_Customers with @odata.draft.enabled;
// new codelist entity -- draft enabled
annotate OrdersService.Z_SalesRegion with @odata.draft.enabled;
// new entity -- titles
annotate OrdersService.Z_Customers with {
ID @(
UI.Hidden,
Common : {Text : email}
);
firstName @title : 'First Name';
lastName @title : 'Last Name';
email @title : 'Email';
creditCardNo @title : 'Credit Card No';
dateOfBirth @title : 'Date of Birth';
status @title : 'Status';
creditScore @title : 'Credit Score';
}
// new entity -- titles
annotate OrdersService.Z_CustomerPostalAddresses with {
ID @(
UI.Hidden,
Common : {Text : description}
);
description @title : 'Description';
street @title : 'Street';
town @title : 'Town';
country @title : 'Country';
}
// new entity -- titles
annotate OrdersService.Z_SalesRegion with {
regionCode @title : 'Region Code';
}
// new entity -- titles
annotate OrdersService.Z_Remarks with {
number @title : 'Remark Number';
remarksLine @title : 'Remark';
}
// new entity in service -- UI
annotate OrdersService.Z_Customers with @(UI : {
HeaderInfo : {
TypeName : 'Customer',
TypeNamePlural : 'Customers',
Title : {
$Type : 'UI.DataField',
Value : email
}
},
LineItem : [
{Value : firstName},
{Value : lastName},
{Value : email},
{Value : status},
{Value : creditScore}
],
Facets : [
{
$Type : 'UI.ReferenceFacet',
Label : 'Main',
Target : '@UI.FieldGroup#Main'
},
{
$Type : 'UI.ReferenceFacet',
Label : 'Customer Postal Addresses',
Target : 'PostalAddresses/@UI.LineItem'
}
],
FieldGroup #Main : {Data : [
{Value : firstName},
{Value : lastName},
{Value : email},
{Value : status},
{Value : creditScore}
]}
});
// new entity -- UI
annotate OrdersService.Z_CustomerPostalAddresses with @(UI : {
HeaderInfo : {
TypeName : 'CustomerPostalAddress',
TypeNamePlural : 'CustomerPostalAddresses',
Title : {
$Type : 'UI.DataField',
Value : description
}
},
LineItem : [
{Value : description},
{Value : street},
{Value : town},
{Value : country_code}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : 'Main',
Target : '@UI.FieldGroup#Main'
}],
FieldGroup #Main : {Data : [
{Value : description},
{Value : street},
{Value : town},
{Value : country_code}
]}
}, ) {
};
// new entity -- UI
annotate OrdersService.Z_SalesRegion with @(UI : {
HeaderInfo : {
TypeName : 'Sales Region',
TypeNamePlural : 'Sales Regions',
Title : {
$Type : 'UI.DataField',
Value : regionCode
}
},
LineItem : [
{Value : regionCode},
{Value : name},
{Value : descr}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : 'Main',
Target : '@UI.FieldGroup#Main'
}],
FieldGroup #Main : {Data : [
{Value : regionCode},
{Value : name},
{Value : descr}
]}
}, ) {
};
// new entity -- UI
annotate OrdersService.Z_Remarks with @(UI : {
HeaderInfo : {
TypeName : 'Remark',
TypeNamePlural : 'Remarks',
Title : {
$Type : 'UI.DataField',
Value : number
}
},
LineItem : [
{Value : number},
{Value : remarksLine}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : 'Main',
Target : '@UI.FieldGroup#Main'
}],
FieldGroup #Main : {Data : [
{Value : number},
{Value : remarksLine}
]}
}, ) {
};
// extend existing entity Orders with new extension fields and new composition
@odata.draft.enabled
annotate OrdersService.Orders with @(UI : {
SelectionFields : [
createdAt,
createdBy
],
LineItem : [
{
Value : OrderNo,
Label : 'OrderNo'
},
{
Value : Z_Customer_ID,
Label : 'Customer'
}, // extension field
{
Value : Z_SalesRegion_regionCode,
Label : 'Sales Region'
}, // extension field
{
Value : Z_priority,
Label : 'Priority'
}, // extension field
{
Value : createdAt,
Label : 'Date'
}
],
HeaderInfo : {
TypeName : 'Order',
TypeNamePlural : 'Orders',
Title : {
Label : 'Order number ', //A label is possible but it is not considered on the ObjectPage yet
Value : OrderNo
},
Description : {Value : createdBy}
},
Identification : [ //Is the main field group
{
Value : createdBy,
Label : 'Customer'
},
{
Value : createdAt,
Label : 'Date'
},
{Value : OrderNo},
],
HeaderFacets : [
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Created}',
Target : '@UI.FieldGroup#Created'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Modified}',
Target : '@UI.FieldGroup#Modified'
},
],
Facets : [
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>OrderItems}',
Target : 'Items/@UI.LineItem'
},
{
$Type : 'UI.ReferenceFacet',
Label : 'Remarks',
Target : 'Z_Remarks/@UI.LineItem'
} // new composition
],
FieldGroup #Details : {Data : [
{
Value : currency_code,
Label : 'Currency'
},
{
Value : Z_Customer_ID,
Label : 'Customer'
}, // extension field
{
Value : Z_SalesRegion_regionCode,
Label : 'Sales Region'
}, // extension field
{
Value : Z_priority,
Label : 'Priority'
} // extension field
]},
FieldGroup #Created : {Data : [
{Value : createdBy},
{Value : createdAt},
]},
FieldGroup #Modified : {Data : [
{Value : modifiedBy},
{Value : modifiedAt},
]},
}, )
{
createdAt @UI.HiddenFilter : false;
createdBy @UI.HiddenFilter : false;
};
// new field in existing service -- exchange ID with text
annotate OrdersService.Orders with {
Z_Customer @(Common : {
//show email, not id for Customer in the context of Orders
Text : Z_Customer.email,
TextArrangement : #TextOnly,
ValueList : {
Label : 'Customers',
CollectionPath : 'Z_Customers',
Parameters : [
{
$Type : 'Common.ValueListParameterInOut',
LocalDataProperty : Z_Customer_ID,
ValueListProperty : 'ID'
},
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty : 'email'
}
]
}
});
}

View File

@@ -0,0 +1,70 @@
using from '_base/app/services';
using OrdersService from './extension_service';
// extend existing entity Orders with new extension fields and new composition
@odata.draft.enabled
annotate OrdersService.Orders with @(UI : {
LineItem : [
{
Value : OrderNo,
Label : 'OrderNo'
},
{
Value : Z_orderInfo,
Label : 'Additional Information'
}, // extension field
{
Value : Z_internalNo,
Label : 'Internal Order Number'
}, // extension field
{
Value : Z_expectedDelivery,
Label : 'Expecxted Delivery Date'
}, // extension field
{
Value : Z_priority,
Label : 'Priority'
}, // extension field
{
Value : Z_discount,
Label : 'Discount'
}, // extension field
{
Value : createdAt,
Label : 'Date'
},
],
FieldGroup #Details : {Data : [
{
Value : currency_code,
Label : 'Currency'
},
{
Value : Z_orderInfo,
Label : 'Additional Information'
}, // extension field
{
Value : Z_internalNo,
Label : 'Internal Order Number'
}, // extension field
{
Value : Z_expectedDelivery,
Label : 'Expected Delivery Date'
}, // extension field
{
Value : Z_priority,
Label : 'Priority'
}, // extension field
{
Value : Z_discount,
Label : 'Discount'
}, // extension field
]},
})
{
createdAt @UI.HiddenFilter : false;
createdBy @UI.HiddenFilter : false;
};