ABAP: To dump or not to dump?

In the world of SAP, runtime errors (also called short-dumps, or simply dumps) are typically viewed as a source of dread and something you should avoid altogether.

The prevailing wisdom is clear:

Catch every exception, log it quietly, and keep the system running without alarming users or halting processes. After all, who wants a production system grinding to a halt over an unhandled issue? But what if this zero-tolerance policy toward dumps is a little too overzealous? What if, in certain scenarios, letting a dump occur isn’t just acceptable but preferable?

In this short article, we’ll explore the nuanced role of dumps in ABAP development, challenging their notoriously bad reputation and shining a light on their often overlooked usefulness and explain why dumps aren’t always the villains they’re made out to be, but actually sometimes they’re the heroes forcing us to confront critical problems as they occur.

Understanding ABAP Short Dumps: The Basics

To appreciate the debate, let’s start with what a short dump actually is. In ABAP, a short dump is essentially a detailed report generated when a runtime error occurs, such as an uncaught exception, an exit message, or a failed assertion.

These runtime errors interrupt the program’s execution and provide a snapshot of the system’s state at the moment of failure. This includes:

  • Error type and message
  • Source code context
  • Call stack
  • Variable values at the moment of failure
  • User and session information
  • System context
  • Hints for resolution

In short, a forensic toolkit for debugging.

A primary trigger for such dumps are unhandled exceptions. ABAP offers robust tools like TRY…CATCH blocks to handle exceptions gracefully, allowing developers to log errors, recover where possible, and continue processing.

So, why not always catch and log? As we will see shortly, the answer lies in the context of the error and the value of the information a dump provides.

Why Dumps Have a Bad Reputation

It’s easy to understand why dumps are so disliked:

  1. User Impact – A dump interrupts a business user’s process with an abrupt error screen. To the end-user, it’s disruptive, confusing, and often frustrating.
  2. Support Pressure – Dumps are visible in ST22 and usually end up as tickets for the support team. This adds to the operational load and makes it look like the system is unstable.
  3. Bad Coding Practices – Frequent or poorly handled dumps can be a symptom of sloppy development, where edge cases aren’t accounted for and error handling was an afterthought.

It’s no secret that short dumps carry a stigma in the SAP world. In a culture that values seamless user experiences, dumps are seen as unprofessional.

As one SAP expert on LinkedIn put it, encountering a dump often prompts reactions like, „Who developed this?“—implying incompetence rather than deliberate choice. This knee-jerk negative response overlooks the dump’s strengths, painting it as an outright enemy rather than a tool with situational utility.

The Case For Dumps

Yet, dumps are not inherently bad. In fact, they can be highly useful in certain contexts:

  • Maximum Transparency – A dump provides a full context: the exact source code line, the variable values at the time, and a structured call stack. It’s far richer in detail than a simple log entry, which may or may not contain enough clues for debugging.
  • Forcing Attention – A log can be ignored. A dump cannot. If a critical piece of logic fails — say, the calculation of pricing, or the assignment of a delivery to a transportation unit — it might actually be better for the system to stop dead in its tracks. That way, the issue is surfaced immediately and with full information, rather than silently creating corrupted or incomplete data.
  • Better Than a Silent Failure – Consider the alternative: catching every exception and writing to a log. If no one ever checks that log, the system could keep producing faulty data while the underlying issue goes unnoticed for weeks. A dump, by contrast, guarantees visibility.

Dumps aren’t just errors, they’re information goldmines. Unlike a logged exception, which might be buried in a sea of log files and overlooked during routine monitoring, a dump demands attention. It halts execution of the affected runtime process (not the entire system), alerting users that something has gone fundamentally wrong.

When to Dump, When not to Dump

The art lies in knowing when a dump is acceptable and when it’s not. Here are some guidelines:

  • Dump if the failure makes the process result invalid or dangerous to continue. (e.g., missing essential configuration, corrupted master data, or critical calculation failure).
  • Log if the error is recoverable, non-essential, or something that the business can still proceed with, perhaps with a warning (e.g., missing optional fields, unrecognized input values that can be skipped).
  • Both, if necessary — log details for long-term analysis, but still dump when business-critical integrity is at stake.

This isn’t a call to abandon exception handling. For recoverable errors, like network timeouts or user input issues, TRY…CATCH with logging is ideal, as demonstrated in examples where it prevents unnecessary dumps.

The key is discernment: use dumps strategically for unrecoverable, high-impact failures where the cost of interruption is outweighed by the risk of proceeding.

Conclusion

The blanket statement that “all dumps are bad and should be avoided” misses the purpose and power of dumps. 

They are disruptive, yes, but they are also one of the most informative and unambiguous signals a system can give. They enforce accountability on the development side by surfacing issues that must be fixed rather than swept under the rug.

