cancel
Showing results for 
Search instead for 
Did you mean: 

Exception Handling in webdynpro abap

Former Member
0 Kudos

Hi

I have a function call which raises an exception. How do i handle it?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I have a funtion module 'ZTRAC_CHKD_GET_QVIEWDATA'.

CALL FUNCTION 'ZTRAC_CHKD_GET_QVIEWDATA'

EXPORTING

IM_SEARCH_DET = ls_chkd_det

IMPORTING

EX_STR_QVIEW_DET = ls_query_view_det

In the function module, an exception is raised. How do i handle it at the call?

How will the try catch block be to catch the exception raised in the function module?

Former Member
0 Kudos

hi,

Have you raised the exception in the function module and also declared the same in Exception Tab of function module.

Just raise the exception inside FM only and handle using sy-subrc in WD ABAP.

After calling your FM , just check :

if sy-subrc NE 0.

<Raise Message for Exception >

endif.

Edited by: Saurav Mago on Oct 16, 2009 10:54 AM

Former Member
0 Kudos

please tell me how to display the captured exception in UI.

Former Member
0 Kudos

hi,

Once you have captured the exception, you can raise an Error message in UI :

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager

.

  • report message

CALL METHOD lo_message_manager->report_error_message

EXPORTING

message_text = ' Exception raised' .

There are different kind of messages which can be raised . Just click on Code Wizard ( control + F7 ) , Generate message -> Select the messge type - Error, Success, Exception.

Former Member
0 Kudos

hi,

In WD4A, Exception handling in FM is same as We do in R/3. You can check sy-subrc after calling the function module.

Also you can raise error message by using web dynpro code wizard(control + F7 ) button:

Select Generate message radio button. You will find number of methods in F4. You can use them as per your requirement

Example :

Suppose you call a FM like this in WD ABAP :

CALL FUNCTION 'F4UT_RESULTS_MAP'

TABLES

shlp_tab = t_shlp_tab

record_tab = t_record

source_tab = t_HCP

CHANGING

shlp = p_shlp_descr

callcontrol = icallcontrol

EXCEPTIONS

illegal_structure = 1

OTHERS = 2.

Now after this FM, check the sy-subrc value Like this:

if sy-subrc = 1.

<Report message for exception 1>.

elseif sy-subrc = 2.

<Report message for exception 2>

endif.

Edited by: Saurav Mago on Oct 16, 2009 10:22 AM