Skip to content

Prefer Built-in String Functions over SEARCH/SHIFT ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC STR_FUNCRemote Enabled

Overview ​

Detect obsolete string statements; prefer built-in functions.

ATC Finding Messages:

  • Use modern built-in string function condense( ... ) instead
  • Use modern string functions to_upper() or to_lower() instead
  • Use modern string function shift_left( ) or shift_right( ) instead
  • SEARCH statement is obsolete; prefer find( ) or contains( )
  • OVERLAY statement is obsolete; prefer string functions or templates
  • Obsolete REPLACE statement; prefer replace( ) function
  • Use strlen( ... ) instead of DESCRIBE FIELD ... LENGTH

Rationale ​

Statements such as CONDENSE, TRANSLATE, SHIFT, and SEARCH mutate a variable and cannot be used inside expressions. Built-in functions return values, compose cleanly, and make the intended transformation explicit. Use functions such as to_upper, to_lower, find, substring, and shift_left instead.

Non-Compliant ​

abap
SHIFT lv_code LEFT BY 2 PLACES.
TRANSLATE lv_country TO UPPER CASE.

Compliant ​

abap
lv_code = shift_left( val = lv_code places = 2 ).
lv_country = to_upper( lv_country ).

Automated QuickFix ​

This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. Select the automated refactoring to apply the clean syntax immediately.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault Value
CHECK_CONDENSEBooleantrue
CHECK_TRANSLATEBooleantrue
CHECK_SHIFTBooleantrue
CHECK_SEARCHBooleantrue
CHECK_OVERLAYBooleantrue
CHECK_REPLACEBooleantrue
CHECK_DESCRIBEBooleantrue

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC STR_FUNC

" SAP CI_ prefix format:
... "#EC CI_STR_FUNC

Technical Details ​

Released under the MIT License.