
This topic demonstrates how you can expand the syntax of the CDS view to include metadata with the aim of providing some additional list reporting capabilities.
@UI.headerInfo: { typeName: 'Sales Order Item', typeNamePlural: 'Sales Order Items' }
define view ZDEMO_SALES_ORDER_ITEM_ADV as
...
Preview:

@Search.searchable: true define view ZDEMO_SALES_ORDER_ITEM_ADV as ... @Search.defaultSearchElement: true Item.product.category as ProductCategory, ...
Preview:

@UI.selectionField.position: 10 key Item.sales_order.sales_order_id as SalesOrderID ... @UI.selectionField.position: 20 @Search.defaultSearchElement: true @Search.fuzzinessThreshold: 0.7 Item.sales_order.customer.company_name as CustomerName, ... @UI.selectionField.position: 30 @Search.defaultSearchElement: true Item.product.category as ProductCategory, ...
Preview:

In the list, the Sales Order ID field should get a specific label (Sales Order) and be displayed at the first position within the result list.
...
@UI.lineItem: { importance: #HIGH, label: 'Sales Order', position: 10 }
key Item.sales_order.sales_order_id as SalesOrderID,
...
Life cycle status information should be displayed on the result list by default:
@UI.lineItem.position: 40 Item.sales_order.lifecycle_status as LifecycleStatus, ...
The order of fields is continued with currency and both amount fields:
@UI.lineItem.position: 50 Item.currency_code as CurrencyCode, @UI.lineItem.position: 60 Item.gross_amount as GrossAmount, @UI.lineItem.position: 70 Item.net_amount as NetAmount ...
The customer’s Company name should also appear in the list:
@UI.lineItem.position: 90 Item.sales_order.customer.company_name as CustomerName, ...
The product Category as last field in the list:
@UI.lineItem.position: 100 Item.product.category as ProductCategory, ...
Preview:

It is not required for the currency field to appear as a separate field in the result list. Therefore, the currency field should be hidden in the list and therefore not available for the personalization settings dialog. The currency code is displayed in connection with the amount data instead. This is implemented by the annotation @Semantics.currencyCode: true. The annotation @Semantics.amount.currencyCode: 'CurrencyCode' defines each amount element as a currency field.
The @DefaultAggregation: #SUM annotation is used for analytical capabilities: The annotated amount fields are specified as so-called measures, that is, fields that can be aggregated.
... @Semantics.currencyCode: true @UI.hidden: true Item.currency_code as CurrencyCode, ... @DefaultAggregation: #SUM @Semantics.amount.currencyCode: 'CurrencyCode' Item.gross_amount as GrossAmount, ... @DefaultAggregation: #SUM @Semantics.amount.currencyCode: 'CurrencyCode' Item.net_amount as NetAmount ...
Preview:

