on 10-16-2009 5:42 AM
Hi
I have a function call which raises an exception. How do i handle it?
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
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.