‎2007 Jul 24 4:15 AM
Hi all,
In my Function Module under Exception i defined Exception E01 and raise exception when there is no row found using SY-SUBRC.
And in my report i want to show error text.
CALL FUNCTION 'Z_FM_TEST1'
EXPORTING
MAT_TYPE = MAT_TYPE
TABLES
TAB_MARA = MARATABLE
EXCEPTIONS
E01 = 1
OTHERS = 2
.
IF SY-SUBRC = 1.
MESSAGE e0001(E01).
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
How to do it
Sachin
‎2007 Jul 24 4:42 AM
Ya you can do that ... immediately after calling the FM ...do this way
CALL FUNCTION 'Z_FM_TEST1'
EXPORTING
MAT_TYPE = MAT_TYPE
TABLES
TAB_MARA = MARATABLE
EXCEPTIONS
E01 = 1
OTHERS = 2
.
IF SY-SUBRC = 1.
<b>MESSAGE e001 with 'E01 Exception raised'.</b> " 001 has to be 3 character length
ENDIF.
‎2007 Jul 24 4:22 AM
hi Sachin,
Inside the FM try coding in this way ..
if sy-subrc <> 0.
raise E01.
endif.
‎2007 Jul 24 4:38 AM
Hi Santosh,
I did it in this way only. but i am not been able to catch that exception in my REPORT where i am calling that FM.
I also catched that exception and <b>print that Error text</b> that i gave in Exception short text.
Is it possible?
and if so, please tell me how to do it?
Any Help will be rewarded.
Sachin.
‎2007 Jul 24 4:56 AM
first of all put a break point and check whether the raise statement is executing or not ? if it is executing then sy-subrc must be 1.
in the message write
if sy-subrc = 1.
message '<same text as in the exception>' type 'E'.
endif.
or you can go through the message class also(se91).
if sy-subrc = 1.
message e001(zspd).
endif.
just dbl click on the zspd and give the text(message text) there and save it.
regards
shiba dutta
‎2007 Jul 24 4:23 AM
i am not enough sure what you want but you can try like this in fm source code.
select * from mara into corresponding fields of table tab_mara where mtart = mat_type.
if tab_mara[] is initial.
raise e01.
endif.
regards
shiba dutta
‎2007 Jul 24 4:42 AM
Ya you can do that ... immediately after calling the FM ...do this way
CALL FUNCTION 'Z_FM_TEST1'
EXPORTING
MAT_TYPE = MAT_TYPE
TABLES
TAB_MARA = MARATABLE
EXCEPTIONS
E01 = 1
OTHERS = 2
.
IF SY-SUBRC = 1.
<b>MESSAGE e001 with 'E01 Exception raised'.</b> " 001 has to be 3 character length
ENDIF.
‎2007 Jul 24 5:02 AM
Hi,
define an exception and short text to it.
then after the select query fire the exception.
see the sample code..
function z73390_fdivide.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(NUMBER1) TYPE I DEFAULT 0
*" REFERENCE(NUMBER2) TYPE I DEFAULT 0
*" EXPORTING
*" REFERENCE(ANS) TYPE P
*" EXCEPTIONS
*" ZERODIVIDEERROR
*"----
if number2 eq 0.
message e000(zgem) with 'Divide by Zero' raising zerodivideerror.
endif.
ans = number1 / number2.
Regards,
Niyaz
endfunction.
‎2007 Jul 24 5:46 AM
hi sachin
if sy-subrc = 1.
message e001 (message class) raising <EXCEPTION NAME>.
endif
regards
ravish
plz reward if useful