Application Development and Automation 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: 
Read only

Problem with Exception

Former Member
0 Likes
518

Hi,

The following is the program.

<b>REPORT ZTX2007.

parameters parm_in default 'A'.

data vout(4) value 'INIT'.

CALL FUNCTION 'Z_TX_2008'

EXPORTING

exname = parm_in

IMPORTING

POUT = vout

EXCEPTIONS

ERROR_A = 1

ERROR_B = 4

ERROR_C = 4

OTHERS = 99.

write: / 'sy-subrc =', sy-subrc,

/ 'vout =', vout.</b>

Below is the function module.

<b>FUNCTION Z_TX_2008.

*"----


""Local interface:

*" IMPORTING

*" VALUE(EXNAME)

*" EXPORTING

*" VALUE(POUT)

*" EXCEPTIONS

*" ERROR_A

*" ERROR_B

*" ERROR_C

*"----


pout = 'XXX'.

case exname.

when 'A'.

raise error_a.

when 'B'.

raise error_b.

when 'C'.

raise error_c.

endcase.

ENDFUNCTION.</b>

Output:

When parm_in = 'A' , sy-subrc value is 1.

When parm_in = 'B', sy-subrc value is 4.

When parm_in = 'C', sy-subrc value is 4.

For the above 3 cases, i get the desired output.

I want the sy-subrc value to be 99 when i enter any other characters in Parm_in.

How to accomplish this?

Do i have to make any changes in the function module?

Please explain...

Thanks,

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
496

Hi your FM ,

use

when others.

raise error_OTHERS.

endcase

also define an excpetion in se37 - exception tabs with the same name.

2 REPLIES 2
Read only

Former Member
0 Likes
497

Hi your FM ,

use

when others.

raise error_OTHERS.

endcase

also define an excpetion in se37 - exception tabs with the same name.

Read only

Former Member
0 Likes
496

hi,

I think in the case statement u need to write the condition

when 'OTHERS'.