Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Exception handling

Clemenss
Active Contributor
0 Kudos

Hi,

in a classical userexit we have just one include to put in the coding.

I want to call a newly-created function function in this include. The function is a copy of the customer-function where the include is located in.

How can we achieve that exceptions raised are passed to the calling function?

Example:


function exit_saplv55k_004 .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"       EXPORTING
*"             VALUE(PROCESSING_PROTOCOL) TYPE  DELIF_T_PROTT
*"       TABLES
*"              IDOC_DATA STRUCTURE  EDIDD
*"       CHANGING
*"             VALUE(IDOC_CONTROL) LIKE  EDIDC STRUCTURE  EDIDC
*"       EXCEPTIONS
*"              IDOC_ERROR
*"              DO_NOT_PROCESS_IDOC
*"----------------------------------------------------------------------


include zxtrku12 .


endfunction.
--
*&---------------------------------------------------------------------*
*& Include.: ZXTRKU12                                                  *
call function 'Z_EXIT_SAPLV55K_004'
  importing
    processing_protocol = processing_protocol
  tables
    idoc_data           = idoc_data
  changing
    idoc_control        = idoc_control
  exceptions
    idoc_error          = 1
    do_not_process_idoc = 2
    others              = 3.

Are the exceptions passed to the calling function? How to achieve this, how to raise OTHERS?

TIA,

Regards,

Clemens

3 REPLIES 3

Former Member
0 Kudos

Hi,

You have to check for each subrc value and raise the exception the accordingly..

As the exception is not getting carried over to the calling function..

For others I believe you don't have to do anything..

Also if you put where used list of the exit function module...The exceptions are not handled...Meaning the exceptions are given..But after the FM call they are checking for the values in the importing parameter PROCESSING_PROTOCOL...Not checking for sy-subrc value..

Thanks,

Naren

Former Member
0 Kudos

You need to check sy-subrc ,

Function module returns sy-subrc ,based on ur exception ,it will return sy-subrc.

idoc_error = 1

do_not_process_idoc = 2

others = 3.

Here idoc_error ,this means sy-subrc eq 1

do_not_process_idoc is sy-subrc eq 2.

So use your validation within ur include program like

case sy-subrc.

when '1'.

message

when '2'.

message

when others.

message.

endcase.

Reward Points if it is helpful

Thanks

Seshu

Clemenss
Active Contributor
0 Kudos

... turned to classes and class-based exceptions. Issue disappeared.

Regards,

Clemens