Skip to content

DevTip: Resume exceptions in ABAP code module to continue execution even after an error has occurred.

In case you’ve missed our dev tips in past weeks, we will be posting them in the blog moving forward. To sign up and get your dev tips delivered to your inbox each week, click here!

Tip of the Week

Resume exceptions in ABAP code module to continue execution even after an error has occurred.

Sometimes when an exception is raised, we would want to continue with the processing after appropriate exception handling no matter where in the program stack the exception is handled. I like to call it a “Warning Exception” because just like a warning message popup, it allows you to continue with the program processing. Here, however, it allows you to handle the exception appropriately before resuming.

To do this we need to follow Class-based Exception Handling paradigm. When we define the exception handlers in a method, we need to define them as ‘RESUMABLE.’ Here are the steps:

Create an exception class
1. I created class ZCX_SS_DEMO_EXCEPTION

2. Create a message class in SE91 with a dummy message and assign it to a message text in the class.
3. Go to SE38 and create a program with the following code. I have added 2 methods here. METHOD_LEVEL2 will raise the exception, and also continue to execute after resuming. METHOD_LEVEL1 is only passing the exception through just to demonstrate that the exceptions can be handled anywhere to get resume. And the EXCEPTION_CATCHER method will handle and issue the ‘resume.’4. Here is the code snippet: the flow of control has been numbered in the comments.
5. Output

 

If you have an interest in viewing similar content, visit our blog, here

View our LinkedIn, here

Shinjan has been in the SAP space for over 10 years. He has worked on all areas of SAP ABAP for various clients in Europe and in the US. He considers himself to be a fast learner who puts enormous importance towards looking at the bigger picture while simultaneously being details oriented. Coming from a computer science background, he has always been a technology enthusiast dabbling in various programming languages along with pushing the limits of SAP ABAP. Before joining Mindset Consulting, he was the solution architect for Microsoft’s Business Process Monitoring engagement. Now as a development lead at Mindset, he has been heading challenging projects and is focused on delivering solutions that reach beyond the expectations of the clients.

Back To Top