Technical Articles
Code Snippet Series: Case Insensitive Table Query
This post is part of a series on code snippets. The complete list of posts in the series is available in the document Code Snippets: A Blog Series.
The ability to query case-sensitive data in a case-insensitive way is a frequent request from both business owners user groups. Examples include searching for a surname “McDonough” or an equipment model “F123b-A”. Users may not know the correct capitalization and a caps-only field may not be available in the database table.
Case-insensitive comparison is possible in Open SQL with the release of SAP_BASIS 751. On older releases, we can use native SQL to perform a case-insensitive query of any database table.
TRY.
EXEC SQL.
SELECT equnr
FROM equi
INTO :the_equnr
WHERE UPPER(herst) = :an_uppercase_herst
AND UPPER(serge) = :an_uppercase_serge
AND UPPER(typbz) = :an_uppercase_typbz
ENDEXEC.
CATCH cx_sy_native_sql_error .
ENDTRY.
Hi Amy,
Nice to see you back.
With ABAP 751 Open SQL supports the case insensitive functionality:
https://blogs.sap.com/2016/10/18/abap-news-release-7.51-case-insensitive-search-sql-new-functions/
BR,
Suhas
Thanks Suhas, we were still on 740 when I wrote this. I'll update with a link to Horst's blog post.
Amy, the link points to scn.sap.com. There are no more "documents" on SCN, you might want to update this.
Also we can use "user tags" now, so if you would tag all the posts with, say, "ABAP snipper" then everyone could easily find them just by clicking on the tag link. And those tags can actually be followed, as I understand.
Thanks for the heads up Jelena. I'm not sure I want to go back and edit every post I've made to update the links. That seems like a lot to ask of authors when SAP reorganizes the site. I notice SAP does forward from scn.sap.com to the new location on blogs.sap.com. Hopefully they'll continue to do so.
Cheers.