Difference Between Error and Exception

Difference between Error and Exception, and how do we handle them in which scenarios?

In any programming language there can be three kinds of errors.

1.  Syntax Errors

The mistakes done while writing statements.  For example, instead of "WRITE", if you type "WIRTE" it is a syntax error. 

Compiler can detect these types of errors.  You will not be able to run the program till these errors are rectified.

2.  Runtime Errors (Exceptions)

Runtime Errors are thrown when the situation occurs during execution of program where the system will not know how to deal with such situation.  For example, you have written a program that takes an excel file and reads the data and stores in the database.  You have done the program perfectly.  No syntax errors.  But while executing the program, if the user enters a filename that does not exist, the program will not know what to do next, at that time runtime error occurs.  Runtime error terminates the execution of the program abruptly. 

Runtime errors mostly occur due to incorrect user entries or improper usage of system resources by program.  These runtime errors can be avoided if we catch the exceptions.  You can handle every possible exception and throw user defined messages during the execution and avoid abrupt termination of the program.

3.  Logical Errors

Logical errors are obviously the mistake done in the logic by programmer.  For example, Value = Rate - Discount is the normal universal calculation.  By mistake if you have typed Value = Rate + Discount, it is neither syntax error nor runtime error.  Your program is successful but result is wrong.

This can be corrected only through thorough study of the program or worst case debugging.

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.