RESTFUL ABAP’TA SEARCH HELP YARATMA
Herkese Merhaba,
Restful ABAP’ta search help (arama yardımı) yaratmak, kullanıcıların uygulamalarda veri girişi yaparken doğru değerleri kolayca seçmelerine olanak tanır. RESTful uygulamalarda search help’ler, genellikle veri modelindeki alanlara bağlanarak kullanıcı arayüzünde (örneğin, SAP Fiori uygulamalarında) kullanılabilir hale getirilir.
@Search.searchable: true annotasyonu kullanılarak yapılır.
ZI_PRODUCT
I_Product Entity referans alınarak oluşturulan CDS view görülmektedir. Serachhelp özelliği açılması için @Search.searchable: true annotasyonu kullanıldı.

ZI_PRODUCT_VH-SearchHelp for Product

I_Product’ın ‘Product’, ‘CreatedByUser’, ‘LastChangeDate’ field ları için ValuHelp özelliği getirildi.
ZC_PRODUCT- Metadata Extension File
Program çalıştırıldığında search helplerin default olarak gelmesi için @Search.defaultSearchElement: true kullanılır.
Metadata Extension file’da, açılan 3 alanın değerlerinin ekrana basılması için
@Consumption.valueHelpDefinition: [{ entity : {
name : 'ValueHelpName'
element : 'Field'} }]
annotasyonu kullanılır.

KOD
ZI_PRODUCT
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'List reports'
//@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
@UI.headerInfo: {
typeName: 'Material',
typeNamePlural: 'Materials'}
@Search.searchable: true
define root view entity ZI_PRODUCT
as select from I_Product as product
association [0..1] to ZI_LISTREPORT_ASSOCIATION as _Sales on $projection.Product = _Sales.Product
{
key product.Product,
product.ProductExternalID,
product.ProductOID,
product.ProductType,
product.CreationDate,
product.CreationTime,
product.CreationDateTime,
product.CreatedByUser,
product.LastChangeDate,
product.LastChangedByUser,
_Sales.SalesStatus,
_Sales.TaxClassification,
_Sales.TransportationGroup
}
ZC_PRODUCT
@Metadata.layer: #CORE
annotate view ZI_PRODUCT with
{
@UI.facet: [{ purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
position: 10,
label: 'Connection' }]
@UI.lineItem: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
@UI.identification: [{ position: 10 }]
@Search.defaultSearchElement: true
@Consumption.valueHelpDefinition: [{ entity : {
name : 'ZI_PRODUCT_VH',
element : 'Product'} }]
Product;
@UI.lineItem: [{ position: 20 }]
@UI.identification: [{ position: 20 }]
ProductExternalID;
@UI.lineItem: [{ position: 30, label: 'OID' }]
@UI.identification: [{ position: 30, label: 'OID' }]
ProductOID;
@UI.lineItem: [{ position: 40 }]
@UI.selectionField: [{ position: 20 }]
@UI.identification: [{ position: 40 }]
ProductType;
@UI.lineItem: [{ position: 50 }]
@UI.identification: [{ position: 50 }]
CreationDate;
@UI.lineItem: [{ position: 60 }]
@UI.identification: [{ position: 60 }]
CreationTime;
@UI.lineItem: [{ position: 70 }]
@UI.identification: [{ position: 70 }]
CreationDateTime;
@UI.lineItem: [{ position: 80 }]
@UI.identification: [{ position: 80 }]
@Search.defaultSearchElement: true
@Consumption.valueHelpDefinition: [{ entity : {
name : 'ZI_PRODUCT_VH',
element : 'CreatedByUser'} }]
CreatedByUser;
@UI.lineItem: [{ position: 90 }]
@UI.identification: [{ position: 90 }]
@Search.defaultSearchElement: true
@Consumption.valueHelpDefinition: [{ entity : {
name : 'ZI_PRODUCT_VH',
element : 'LastChangeDate'} }]
LastChangeDate;
@UI.lineItem: [{ position: 100 }]
@UI.identification: [{ position: 100 }]
LastChangedByUser;
@UI.lineItem: [{ position: 110 }]
@UI.identification: [{ position: 110 }]
SalesStatus;
@UI.lineItem: [{ position: 120 }]
@UI.identification: [{ position: 120 }]
TaxClassification;
@UI.lineItem: [{ position: 130 }]
@UI.identification: [{ position: 130 }]
TransportationGroup;
}
ZI_PRODUCT_VH
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Value Help for Product'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZI_PRODUCT_VH as select from I_Product
{
key Product,
CreatedByUser,
LastChangeDate
}
SCREENSHOTS
Kulakçığa tıklandığında;


Değerlerden bir ya da birkaç tanesi seçilip rahatça arama yapmaya olanak sağlandı böylece.

Bir sonraki yazıda görüşmek dileğiyle 🙂
