on 10-21-2009 5:30 AM
Hi,
I have called a function module from a method. Inside the Function module, there is an exception raised. How do i handle this in the method?
I have done the following:
CALL FUNCTION Fun_mod
EXPORTING
IM_SEARCH_DET = ls_chkd_det
IMPORTING
EX_STR_QVIEW_DET = ls_query_view_det
EX_TAB_ERRORS = ls_errors
EXCEPTIONS ZCX_ZTRAC_ERROR = 1
.
if sy-subrc is not initial.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
It still dumps.
Hi Lekha/Saurav,
I did check the sy-subrc value and did the following but the dump still exists.
CALL FUNCTION 'ZTRAC_CHKD_GET_QVIEWDATA'
EXPORTING
IM_SEARCH_DET = ls_chkd_det
IMPORTING
EX_STR_QVIEW_DET = ls_query_view_det
EX_TAB_ERRORS = ls_errors
EXCEPTIONS ZCX_ZTRAC_ERROR = 1
.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
rasie the error(based on sy-subrc).
endif
.
do you have any entries under the EXCEPTIONS tab of that FM. If yes,
I have No_data exception under EXCEPTIONS table.
Ex:
if table is initial
raise no_data.
endif.
Regards,
Lekha.
Edited by: Lekha on Oct 21, 2009 2:45 PM
Hi Matt,
Find below the piece of code within the function module where the exception is raised.
if sy-subrc <> 0.
message e000(zcl_ztrac_message) with 'ztrac_kpi_qry'.
No Record found for the given condition in the table &1.
raise exception type zcx_ztrac_error
exporting textid = zcx_ztrac_error=>no_rec_found_in_tab.
l_str_errors-type = 'E'.
l_str_errors-id = 'zcl_ztrac_message'.
l_str_errors-number = '000'.
l_str_errors-message_v1 = 'ztrac_kpi_qry'.
append l_str_errors to ex_tab_errors.
No Record found for the given condition in table.
endif.
The function module imports a parameter called check id and exports two parameters - EX_TAB_ERRORS and EX_STR_QVIEW_DET
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi Matt,
>
> Find below the piece of code within the function module where the exception is raised.
>
> if sy-subrc <> 0.
>
> * message e000(zcl_ztrac_message) with 'ztrac_kpi_qry'.
> * No Record found for the given condition in the table &1.
>
> raise exception type zcx_ztrac_error
> exporting textid = zcx_ztrac_error=>no_rec_found_in_tab.
> l_str_errors-type = 'E'.
> l_str_errors-id = 'zcl_ztrac_message'.
> l_str_errors-number = '000'.
> l_str_errors-message_v1 = 'ztrac_kpi_qry'.
>
> append l_str_errors to ex_tab_errors.
> * No Record found for the given condition in table.
>
> endif.
>
>
> The function module imports a parameter called check id and exports two parameters - EX_TAB_ERRORS and EX_STR_QVIEW_DET
The exceptions at the end of the function module are for non-class based exceptions. When raised in the function module, they give sy-subrc value the value defined in the CALL FUNCTION.
The exception you've got is a class based exception. So you need to do:
DATA lx_ztrac_error TYPE REF TO zcx_ztrac_error.
TRY.
CALL FUNCTION...
CATCH zcx_ztrac_error INTO lx_ztrac_error.
" do stuff with lx_ztrac_error
" e.g.
MESSAGE lx_ztrac_error TYPE 'E'.
ENDTRY.
Should the exception be caught within the function module or do i have to put the call function module in a try catch block and catch the exception which is raised at the function module?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a function module exception - not an object type exception - so try...endtry is probably not approriate. You could catch the "uncaught exception" exceptio, I suppose, but probably that would be bad programming - you probably need to handle the exception.
Can you post the section of the dump which shows where the error occured, and also the signature of the function module being called (The block of comments at the top of the source code of the function module).
matt
hi,
Exception needs to be taken care inside the FM only and then raise the Exception explicitly in FM.
Ex :
Inside your FM , you have to something like this :
if sy-subrc <> 0.
RAISE PARAMETER_UNKNOWN.
endif.
Here : PARAMETER_UNKNOWN is an exception declared in Exception Tab of FM and it has been raised explicitly.
So, debug your program and catch the exception using sy-subrc ' s value and raise it explictly.
The dump analysis says uncaught exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ,
go to the transaction st22 , there u can find the analysis , why u r getting the short dump
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do i have to use a try catch block?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Sy-subrc = 4 and i tried debugging. Before it exits out of the function module itself, it dumps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
What is the value of sy-subrc ?
Try putting break point and de-bug this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.