cancel
Showing results for 
Search instead for 
Did you mean: 

Exception Handling in Webdynpro Abap

0 Kudos

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.

Accepted Solutions (0)

Answers (8)

Answers (8)

0 Kudos

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.

Former Member
0 Kudos

Please debug your FM and raise the exception inside your FM.

If you dont handle the exception inside FM , it will continue giving dump.

Former Member
0 Kudos

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

0 Kudos

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

matt
Active Contributor
0 Kudos

>

> 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.

0 Kudos

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?

matt
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Check the sy-subrc for that FM and handle the exceptions.

Former Member
0 Kudos

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.

0 Kudos

The dump analysis says uncaught exception.

Former Member
0 Kudos

hi,

There is an exception which is raised in your FM . That exception is not caught there.

Thats why you are getting this dump.

Please de-bug your FM and catch the exception .

Former Member
0 Kudos

hi ,

go to the transaction st22 , there u can find the analysis , why u r getting the short dump

regards,

amit

0 Kudos

Do i have to use a try catch block?

Former Member
0 Kudos

I think the problem is with in your FM because as you said it gives dump before coming out of FM.

Go to SE37 and test your FM there whether it is working fine or not.

0 Kudos

Hi,

Sy-subrc = 4 and i tried debugging. Before it exits out of the function module itself, it dumps.

Former Member
0 Kudos

hi,

What is the value of sy-subrc ?

Try putting break point and de-bug this.