sy-subrc checked after a method call

 home  single file   example  edit

stale_subrc

Description

Reports IF, CHECK, ASSERT or CASE on sy-subrc directly after a method call without EXCEPTIONS

Extended Information

A method call without EXCEPTIONS does not set sy-subrc. After the call, sy-subrc holds whatever
the last statement inside the method set, so the check depends on the method's implementation
and breaks silently when the method changes.

Check the result of the method instead, eg. a returning parameter or an exception, or move the
check directly after the statement that sets sy-subrc.

Reported: the statement directly before the check is a method call, CALL METHOD, or an
assignment with a method call or NEW in its source.

Not reported: a call with EXCEPTIONS or EXCEPTION-TABLE, an assignment that only calls built-in
functions like lines( ), and any other statement before the check, eg. CALL FUNCTION or
CREATE OBJECT, a check that is the first statement of a block, or a check after ENDIF.
An assignment or CLEAR without a call does not change sy-subrc, so a check after it still
reads the statement before it, which is not reported either.
See also check_subrc and subrc_after_assign.

Default Configuration

Hover to see descriptions, Ctrl+Space for suggestions

Examples