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 riskOPEN 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 Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
CHECK_DATASET | Boolean | true | Check unclosed OPEN DATASET statements |
CHECK_CURSOR | Boolean | true | Check 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_RESRelated Rules
- Avoid Database Access Inside Loops (N+1 Query Antipattern) —
#EC NO_DB_IN_LOOP - Avoid Obsolete ABAP Memory and Context Statements —
#EC NO_OBS_MEMORY
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_UNCLOSED_RES - Implementation File: zcl_skylint_no_unclosed_res.clas.abap