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: 

error catch of a function module exception in a method

Former Member
0 Kudos

Hello,

how do you catch the error of a function module that is called from within a method. Presently the process terminates in case of an exceptions. Sy-subrc seems also not to work.

E.G.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

client = sy-mandt

date = SOURCE_FIELDS-xxx

foreign_amount = SOURCE_FIELDS-xxx

foreign_currency = SOURCE_FIELDS-xxx

local_currency = SOURCE_FIELDS-xxx

IMPORTING

local_amount = RESULT

  • EXCEPTIONS

  • NO_RATE_FOUND = 1

  • OVERFLOW = 2

  • NO_FACTORS_FOUND = 3

  • NO_SPREAD_FOUND = 4

  • DERIVED_2_TIMES = 5

  • OTHERS = 6.

2 REPLIES 2

Former Member
0 Kudos

Hi,

Please uncomment the exceptions part and then check the sy-subrc .

You'll have to uncomment evrything from exceptions till the last .

Regards

Nishant

Message was edited by: Nishant Rustagi

dani_mn
Active Contributor
0 Kudos

HI,

use 'EXCEPTIONS' to catch the error happens in FM.

uncomment all your exceptions when calling FM.

and you will get the exception number in sy-subrc.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

client = sy-mandt

date = SOURCE_FIELDS-xxx

foreign_amount = SOURCE_FIELDS-xxx

foreign_currency = SOURCE_FIELDS-xxx

local_currency = SOURCE_FIELDS-xxx

IMPORTING

local_amount = RESULT

EXCEPTIONS

NO_RATE_FOUND = 1

OVERFLOW = 2

NO_FACTORS_FOUND = 3

NO_SPREAD_FOUND = 4

DERIVED_2_TIMES = 5

OTHERS = 6.

if sy-subrc = 2.

message e000(su) 'overflow.

endif.

Regards,