Select Text fields: Case-insensitive

Select Text fields: Case-insensitive

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

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

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

This was first published in July 2008

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.