cancel
Showing results for 
Search instead for 
Did you mean: 

Catch an Exception Code

Former Member
0 Kudos

Hi,

I am new to abap and webdynpro.

This is all i have done so far.

1.) Create a FM that creates a record in database table.

2.) Create a service call in webdynpro to that FM

3.) Added views and code to the webdynpro.

Now my webdyn pro works great and it creates a record in table.

But i have a problem here. there is now way to find out if a record is written into table or now.

Supose if i give a same record which exists in database it doesnt show any error.

I have added this exception in function module. But i dont know how to find out if an exception happens.

Please help me in this regard.

Thanks,

Bala.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bala,

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

Answers (1)

Answers (1)

pranav_nagpal2
Contributor
0 Kudos

Hi,

Check below code to catch exception

CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr           = lv_pernr
      infty           = lc_infotype
      BYPASS_BUFFER   = 'X'
    TABLES
      infty_tab       = itab8_info
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.
  IF sy-subrc EQ 1.

*  REPORT MESSAGE

    CALL METHOD
wd_comp_controller->gr_message_manager->report_t100_message
      EXPORTING
        msgid = lc_msgid
        msgno = lc_msgno_65
        msgty = lc_e.
  ELSEIF sy-subrc EQ 2.

*  REPORT MESSAGE
    CALL METHOD
wd_comp_controller->gr_message_manager->report_t100_message
      EXPORTING
        msgid = lc_msgid
        msgno = lc_msgno_88
        msgty = lc_e.


  ENDIF.

here sy-subrc is a variable which stores 0 only whn update is successful else it returns any other value....

regards

Pranav