Skip to content

Repository files navigation

Version

License Contributor Covenant REUSE Status

Error

General-purpose exception classes. Support for RAISE EXCEPTION statement (recommended and better debugging) and class methods (shorter code).

NO WARRANTIES, MIT License

Usage

Raise an exception with free-form text:

RAISE EXCEPTION TYPE /apmg/cx_error_text EXPORTING text = 'Not found'.

Raise an exception concerning another exception:

TRY.
    "... some code that raises an exception
  CATCH cx_root INTO DATA(error).
    RAISE EXCEPTION TYPE /apmg/cx_error_prev EXPORTING previous = error. 
ENDTRY.

Raise an exception with current system message (T100). This is useful, for example, after function calls that set a message.

RAISE EXCEPTION TYPE /apmg/cx_error_t100.

For convenience, you can use /apmg/cx_error=>null to avoid output of the message without the need to define a local variable:

MESSAGE e001(00) WITH 'error value' 'more text' INTO /apmg/cx_error=>null. 
RAISE EXCEPTION TYPE /apmg/cx_error_t100.

The exception can also be raised via class method:

" Free-form text
/apmg/cx_error=>raise( 'Not found' ).

" Based on other exception
/apmg/cx_error=>raise_with_text( error ).

/apmg/cx_error=>raise(
  text     = 'Overwrite error text'
  previous = error ).

" System message
/apmg/cx_error=>raise_t100( ).

Prerequisites

SAP Basis 7.50 or higher

Installation

Install error as a global module in your system using apm.

or

Specify the error module as a dependency in your project and import it to your namespace using apm.

Contributions

All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.

You can install the developer version of ABAP Error using abapGit either by creating a new online repository for https://github.com/abapPM/ABAP-Exceptions.

Recommended SAP package: /APMG/EXCEPTIONS

About

Made with ❤ in Canada

Copyright 2025 apm.to Inc. https://apm.to

Follow @marcf.be on Bluesky and @marcfbe or LinkedIn

About

General Purpose Exception Class

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Sponsor this project

Contributors

Languages