‎2006 Jul 11 10:10 AM
hi,
iam creting a function module . but i dont know how to give exceptions. can any body explain how give exceptions in FM.
chandu
‎2006 Jul 11 10:14 AM
Hi,
Goto Exception Tab
Enter the Exception Name
If u want to raise exception in code.
just write
raise <Exception Name>
Declaring Exception is similar to declaring a simple importing / Exporting Parameter.
Only diffrence is it dont have any type.
In the Exception Tab ; Enter these Values
1) Exception Name
2) Exception Discription.
‎2006 Jul 11 10:15 AM
‎2006 Jul 11 10:16 AM
Hello In the Exceptions Tab,
Give Like this.
INCONSISTENT_PARAMETERS
UPLOAD_OLE
The sy-Subrc will be set as 1 & 2 etc.
If useful reward points.
REgards,
Vasanth
‎2006 Jul 11 10:16 AM
Hi,
You can create the Exceptions in the Exceptions tab in the Function module,
There are two ABAP statements for raising exceptions. They can only be used in function modules:
<b>RAISE <except>.</b>
and
<b>MESSAGE..... RAISING <except>.</b>
The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.
If the calling program does not handle the exception
The RAISE statement terminates the program and switches to debugging mode.
The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.
If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
<b>See this link for more info</b>
http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801f02454211d189710000e8322d00/frameset.htm
Thanks
Sudheer
‎2006 Jul 11 10:17 AM
Hi Chandra,
In the Exceptions tab you have to declare your exceptions and the short text for that exception.In the source code of the FM.You have to raise these exceptions.
Check this example.
CALL FUNCTION 'VIEWPROC_V_T6B1'
EXPORTING
FCODE = FUNCTION
VIEW_ACTION = MAINT_MODE
VIEW_NAME = VIEW_NAME
CORR_NUMBER = CORR_NUMBER
IMPORTING
UPDATE_REQUIRED = STATUS_V_T6B1-UPD_FLAG
TABLES
EXCL_CUA_FUNCT = EXCL_CUA_FUNCT
EXTRACT = V_T6B1_EXTRACT
TOTAL = V_T6B1_TOTAL
X_HEADER = X_HEADER
X_NAMTAB = X_NAMTAB
DBA_SELLIST = DBA_SELLIST
DPL_SELLIST = DPL_SELLIST
CORR_KEYTAB = E071K_TAB
EXCEPTIONS
MISSING_CORR_NUMBER = 1
NO_VALUE_FOR_SUBSET_IDENT = 2
SAVING_CORRECTION_FAILED = 3.
CASE SY-SUBRC.
<b> WHEN 1. RAISE MISSING_CORR_NUMBER.
WHEN 2. RAISE NO_VALUE_FOR_SUBSET_IDENT.</b>
WHEN 3.
ENDCASE.
This FM is called in another Function module that you will create both the exceptions 'RAISE MISSING_CORR_NUMBER' 'RAISE NO_VALUE_FOR_SUBSET_IDENT' with the text you have to declare in your exceptions tab.
Message was edited by: mukesh kumar
‎2006 Jul 11 10:17 AM
hi
execeptions are just nothing but identifiers
which u can use to raise a sensible message to the user other wise it would have dumped on screen
give any name for exception and a description
eg: not_valid : not a valid number
and when ever in the code u want to raise an exception
use statement
raise not_valid.
Regards
Harish
Reward if useful.
‎2006 Jul 11 10:17 AM
define all your exceptions, in the function module,
ex : FILE_WRITE_ERROR is the exception i defined in the function module & to call use RAISE
if you want to raise any exception,
use
if sy-subrc <> 0.
RAISE FILE_WRITE_ERROR.
endif.
regards
srikanth
‎2006 Jul 11 10:17 AM
In the Exceptions tab while creating FM ,
eg: give any name eg : <b>NOT_VALID</b> and its short text as <b>Check not valid</b>
and in the source code
SELECT SINGLE * FROM T005 WHERE LAND1 = COUNTRY.
IF SY-SUBRC NE 0.
MESSAGE E001 WITH COUNTRY RAISING <b>NOT_VALID</b>.
ENDIF.
‎2006 Jul 11 10:17 AM
Lets say we have a FM to fetch material description for a given material number. So one exception can be created as MATERIAL_NOT_FOUND. GO to the exceptions tab in your FM through SE37 and give an exception name MATERIAL_NOT_FOUND.
To raise this exception inside the code use syntax : RAISE MATERIAL_NOT_FOUND.
‎2006 Jul 11 10:18 AM
Hi ,
In FM you will have a tab called exceptions name the exceptions in that place .once that is done go to source code . and write the following thing based on certain condition are something where you like to raise the error.
for this write
if condition.
raise excpetionname.
endif.
regards,
Manohar.