‎2008 Feb 08 10:36 AM
Hi i am creating a FM
i wanna know how is return codes used in FM
Any example?
Whats there use even if i m running my FM in background
Thnkx
‎2008 Feb 08 10:38 AM
Hi Bhanu,
Return codes are the SY-SUBRC values set by a funtion module when you raise an exception. Say you have created 5 exceptions for a function module, then the first function module if raised using RAISE <exception> command would set SY-SUBRC as 1 in the calling program ... and so on.
It is mainly used for exception/error handling.
E.g. You have a function module with exceptions
EXCEPTION1
EXCEPTION2
When you call the function module in calling program using Pattern, it would create the following code:
EXCEPTIONS
EXCEPTIONS1 = 1
EXCEPTIONS2 = 2.
Regards,
Aditya
Edited by: Aditya Laud on Feb 8, 2008 5:38 AM
‎2008 Feb 08 10:39 AM
‎2008 Feb 08 10:41 AM
The exporting section of the interface is used to communicate the results of the ABAP handler processing. The return code RFCRC parameter is a single field used to determine the code a connector returns. The possible values are:
RC = 0 (success, VALCHANGE)
RC = 1 (failure, FAIL)
The RETURN_TEXT parameter is a 120-character free text field that is written to by the connector or logged as an error message in the return status descriptor. If the ABAP handler does not provide a value for this parameter, then Y_XR_RFC_DO_VERB_NEXTGEN supplies default text depending on the return code.
Note:
The exceptions section of the interface defines two exceptions. It is recommended that you use the exporting parameters instead.
REWARD POINTS IF USEFUL
‎2008 Feb 08 10:43 AM
Hi,
Inorder to get return codes u have to maintain exceptions in the function module and u have to raise that exception in the function module then only when u call the FM in ur program the sy-subrc value is returned other wise it will always return as ZERO..
this is the way u have to do..
source code in FM..
import
MATNR TYPE MATNR
export
....
tables
...
exceptions
NO_DATA
select matnr from mara where matnr = matnr.
if sy-subrc ne 0.
RAISE NO_DATA.
endif.
ENDFUCNTION.
now when u call this FM in ur program
CALL FUNCTION <FMNAME>
EXPORT
MATNR = MATNR
EXCEPTIONS
NO_DATA = 1.
if sy-subrc ne 0.
throw error message.
endif.
Regards,
Nagaraj
‎2008 Feb 08 11:03 AM