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

Passing exception

Former Member
0 Likes
550

How to pass the exception of a function module so that it can be raised in a different program?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
520

Hi,

The exception of the FM is returned to the calling program via the SY-SUBRC field

You can evaluate the sme to know which exception has been triggered.

the value of sy-subrc is set to the exception number

if the first excpetion defined in the Excep tab is raised the subrc value will be 1

if the 2nd excpetion defined in the Excep tab is raised the subrc value will be 2

so you can come to know which exception was raised inside the FM

regards,

gaurav

3 REPLIES 3
Read only

Former Member
0 Likes
520

Hi

Define different exceptions based on the value of SY-SUBRC field in the fun module

and when that fun module is used in the program based on the value of the Sy-SUBRC you just raise the exception.

Case Sy-subrc.

when 1.

raise FILE_NOT_FOUND.

when 2.

Raise UNABLE_TO_OPEN_FILE.

endcase.

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
520

The actual scenario is, I am calling perform statement in the include of a function module.The form is written in a different program(subroutine pool).I have to raise the exeption of the function module inside this program.How to do that?

Read only

Former Member
0 Likes
521

Hi,

The exception of the FM is returned to the calling program via the SY-SUBRC field

You can evaluate the sme to know which exception has been triggered.

the value of sy-subrc is set to the exception number

if the first excpetion defined in the Excep tab is raised the subrc value will be 1

if the 2nd excpetion defined in the Excep tab is raised the subrc value will be 2

so you can come to know which exception was raised inside the FM

regards,

gaurav