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( ... ) insteadUse modern string functions to_upper() or to_lower() insteadUse modern string function shift_left( ) or shift_right( ) insteadSEARCH statement is obsolete; prefer find( ) or contains( )OVERLAY statement is obsolete; prefer string functions or templatesObsolete REPLACE statement; prefer replace( ) functionUse 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):
- Position the cursor on the flagged statement.
- Press Ctrl + 1 (Quick Assist).
- 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 Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
CHECK_CONDENSE | Boolean | true | Suggest condense( ) function over CONDENSE statement |
CHECK_TRANSLATE | Boolean | true | Suggest to_upper( ) / to_lower( ) over TRANSLATE statement |
CHECK_SHIFT | Boolean | true | Suggest substring / shift functions over SHIFT statement |
CHECK_SEARCH | Boolean | true | Suggest find( ) function over SEARCH statement |
CHECK_OVERLAY | Boolean | true | Suggest string templates over OVERLAY statement |
CHECK_REPLACE | Boolean | true | Suggest replace( ) function over REPLACE statement |
CHECK_DESCRIBE | Boolean | true | Suggest 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_FUNCRelated Rules
- Prefer String Templates over CONCATENATE —
#EC PREF_STR_TMPL - Avoid Concatenating Adjacent String Literals —
#EC NO_USELESS_CONCAT - Avoid Obsolete String and POSIX Regex Statements —
#EC NO_OBS_STRINGS
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_STR_FUNC - Implementation File: zcl_skylint_pref_str_func.clas.abap