Extending SAP Fiori app with search help & filter based on SAP Gateway Service
This blog is a sequel of Extending SAP Fiori app based on SAP Gateway Service – SAP Extensibility 101 where I took step by step how to extend SAP Fiori app ‘Manage Customer Line Item(F0711)’. To do the exercise in this blog, you must complete the steps in the aforementioned blog.
The Setup
In this previous blog, we extended a custom field ‘Custom field 1’ to Manage Customer Line Item(F0711) app and mapped Consolidation Unit from accounting document item. In this blog, we will learn how to add search help in the filter prompt in Fiori so that user can search and filter using value prompted.
1. Define custom search help
First, create search help with the same name as the custom fields. In our case it’s ZZ1_CUSTOMFIELD1. FINCS_BUNIT is used as base data source for search help. Make sure to list the Search help parameters as follows.
Go to your SEGW project and define entity types for the search help with prefix ‘VL_SH_’. Add Value and text as properties, which will be shown in the search help.
Define entity set with the same name.
Save and Generate the project.
2. Add logic to bind search help as property metadata
Go to <your class>_MPC_EXT class and redefine DEFINE class. To add search help to the custom fields, it must be bound as annotation to the custom field and let it trigger search help. To do so we must add below logic in redefined DEFINE method to do the binding.
method DEFINE.
CONSTANTS:cns_namespace TYPE string VALUE 'FAR_CUSTOMER_LINE_ITEMS',
cns_entitytype TYPE string VALUE 'Item'.
super->define( ).
" Connect custom fields to value help entity types configured in the project
cl_fis_shlp_annotation=>create(
io_odata_model = model
io_vocan_model = vocab_anno_model
iv_namespace = cns_namespace
iv_entitytype = cns_entitytype
iv_property = 'ZZ1_CUSTOMFIELD1'
iv_valuelist_entityset = 'VL_SH_ZZ1_CUSTOMFIELD1'
iv_valuelist_property = 'BUNIT'
iv_search_supported = abap_true
)->add_display_parameter( iv_valuelist_property = 'TXTSH'
).
endmethod.
Go to transaction code ‘/n/iwfnd/maint_service’ and search for ZFAR_CUSTOMER_LINE_ITEMS and go to Gateway Client. Add ‘/$metadata’ as URI option and execute. We will see the metadata of the service. Search for string ‘ZZ1_CUSTOMFIELD1’.
Below entry in metadata is what is needed to trigger search help for the custom field in this app. This is an annotation targeting the custom fields that triggers VL_SH_ZZ1_CUSTOMFIELD1 and the SAP standard code will search for search help name that is without ‘VL_SH_’. What is left is ‘ZZ1_CUSTOMFIELD1’ so the search help ZZ1_CUSTOMFIELD1 we created will be triggered.
Check result
Now go to the Fiori app, choose Adapt Filter and add Custom field 1 as filter. Click on the search help and you should be able to see the data from our search help ZZ1_CUSTOMFIELD1.