Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error handling in Update function modules

Former Member
0 Kudos

Hi,

Can any one please let me know how to handle errors in the update function modules.I have searched in SDN but unable to find suitable answer.

I am getting an SAP Mail saying that update did not happen. I want to display error messages in the output list. I used the RAISE statement but the exception handling is not happening.

Regard

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Unfortunately, this type of error cannot be handled in the calling routine. They occur after the update has been passed to V1 or V2.

You have to use SM13 or SM14 to examine the problem.

Rob

4 REPLIES 4

Former Member
0 Kudos
function ztest1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(EMPNO) TYPE  P0001-PERNR
*"  EXCEPTIONS
*"      NO_DATA
*"----------------------------------------------------------------------
  tables : pa0001.
  select single * from pa0001 where pernr = empno.
  if sy-subrc = 4.
    raise no_data.
  endif.


endfunction.

Exceptions in FM:

NO_DATA No data for selection

Calling this FM in report

PARAMETERS : pernr TYPE p0001-pernr.
CALL FUNCTION 'ZTEST1'
  EXPORTING
    EMPNO         = pernr
 EXCEPTIONS
   NO_DATA       = 1
   OTHERS        = 2
          .
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

0 Kudos

Hi Shaik,

Thanks for the coding,

Kindly note the below points

1) I am using a update function

2) I already used a Raise statment

3) I am having error in a SAP mail,which is not sufficient

I want to capture the errors like in normal function and display in a report output

Regrads

Former Member
0 Kudos

Hi, this is normal behavior when an exception is raised in an update module, see ABAP keyword documentation:

CALL FUNCTION - IN UPDATE TASK

Notes

- If during the update an error occurs, the update work process executes a database rollback ... and informs the user whose program has created the log record by SAPMail. After removing the error cause, the returned log records can be updated again.

If you want to handle the exception in the calling program, perform a general function call (without using update task). Like this you can handle the exception and display errors in the output list of the calling program.

Regards, Martin

Former Member
0 Kudos

Unfortunately, this type of error cannot be handled in the calling routine. They occur after the update has been passed to V1 or V2.

You have to use SM13 or SM14 to examine the problem.

Rob