As with most tools, the key lies in balance. Overusing dumps for trivial issues is careless; eliminating them entirely in favor of silent logs is just as risky. Sometimes you need a loud crash to fix what’s broken – and that’s what dumps are good for.

The smartest ABAP developers know when a dump is a safeguard and not a failure and strategically implement them for this purpose.

ABAP: Pass by Value vs. Pass by Reference

In modern ABAP Object Oriented Programming, we define method parameters using the IMPORTING, EXPORTING keywords, each of which can use pass by value or pass by reference, as well as the RETURNING keyword, which always uses pass by value, and the CHANGING keyword, which always uses pass by reference.

Let’s understand the difference between them.

1. Pass by Value

When a parameter is passed by value, a copy of the data is made.

This means any changes inside the method do not affect the original variable outside the method. In methods we explicitly define pass by value using the VALUE keyword.

Example 1) of Pass by Value

Explanation:

  • The VALUE keyword ensures iv_number is passed by value, thus a copy of the data is created inside the method.
  • Any modifications to the copied data within change_value do not affect lv_number outside the method.
  • Note: The IMPORTING parameter was able to be „changed“ due to VALUE( ) without needing to define it as a CHANGING parameter.

That’s great, but what if instead of:

We have:

We have IMPORTING VALUE(), which is implicitly pass-by-value, so it creates a copy of the data, but now we don’t have TYPE i but TYPE REF TO i as our type.

Let’s take a look.

Example 2) of Pass by Value

Explanation

  • lv_number is an integer and lo_number is a reference that points to its memory location.
  • The method is pass-by-value and expects a reference, so the reference (memory address) is copied.
  • When the dereferenced value behind that address is changed inside the method, the change persists outside the method even on the original lv_number since it shares the same address.
  • Note: lv_number->* ue be can be modified, despite lv_number being desfined as an IMPORTING parameter

Next, let’s check out pass-by-reference in methods.

2. Pass by Reference

When a parameter is passed by reference, no copy of the data is created.

Instead, the method copies the memory address of the data as a reference and operates directly on the original variable, meaning any changes made inside the method will reflect outside the method, as the original data was changed via this reference.

Example 1) of Pass by Reference

Explanation:

  • lv_number is passed by reference to the method, thus the method acts directly on the data behind the reference.
  • The changes to cv_number reflect outside the method on lv_number.
  • Note: cv_number must be made a CHANGING parameter, because IMPORTING parameters cannot be changed by reference.

Example 2) of Pass by Reference

Explanation:

  • lv_number is an integer and lo_number is a reference that points to its memory location.
  • The method is pass-by-reference and expects a reference, so a reference to a reference is acted upon.
  • When the dereferenced value behind that reference is changed inside the method, the change persists outside the method even on the original lv_number as it was passed by reference

3. Field-Symbols

We’ve pretty much covered pass-by-value and pass-by-reference in the context of methods and their parameters, and we’ve also talked about variables and ref variables.

I know some readers are going to be wondering: “What about Field-Symbols?”

So let’s briefly discuss them as well and you’ll find more details in the performance comparisons below.

What are field-symbols?

Field-symbols are pass-by-reference. Their syntax differs a bit from references, but basically they’re pointers in ABAP, allowing dynamic access to memory locations without copying data or needing to be dereferenced.

While field-symbols offer a slight performance advantage due to not needing to be dereferenced, which is a negligible performance cost, they are becoming obsolete and are not recommended by SAP.

Hence, why I only want to mention them briefly.

4. Compare & Contrast

Pass-by-value vs. Pass-by-reference:

AspectPass-by-valuePass-by-reference
ConceptThe method receivs a copy of the variables’s valueThe method receives a pointer (reference) to the original variable
Memory UsageHigher (creates a copy)Lower (uses original memory)
PerformanceSlower for large dataFaster, especially for tables
ScopeChanges only affect the copy within the methodChanges affect the original variable directly
UsageCommon for small data types or when memory is no concernCommon for large structures, itabs and objects
Data IntegritySafer (no unintended modifications)Risk of unintended modifications
ModificationsNo impact on the original dataModifies the original data directl.y
FlexibilitySafer, as the original data remains unchangedMore flexible, but requires careful handling
SyntaxIMPORTING VALUE( )
TYPE
IMPORTING
TYPE REF TO

Field-Symbols vs. References:

