SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Dictionary → Built-In Functions in ABAP Dictionary → SQL Functions → SQL Functions for Strings →SQL Function UPPER
This example demonstrates the SQL function UPPER in Open SQL and ABAP CDS.
Source Code
REPORT demo_sql_upper.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA:
query TYPE string VALUE `ERROR`,
rows TYPE i VALUE 100.
cl_demo_input=>add_field( CHANGING field = query ).
cl_demo_input=>request( CHANGING field = rows ).
query = `%` && to_upper( query ) && `%`.
rows = COND #( WHEN rows <= 0 THEN 100 ELSE rows ).
"UPPER in CDS view
SELECT arbgb, msgnr, text
FROM demo_cds_upper
WHERE sprsl = 'E' AND
upper_text LIKE @query
ORDER BY arbgb, msgnr, text
INTO TABLE @DATA(result1)
UP TO @rows ROWS.
"UPPER in Open SQL
SELECT arbgb, msgnr, text
FROM t100
WHERE sprsl = 'E' AND
upper( text ) LIKE @query
ORDER BY arbgb, msgnr, text
INTO TABLE @DATA(result2)
UP TO @rows ROWS.
ASSERT result1 = result2.
cl_demo_output=>display( result1 ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
A SELECT statement accesses the following CDS view, which uses the SQL function UPPER:
Another SELECT statement uses the SQL function UPPER directly to access the same data source T100.
Since SQL functions cannot yet be used on the left side of LIKE in the DDL of the ABAP CDS, the view returns a help field, which is evaluated in Open SQL. The results are the same. The search effected by the examples is not case-sensitive.