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 add exceptions to function module

Former Member
0 Likes
1,994

Hi Experts ,

I have a query , how to add exceptions to a standard function module when there are no exceptions provided by default . Also please let me know by adding exceptions can we just throw a message and will we be able to prevent the program from going into dump.

1 ACCEPTED SOLUTION
Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
1,207

Hi,

It is not possible to add exceptions to std FM without raising for an OSS message. After getting the key for editing the FM u can add the Exceptions and can give some messages in the program after a sy-subrc check. But this is not recommended as this FM might be used in different programs.

Keerthi.

Edited by: Keerthy K on Feb 25, 2009 11:23 AM

7 REPLIES 7
Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
1,208

Hi,

It is not possible to add exceptions to std FM without raising for an OSS message. After getting the key for editing the FM u can add the Exceptions and can give some messages in the program after a sy-subrc check. But this is not recommended as this FM might be used in different programs.

Keerthi.

Edited by: Keerthy K on Feb 25, 2009 11:23 AM

Read only

naveen_kumar116
Active Participant
0 Likes
1,207

Hi,

U can use Return code to avoid Dumb.

use PROCESS_MESS_GET_RETURN_CODE

or Search RETURNCODE* in SE37 find suitable FM to ur requirement

Read only

MarcinPciak
Active Contributor
0 Likes
1,207

Hi Balaji,

As this is standard function module, I think you can't change its code, which will be required to raise some exceptions.

As for the second question if you use in FM such statement


RAISE exc.

Then after calling this FM you need to handle this exceptions, otherwise system will dump out.


CALL FM '....'
...
EXCEPTIONS
    exc = 2.

if sy-subrc <> 2.
   MESSAGE ....  'Exception raised'.
endif.

If you want to handle it inside the FM, you need to write like this:


MESSAGE .... RAISING exc.

After this when exception is raised system will end up the FM and the result is stored in sy structure


CALL FM '...'
...
EXCEPTIONS
      exc = 2.
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Regards

Marcin

Read only

Former Member
0 Likes
1,207

Hi Naveen ,

I had a look at the function module " PROCESS_MESS_GET_RETURN_CODE " but not sure how to use that to raise an exception , can you please help me with it , do you have any sample code showing the use of this FM .

Thanks

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,207

As in previous answers, I do not advise you to change a strandard function module.

You can in an exit / Badi send an error message, the calling programs must intercept the exception ERROR_MESSAGE to avoid any dump.

Regards

Read only

Former Member
0 Likes
1,207

Hi,

You can define your own exceptions and inside the source code.... use RAISE statement to show the message without going into DUMP.

r

Read only

Former Member
0 Likes
1,207

Solved