Problem solve Get help with specific problems with your technologies, process and projects.

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

Dig Deeper on SAP development and programming languages

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchContentManagement

SearchHRSoftware

Close