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

HOW TO RAISE EXCEPTION IN FUNCTION MODULE !

Former Member
0 Likes
34,435

I have created a function module....where i want to raise some error message when some wrong data will be inputed

what is the syntax ? Please tell me the syntax .

1 ACCEPTED SOLUTION
Read only

Former Member
10,998

hi you can do like this:

in exception tab of FM write exceptions you want to raise.

e.g. incorrect_input.

now in code write

if input not correct (write your validation condition here)

raise incorrect_input.

endif.

reward if useful.

5 REPLIES 5
Read only

Former Member
0 Likes
10,998

hi,

do this way ..


raise invalid_input. 

Regards,

Santosh

Read only

Former Member
0 Likes
10,998

You define your exceptions in one of the tabs in SE37.

Say you create one

BAD_DATA

when you want to return this error

RAISE BAD_DATA.

Function exits with sy-subrc = to whatever was assigned during the definition.

Read only

Former Member
0 Likes
10,998

Hi,

1. Declare the exceptions in the exception tab.

2. Check the necessary condition in the code. If not satisfied,

RAISE <exception> ---> This should be declared in the Exception tab of the FM.

Thanks and Regards,

Lakshmi.

Read only

Former Member
10,999

hi you can do like this:

in exception tab of FM write exceptions you want to raise.

e.g. incorrect_input.

now in code write

if input not correct (write your validation condition here)

raise incorrect_input.

endif.

reward if useful.

Read only

Former Member
0 Likes
10,998

Not a bad solution, but it will lead to dump.

If you want to regain control returning to the code part calling your FM, then you should use

MESSAGE '' TYPE 'I' RAISING error_type.