Avoid Obsolete String and POSIX Regex Statements
WarningAnti-Patterns & Bad Practices#EC NO_OBS_STRINGSRemote Enabled
Overview
Obsolete String and Regex Statements.
ATC Finding Message:
Avoid obsolete string statements (PACK, UNPACK, POSIX REGEX, etc.)
Rationale
Statements such as PACK, UNPACK, REPLACE ... INTO, and FIND/REPLACE with REGEX / OCCURENCES (along with POSIX regular expression classes like CL_ABAP_REGEX=>CREATE_POSIX) are legacy constructs superseded by modern PCRE (Perl-Compatible Regular Expressions via PCRE keywords / XCO regex) and standard string expressions / built-ins.
Non-Compliant
abap
PACK lv_source TO lv_packed.
FIND REGEX 'pattern' IN lv_text.Compliant
abap
FIND PCRE 'pattern' IN lv_text.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_PACK | Boolean | true | Detect obsolete PACK statement (prefer numeric assignment) |
CHECK_UNPACK | Boolean | true | Detect obsolete UNPACK statement |
CHECK_REGEX | Boolean | true | Detect obsolete POSIX regex statements in favour of PCRE |
CHECK_OCCURENCES | Boolean | true | Detect obsolete OCCURRENCES addition syntax |
CHECK_REPLACE_INTO | Boolean | true | Detect obsolete REPLACE ... WITH ... INTO syntax |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_OBS_STRINGS
" SAP CI_ prefix format:
... "#EC CI_NO_OBS_STRINGSRelated Rules
- Avoid Obsolete Arithmetic and Assignment Statements —
#EC NO_OBS_ARITH - Avoid Obsolete Control Flow and Procedural Forms —
#EC NO_OBS_CONTROL - Avoid Obsolete Declarations and Table Headers —
#EC NO_OBS_DECL
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_OBS_STRINGS - Implementation File: zcl_skylint_no_obs_strings.clas.abap