"
Supported by

Ignore function module exceptions

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.

2 comentários a “Ignore function module exceptions”

  1. SÉRGIO FRAGA Diz:

    Muito Fixe,

    convém o belo do comentário para o próximo developer perceber qual a razão de tanto 0!

  2. Rui Dantas Diz:

    e… basta o OTHERS, certo?

Deixe um comentário


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).