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

Return codes

Former Member
0 Likes
2,206

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,288

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

Read only

Former Member
0 Likes
1,288

Hello,

Have a look at this thread.

Might be useful for you.

Cheers,

Vasanth

Read only

Former Member
0 Likes
1,288

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

Read only

former_member404244
Active Contributor
0 Likes
1,288

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,288

Look at [Calling Function Modules|http://help.sap.com/saphelp_47x200/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/frameset.htm]

Regards