I am developing a SAPUI5 application consuming oData services with SAP Gateway. I have implemented a search functionality which is producing a SQL where condition. One part of the condition looks like follows: ... OR DESCRIPTION LIKE '%searchString%'...
. In my database table I have a field DESCRIPTION
which is of type LCHR
length 32000
. The only problem is that the field DESCRIPTION
cannot be in WHERE
clause.
What would be a correct approach of searching long strings in database table via oData services? Do I need to hardcode the search functionality or is there some cleaner way?
The answer is CDS Table Function. The basic idea is to push the search down to HANA which is implemented by AMDP. I did some local testing to answer this by concrete code.
I created a table
zza_test
Defined a CDS table function
zza_test_tf
with parametersearch_str
.Created a Class
zcl_zza_test_tf
with interfaceif_amdp_marker_hdb
and implement the methodsearch_des
Now we have a CDS table funtion with parameters. Run the CDS view and input the search parameter to get the result. You can even define your HANA SQL in your AMDP implementation with fuzzy search.
To fulfill the requirement, you implement the Open SQL select on this CDS view at your GateWay layer.
Everything should work. Hope it helps. Thank you!