‎2006 Apr 18 9:18 PM
Hi all,
When we call a function module how will the sy-subrc value will be set ? Is it based upon the exception value ? say a FM is called and it is returning a value other than 0 and not matches with the eception values, how can we identify why the FM call failed ?
Thanks and Regards,
Varun.
‎2006 Apr 18 9:44 PM
CALL FUNCTION 'F4IF_DETERMINE_SEARCHHELP'
EXPORTING
TABNAME = TABNAME
FIELDNAME = FIELDNAME
selection_screen = selection_screen
IMPORTING
SHLP = SHLP_TOP
EXCEPTIONS
FIELD_NOT_FOUND = 1
NO_HELP_FOR_FIELD = 2
INCONSISTENT_HELP = 3
OTHERS = 4.
In the above call, as you can see, the numbers 1, 2, 3 are given by you when you are calling it. The call function will set the sy-subrc to the value that is against the given exception. Within the function module, the exception is raised by its name. So in this function module code, you will see the code like
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING FIELD_NOT_FOUND.Then you will get a sy-subrc of 1 because that is the number you gave. But if give a number 10 instead of 1 for FIELD_NOT_FOUND, your sy-subrc will be 10.
If you are getting a value other than the ones specified in exceptions, then you have to trap it in OTHERS exception. This is an exception not raised, but just occured in the function module.
Hope this clarifies.
Srinivas
‎2006 Apr 18 9:32 PM
If you call a function module and an exception is not raised, sy-subrc has the value 0 after the FM executes. (At least, that's what happened in my test.)
Rob
‎2006 Apr 18 9:38 PM
Hi Rob,
Can sy-subrc take any value other than zero when the exception is not raised ? How can we identify what the error is when sy-subrc is not 0 and exception is not raised ? In my case FM is calling some other FM and the chain continues like that.
Thanks and Regards,
Varun.
‎2006 Apr 18 9:42 PM
I ran the following test:
REPORT ztest MESSAGE-ID zc.
sy-subrc = 8.
CALL FUNCTION 'Z_ROB_TEST'.
break rburbank.The function 'Z_ROB_TEST' was:
function z_rob_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*"----------------------------------------------------------------------
sy-subrc = 9.
endfunction.After the execution of the FM, sy-subrc was 0.
Rob
‎2006 Apr 18 9:44 PM
CALL FUNCTION 'F4IF_DETERMINE_SEARCHHELP'
EXPORTING
TABNAME = TABNAME
FIELDNAME = FIELDNAME
selection_screen = selection_screen
IMPORTING
SHLP = SHLP_TOP
EXCEPTIONS
FIELD_NOT_FOUND = 1
NO_HELP_FOR_FIELD = 2
INCONSISTENT_HELP = 3
OTHERS = 4.
In the above call, as you can see, the numbers 1, 2, 3 are given by you when you are calling it. The call function will set the sy-subrc to the value that is against the given exception. Within the function module, the exception is raised by its name. So in this function module code, you will see the code like
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING FIELD_NOT_FOUND.Then you will get a sy-subrc of 1 because that is the number you gave. But if give a number 10 instead of 1 for FIELD_NOT_FOUND, your sy-subrc will be 10.
If you are getting a value other than the ones specified in exceptions, then you have to trap it in OTHERS exception. This is an exception not raised, but just occured in the function module.
Hope this clarifies.
Srinivas
‎2006 Apr 18 9:46 PM
If there is an error message issued in the function module without actually using 'RAISE' you will still get a non-zero sy-subrc(and not equal to any of the values you specified in your EXCEPTIONS values).