new CodeList
This commit is contained in:
4
db/data/Z_bookshop.extension-Z_SalesRegion.csv
Normal file
4
db/data/Z_bookshop.extension-Z_SalesRegion.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
Z_regionCode
|
||||
AMER
|
||||
EMEA
|
||||
APJ
|
||||
|
@@ -1,19 +1,21 @@
|
||||
|
||||
using {sap.capire.bookshop} from '_base/db/schema';
|
||||
using {sap.capire.orders} from '_base/db/schema';
|
||||
using {sap.capire.orders} from '_base/db/schema';
|
||||
using from '_base/db/capire_common';
|
||||
|
||||
using {
|
||||
cuid, managed, Country
|
||||
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_Remarks : Composition of many Z_Remarks on Z_Remarks.Z_parent = $self;
|
||||
Z_priority : String @assert.range enum {high; medium; low} default 'medium';
|
||||
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.Z_parent = $self;
|
||||
}
|
||||
|
||||
// new entity - as association target
|
||||
@@ -47,6 +49,12 @@ entity Z_CustomerPostalAddresses // :
|
||||
Z_country : Country;
|
||||
};
|
||||
|
||||
// new entity - as code list
|
||||
entity Z_SalesRegion: CodeList {
|
||||
key Z_regionCode : String(11);
|
||||
}
|
||||
|
||||
|
||||
// new entity - as composition target
|
||||
entity Z_Remarks // : cuid, managed
|
||||
{
|
||||
|
||||
BIN
mtx_error_1.txt
Normal file
BIN
mtx_error_1.txt
Normal file
Binary file not shown.
BIN
mtx_error_2.txt
Normal file
BIN
mtx_error_2.txt
Normal file
Binary file not shown.
@@ -6,6 +6,7 @@ using { Z_bookshop.extension as ext } from '../db/extension';
|
||||
|
||||
|
||||
extend service OrdersService with {
|
||||
entity Z_Customers as projection on ext.Z_Customers;
|
||||
entity Z_Customers as projection on ext.Z_Customers;
|
||||
entity Z_SalesRegion as projection on ext.Z_SalesRegion;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ using OrdersService from './extension_service';
|
||||
|
||||
|
||||
// new entity -- draft enabled
|
||||
annotate OrdersService.Z_Customers with @odata.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 {
|
||||
@@ -32,6 +35,10 @@ annotate OrdersService.Z_CustomerPostalAddresses with {
|
||||
Z_country @title : 'Country';
|
||||
}
|
||||
|
||||
// new entity -- titles
|
||||
annotate OrdersService.Z_SalesRegion with {
|
||||
Z_regionCode @title: 'Region Code';
|
||||
}
|
||||
|
||||
// new entity -- titles
|
||||
annotate OrdersService.Z_Remarks with {
|
||||
@@ -100,6 +107,32 @@ annotate OrdersService.Z_CustomerPostalAddresses with @(UI : {
|
||||
|
||||
};
|
||||
|
||||
// new entity -- UI
|
||||
annotate OrdersService.Z_SalesRegion with @(
|
||||
UI: {
|
||||
HeaderInfo: {
|
||||
TypeName: 'Sales Region',
|
||||
TypeNamePlural: 'Sales Regions',
|
||||
Title : {
|
||||
$Type : 'UI.DataField',
|
||||
Value : Z_regionCode
|
||||
}
|
||||
},
|
||||
LineItem: [
|
||||
{Value: Z_regionCode}
|
||||
],
|
||||
Facets: [
|
||||
{$Type: 'UI.ReferenceFacet', Label: 'Main', Target: '@UI.FieldGroup#Main'}
|
||||
],
|
||||
FieldGroup#Main: {
|
||||
Data: [
|
||||
{Value: Z_regionCode}
|
||||
]
|
||||
}
|
||||
},
|
||||
) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
// new entity -- UI
|
||||
@@ -143,8 +176,9 @@ annotate OrdersService.Orders with @(
|
||||
SelectionFields: [ createdAt, createdBy ],
|
||||
LineItem: [
|
||||
{Value: OrderNo, Label:'OrderNo'},
|
||||
// {Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - extension field
|
||||
{Value: Z_priority, Label:'Priority'}, // extension field
|
||||
{Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - extension field
|
||||
{Value: Z_SalesRegion_Z_regionCode, Label:'Sales Region'}, // workaround - extension field
|
||||
{Value: Z_priority, Label:'Priority'}, // extension field
|
||||
{Value: createdAt, Label:'Date'}
|
||||
],
|
||||
HeaderInfo: {
|
||||
@@ -171,9 +205,10 @@ annotate OrdersService.Orders with @(
|
||||
],
|
||||
FieldGroup#Details: {
|
||||
Data: [
|
||||
{Value: currency_code, Label:'Currency'}, // correction
|
||||
// {Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - extension field
|
||||
{Value: Z_priority, Label:'Priority'} // extension field
|
||||
{Value: currency_code, Label:'Currency'}, // correction
|
||||
{Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - extension field
|
||||
{Value: Z_SalesRegion_Z_regionCode, Label:'Sales Region'}, // workaround - extension field
|
||||
{Value: Z_priority, Label:'Priority'} // extension field
|
||||
]
|
||||
},
|
||||
FieldGroup#Created: {
|
||||
|
||||
Reference in New Issue
Block a user