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.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 from '_base/db/capire_common';
|
||||||
|
|
||||||
using {
|
using {
|
||||||
cuid, managed, Country
|
cuid, managed, Country, sap.common.CodeList
|
||||||
} from '@sap/cds/common';
|
} from '@sap/cds/common';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Z_bookshop.extension;
|
namespace Z_bookshop.extension;
|
||||||
|
|
||||||
// extend existing entity
|
// extend existing entity
|
||||||
extend orders.Orders with {
|
extend orders.Orders with {
|
||||||
Z_Customer : Association to one Z_Customers;
|
Z_Customer : Association to one Z_Customers;
|
||||||
Z_Remarks : Composition of many Z_Remarks on Z_Remarks.Z_parent = $self;
|
Z_SalesRegion : Association to one Z_SalesRegion;
|
||||||
Z_priority : String @assert.range enum {high; medium; low} default 'medium';
|
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
|
// new entity - as association target
|
||||||
@@ -47,6 +49,12 @@ entity Z_CustomerPostalAddresses // :
|
|||||||
Z_country : Country;
|
Z_country : Country;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// new entity - as code list
|
||||||
|
entity Z_SalesRegion: CodeList {
|
||||||
|
key Z_regionCode : String(11);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// new entity - as composition target
|
// new entity - as composition target
|
||||||
entity Z_Remarks // : cuid, managed
|
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.
@@ -7,5 +7,6 @@ using { Z_bookshop.extension as ext } from '../db/extension';
|
|||||||
|
|
||||||
extend service OrdersService with {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ using OrdersService from './extension_service';
|
|||||||
|
|
||||||
// new entity -- draft enabled
|
// 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
|
// new entity -- titles
|
||||||
annotate OrdersService.Z_Customers with {
|
annotate OrdersService.Z_Customers with {
|
||||||
@@ -32,6 +35,10 @@ annotate OrdersService.Z_CustomerPostalAddresses with {
|
|||||||
Z_country @title : 'Country';
|
Z_country @title : 'Country';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// new entity -- titles
|
||||||
|
annotate OrdersService.Z_SalesRegion with {
|
||||||
|
Z_regionCode @title: 'Region Code';
|
||||||
|
}
|
||||||
|
|
||||||
// new entity -- titles
|
// new entity -- titles
|
||||||
annotate OrdersService.Z_Remarks with {
|
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
|
// new entity -- UI
|
||||||
@@ -143,7 +176,8 @@ annotate OrdersService.Orders with @(
|
|||||||
SelectionFields: [ createdAt, createdBy ],
|
SelectionFields: [ createdAt, createdBy ],
|
||||||
LineItem: [
|
LineItem: [
|
||||||
{Value: OrderNo, Label:'OrderNo'},
|
{Value: OrderNo, Label:'OrderNo'},
|
||||||
// {Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - 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: Z_priority, Label:'Priority'}, // extension field
|
||||||
{Value: createdAt, Label:'Date'}
|
{Value: createdAt, Label:'Date'}
|
||||||
],
|
],
|
||||||
@@ -172,7 +206,8 @@ annotate OrdersService.Orders with @(
|
|||||||
FieldGroup#Details: {
|
FieldGroup#Details: {
|
||||||
Data: [
|
Data: [
|
||||||
{Value: currency_code, Label:'Currency'}, // correction
|
{Value: currency_code, Label:'Currency'}, // correction
|
||||||
// {Value: Z_Customer_Z_ID, Label:'Customer'}, // workaround - 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: Z_priority, Label:'Priority'} // extension field
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user