Skip to content

Prefer Built-in String Functions over SEARCH/SHIFT ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_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 ValueDescription & Guidance
CHECK_CONDENSEBooleantrueSuggest condense( ) function over CONDENSE statement
CHECK_TRANSLATEBooleantrueSuggest to_upper( ) / to_lower( ) over TRANSLATE statement
CHECK_SHIFTBooleantrueSuggest substring / shift functions over SHIFT statement
CHECK_SEARCHBooleantrueSuggest find( ) function over SEARCH statement
CHECK_OVERLAYBooleantrueSuggest string templates over OVERLAY statement
CHECK_REPLACEBooleantrueSuggest replace( ) function over REPLACE statement
CHECK_DESCRIBEBooleantrueSuggest describe_by_data( ) over DESCRIBE FIELD

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.