Skip to content

Ensure Opened Datasets and Cursors are Closed ​

WarningSecurity & Robustness#EC NO_UNCLOSED_RESRemote Enabled

Overview ​

Ensure opened datasets and cursors are closed.

ATC Finding Messages:

  • OPEN DATASET is not closed; resource leak risk
  • OPEN CURSOR is not closed; database cursor leak risk

Rationale ​

Resources opened on the application server (OPEN DATASET) or database (OPEN CURSOR) must always be explicitly closed (CLOSE DATASET, CLOSE CURSOR). Leaving resources open causes operating system file descriptor leaks, persistent file locks, and can trigger the fatal runtime error DBSQL_TOO_MANY_OPEN_CURSOR (maximum 17 open database cursors session limit).

Non-Compliant ​

abap
OPEN CURSOR @DATA(dbcur) FOR SELECT * FROM t100.
" Cursor remains open without CLOSE CURSOR!

Compliant ​

abap
OPEN CURSOR @DATA(dbcur) FOR SELECT * FROM t100.
FETCH NEXT CURSOR @dbcur INTO TABLE @DATA(lt_data).
CLOSE CURSOR @dbcur.

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_DATASETBooleantrueCheck unclosed OPEN DATASET statements
CHECK_CURSORBooleantrueCheck unclosed OPEN CURSOR statements

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.