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 last published in July 2008

Dig Deeper on SAP workflow development

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close