Select Text fields: Case-insensitive

Searching for strings is cumbersome if the table field isn't defined as Case-insensitive. By using EXEC-SQL there's a way to do this selection case-insensitive.

Searching for strings (parts or with pattern) is cumbersome if the table field isn't defined as case-insensiti

ve.

Example:

Search all requests in "E07T" where "AS4TEXT" contains "Sales."

With a normal SELECT * FROM E070T WHERE AS4TEXT LIKE gv_text" values like SALES or sales will not be found.

By using EXEC-SQL, there's a way to do this selection Case-insensitive:

REPORT xy.
DATA:
  gt_e07t       TYPE TABLE OF e07t WITH HEADER LINE,
  gv_reqtxt(60).

PARAMETERS p_text TYPE rzielort.

*** Selection by Request text
*** Native SQL needed since as4text is case sensitive but we
*** want to search case-insensitive
gv_reqtxt = p_text.
TRANSLATE gv_reqtxt TO UPPER CASE.
CONCATENATE '%' gv_reqtxt '%' INTO gv_reqtxt.
*** Change SAP-wildcards to DB-wildcards TRANSLATE gv_reqtxt USING '*%'.
TRANSLATE gv_reqtxt USING '+_'.
EXEC SQL PERFORMING append_e07t.
  SELECT * FROM e07t INTO :gt_e07t
      WHERE upper(as4text) LIKE :gv_reqtxt ENDEXEC.
DESCRIBE TABLE gt_e07t LINES sy-dbcnt.
CHECK sy-dbcnt GT 0.

LOOP AT gt_e07t.
  WRITE: / gt_e07t-trkorr, gt_e07t-as4text.
ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  append_e07t
*&---------------------------------------------------------------------*
*         text
*-----------------------------------------------------------------------*
FORM append_e07t.
  APPEND gt_e07t.
ENDFORM.                    "append_e07t
This was first published in July 2008

Dig deeper on SAP workflow development

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close