AspectField-Symbols (< >)References (REF #( ))
ConceptActs like a pointer, referencing existing memory directlyCreates a reference object pointing to data
Memory UsageNo new memory allocationRequires memory for the reference itself
PerformanceVery fast (direct access)Slightly slower due to dereferencing
ScopeOnly valid within the block where assignedPersistent across method calls
UsageGood for internal table processing, loops, dynamic accessUseful for object-oriented design, method parameters
ModificationsChanges the original data directlyChanges data via the reference
FlexibilityMore flexible for direct memory operationsBetter for passing objects and structured data
DereferencingImplicit (no extra step needed)Explicit (lo_ref->*)

*Dereferencing is very fast, operating at memory access speed. The performance cost is negligible compared to large data copies or database accesses.

5. Overview of Behaviour

  1. In ABAP OOP, using VALUE() or not in your IMPORTING and EXPORTING parameters determines whether the method implicitly behaves as pass-by-value or pass-by-reference.
  2. A reference to an object is the memory address of an object via which the object can be accessed (dereferenced, ->*) and acted upon. Passing only memory addresses requires less computation than copying the entire datasets around.
  3. Pass-by-value methods create a copy of the object, even when the object itself is a reference. Thus the original object stays unchanged outside the method.
  4. Pass-by-reference methods access the memory address of the original object and may act upon its data by dereferencing. The original object doesn’t stay unchanged outside the method. This can sometimes lead to unexpected behavior, when appending to EXPORTING tables in separate method calls throughout a program, where one would expect the parameter to be cleared automatically with each call, but isn’t. Manual clearing of EXPORTING parameters for tables, is often wanted, when appending to pass-by-reference parameters.
  5. CHANGING is always pass-by-reference and RETURNING is always pass-by-value. IMPORTING and EXPORTING can be either.

Conclusion

Modern ABAP OOP syntax allows clear control over pass by reference vs. pass by value, influencing performance and data integrity. By understanding these principles, developers can write more efficient and maintainable code in ABAP.

Let’s Keep the Conversation Going!

Do you have questions or your own experiences on this topic? Feel free to reach out to Jonathan Rumpl on LinkedIn!

Stay up to date! Sign up for our Cadaxo newsletter and receive regular insights, best practices, and news from the SAP world.

 

ABAPConf Learnings – Teil #2

Willkommen zurück zu weiteren Learnings der ABAPConf 2024! In diesem Beitrag präsentieren wir eine Zusammenfassung eines besonders wertvollen Beitrags aus der letzten Konferenz. Hier erfahrt ihr die wichtigsten Inhalte, Tipps und Tricks, die für euch von Interesse sein könnten. Wie immer findet ihr am Ende des Blogbeitrags alle relevanten Links zu weiteren Ressourcen.

Diesmal werfen wir einen Blick auf …

ABAP Tools für Clean Code

Am letzten Tag der 3tägigen CodeConnect-Veranstaltung war der Vortrag „ABAP Tools for Clean ABAP“ von Björn Jüliger und Jörg-Michael Grassau. Diesen wollen wir kurz im Folgenden Revue passieren lassen.

Warum Clean ABAP?

Zeit in Clean ABAP Code ist gut investiert, denn:

  • Code wird lesbarer, testbarer und wartbarer.
  • Wir verbringen mehr Zeit damit unseren Code zu lesen, als ihn zu schreiben.
  • ABAP gibt es schon sehr lange mit großer Rückwärtskompatibilität, weshalb man oft auch in der Zukunft nochmal damit konfrontiert ist.

Um Clean Code noch erfolgreicher umzusetzen, gibt es ein paar hilfreiche Tools, die wir gerne näher beleuchten.

Code Pal

Code Pal ist ein Clean Code Unterstützungstool und kann innerhalb des ABAP Test Cockpits (ATC) eingeschaltet werden.

Es bietet Kontrolle über einige Checks für die Umsetzung von Clean ABAP:

Dabei ist zu beachten:

  1. Code Pal steht als Open Source Projekt via Github zur Verfügung und wird vom ATC Team betreut (Links am Ende des Artikels)
  2. Integriert werden kann ATC in den ABAP development tools (ADT) von Eclipse

ABAP Cleaner

ABAP Cleaner ist ein konfigurierbares Open-Source Tool mit dem Ziel alles, was in Zusammenhang mit ABAP Code Styling automatisiert werden kann, zu automatisieren.

Sprich: Ein konfigurierbarer Pretty Printer!

Vor allem, wenn man im Team arbeitet, kann so ein Tool sehr nützlich sein, um ein gewolltes Styling schnell zu implementieren.

Der ABAP Cleaner ist auch wieder im ADT verfügbar. (Links unten.)

Danke für’s Lesen!

Du möchtest keine weiteren ABAP Tipps und Tricks verpassen?

Dann folge uns jetzt auf LinkedIn oder abonniere unseren Newsletter, um stets über die neuesten Entwicklungen in ABAP informiert zu bleiben und keine Neuigkeiten zur ABAPConf am 5. Dezember 2024 zu verpassen.

Nähere Ausführungen zum Thema Clean ABAP entnehmen Sie bitte dem PDF oder der offiziellen Website der ABAPConf.

Zum LinkedIn-Beitrag der ABAPConf South Africa am 13. November 2024 geht es hier.

Dieser Artikel wurde verfasst von: Jonathan Rumpl, SAP Consultant der Cadaxo GmbH.

Ressourcen

Code Pal

Code pal (Classic)

  • Available for on-premise: AS ABAP 7.40 SP08 (++), not remote-enabled 

NEW: Code pal (Cloud Edition)

ABAP Cleaner

Open Source repository

Updatesite for Eclipse plug-in

Demo

Webinar

Blog post

ABAPConf Learnings – Teil #1

Unsere nächste ABAPConf findet noch dieses Jahr statt – und zwar am 5. Dezember 2024!

Zu unserer Freude hält nun Südafrika am 13. November 2024 auch eine eigene ABAPConf 2024 South Africa ab, und das unterstützen wir natürlich! Link dazu am Ende dieses Beitrags.

Wieder erwarten uns viele spannende Themen sowie hilfreiche Tipps und Tricks rundum ABAP.

Um die Wartezeit etwas zu verkürzen und einen Vorgeschmack für jene anzubieten, die die letzte ABAPConf verpasst haben oder nicht alle Vorträge gesehen haben, gibt es hier eine kurze Zusammenfassung eines sehr relevanten Beitrags:

Neues für ABAP CDS im ABAP Cloud Development Model

Dieser Vortrag wurde live von SAP-internen Mitarbeitern gehalten.

Wie der Titel bereits verrät, geht es um die Weiterführung der ABAP Core Data Services im ABAP Cloud Development Model, welches immer zentraler wird.

Deshalb gibt es nun einen kurzen Ein- und Ausblick, welche neuen Anwendungen und Technologien da auf uns zukommen.

3 neue CDS Entity Types

Diese drei sind

  1. CDS Simple Type
  2. CDS Enumerated Type
  3. CDS Scalar Function

und erweitern somit den Katalog:

Sehen wir sie uns näher an, beginnend mit dem

CDS Simple Type

Dieser Typ erlaubt das Definieren von elementaren Datentypen, die anstelle von DDIC Elementen in ABAP CDS verwendet werden können.

Angelegt werden kann so ein Simple Type folgendermaßen:

Anstelle des built-in data types abap.char( 30 ) könnte auch ein weiterer solcher Simple Type oder auch ein Data Element verwendet werden. Die Annotation versorgt den Datentypen mit Metadaten, die man herkömmlicherweise bei DDIC Elementen in der SE11 pflegen würde.

Dieser neue User-definierte Datentyp kann ganz einfach wie gewohnt in CDS View Entities oder in ABAP-Coding zur Typisierung von Variablen genutzt werden.

CDS Enumerated Type

Dieser Typ entspricht den aus vielen Programmiersprachen bekannten Enum Datentyp, und bildet somit ein definierte Menge an Werten. Objekte dieses Datentyps können somit nur Werte, die in diesem Enumerated Type definiert sind, annehmen.

Hier ein kurzer Ausschnitt wie der Enumerated Type definiert wird:

CDS Scalar Functions

Der Begriff Skalar kommt aus dem Teilbereich der linearen Algebra der Mathematik und bezeichnet einen dimensionslose Zahl, die üblicherweise auf Vektoren oder Matrizen angewendet wird, um diese entweder zu verkleinern oder vergrößern, sprich skalieren.

Skalarfunktionen im Kontext von SQL sind Funktionen, die einen oder mehrere Parameter entgegennehmen, und einen einzelnen Wert (= Skalar) zurückgeben.

Ein typisches Beispiel hierfür ist die AVG( )-Funktion, die den Mittelwert einer Menge von Werten zurückliefert.

Die User-definierten Skalarfunktionen sind mit AMDP (= ABAP Managed Database Procedures) verknüpft und werden mittels SQLScript implementiert.

Hier ein Beispiel um Zollgebühren zu berechnen:

Fazit

Mit diesen Erweiterungen kann jetzt noch flüssiger programmiert werden und Kundenanforderungen lassen sich noch präziser und maßgeschneiderter umsetzen, ohne erhöhten Aufwand oder an Performance zu verlieren und der Code wird noch stabiler.

Top.

Du möchtest keine weiteren ABAP Tipps und Tricks verpassen?

Dann folge uns jetzt auf LinkedIn und wir halten dich am Laufenden über die neuesten Möglichkeiten in ABAP sowie die nächste ABAPConf am 5. Dezember 2024.

Weitere Ausführungen zu dem Thema der CDS Views in ABAP Cloud entnehmen Sie bitte dem PDF oder der offiziellen Website der ABAPConf.

Zum LinkedIn-Beitrag der ABAPConf South Africa am 13. November 2024 geht es hier.