At times we see function modules without any exceptions but still there is a error message being thrown inside the function module if any piece of code fails. If this situation happens then the program terminates at that point. Ever wondered how do you capture the error message as there is no exception and hence no SY-SUBRC other than 0. Well here is the way.
In the program where you have written your code for the FM, include the following for the FM
EXCEPTIONS
error_message = 99.
EXCEPTIONS
error_message = 99.
By doing this you will ensure that whenever there is any error thrown by the function module, SY-SUBRC is set as 99 and you can then capture the message in system fields i.e. SY-MSGID, SY-MSGTY, SY-MSGNO, SY-MSGV1, SY-MSGV2, SY-MSGV3, SY-MSGV4, SY-MSGV5.
No comments:
Post a Comment