Supported by
Supported by Inetum

Ignore function module exceptions

images/thumbnail.jpg - Thumbnail

When calling a function module which returns exceptions you normally give them sequential numbers like this:

CALL FUNCTION 'GO_BUT_PLEASE_COME_BACK'
  EXPORTING
    ali = 'To the moon'
  EXCEPTIONS
    NOT_FOUND = 1
    GOT_LOST  = 2
    OTHERS    = 3.

But Code Inspector may be configured to report a warning if afterwards you are not careful to add an IF or a CASE to look at SY-SUBRC,

There are, nevertheless, occasions in which you’re 100% sure that the function module will success and can do without checking SY-SUBRC.

In those cases you can do two things to avoid the Code Inspector warning:

1. Use the pseudocomment “#EC CI_SUBRC 2. Set all return values = 0. Like this:

CALL FUNCTION 'GO_BUT_PLEASE_COME_BACK'
  EXPORTING
    ali = 'To the moon'
  EXCEPTIONS
    NOT_FOUND = 0
    GOT_LOST  = 0
    OTHERS    = 0.

I found this last one quite amusing.

Thanks Leo Reynolds for the photo.

Greetings from Abapinho.