Debugging in ABAP Cloud ist anders als in Classic ABAP. Dieser Guide zeigt dir die neuen Tools und Techniken.
🎯 Was ist anders in ABAP Cloud?
❌ Geht NICHT mehr
/hDebugger-Kommando- SAP GUI Debugger (SE38, SE80)
BREAK-POINTStatement- Dynpro-Debugging
- Direkter DB-Zugriff im Debugger
✅ Neue Tools
- ADT Debugger (Eclipse)
- ABAP Console (
cl_demo_output) - Feed Reader (Background Jobs)
- Application Log (BAL)
- SQL Trace (Performance)
1. ADT Debugger (Haupt-Tool)
Debugger starten
Methode 1: Breakpoint setzen
- In ADT: Doppelklick auf Zeilennummer → Breakpoint (blauer Punkt)
- Programm ausführen (F9 oder Preview)
- Debugger stoppt an Breakpoint
Methode 2: Run As → ABAP Application (Debug)
- Rechtsklick auf Klasse/Programm
Debug As→ABAP Application
Debugger-Layout
┌─────────────────────────────────┐│ Code (aktuell Zeile markiert) │├─────────────────────────────────┤│ Variables (Variablen-Werte) │├─────────────────────────────────┤│ Breakpoints (alle Breakpoints) │├─────────────────────────────────┤│ Call Stack (Aufruf-Historie) │└─────────────────────────────────┘Wichtigste Shortcuts
| Shortcut | Aktion |
|---|---|
F5 | Step Into (in Methode springen) |
F6 | Step Over (Zeile ausführen) |
F7 | Step Return (aus Methode zurück) |
F8 | Resume (bis nächster Breakpoint) |
Ctrl+Shift+B | Toggle Breakpoint |
Ctrl+Alt+B | Alle Breakpoints zeigen |
Variablen inspizieren
METHOD calculate. DATA(lv_a) = 5. DATA(lv_b) = 3. DATA(lv_result) = lv_a + lv_b. " Breakpoint hier
" Im Variables Tab: " lv_a = 5 " lv_b = 3 " lv_result = 8ENDMETHOD.Variablen ändern:
- Rechtsklick auf Variable →
Change Value - Neuen Wert eingeben
- Weiter debuggen mit geändertem Wert
Watchpoints
Stoppt, wenn Variable sich ändert:
- Rechtsklick auf Variable →
Toggle Watchpoint - Debugger stoppt bei jeder Änderung
Conditional Breakpoints
Nur stoppen wenn Bedingung erfüllt:
- Rechtsklick auf Breakpoint →
Breakpoint Properties - Condition:
lv_id = '12345' - Stoppt nur wenn
lv_iddiesen Wert hat
2. ABAP Console (Output während Entwicklung)
Statt WRITE oder Debug-Ausgaben:
METHOD process_data. " Einfache Ausgabe cl_demo_output=>display( 'Starting processing' ).
" Variable ausgeben cl_demo_output=>write( |Customer ID: { lv_customer_id }| ).
" Tabelle ausgeben cl_demo_output=>write( lt_customers ).
" Finale Ausgabe cl_demo_output=>display( ).ENDMETHOD.Output:
- Erscheint im Console Tab in ADT
- Nur in Entwicklung nutzen!
- In Produktion: Application Log verwenden
Vorteile:
- ✅ Schneller als Debugger
- ✅ Für komplexe Datenstrukturen
- ✅ Bleibt im Log (scrollen möglich)
3. Logging mit Application Log
Für produktiven Code:
METHOD process_order. TRY. " Log erstellen DATA(lo_log) = cl_bali_log=>create_with_header( header = cl_bali_header_setter=>create( object = 'ZORDERS' subobject = 'PROCESS' external_id = |Order { iv_order_id }| ) ).
" Info-Meldung lo_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_information text = |Processing order { iv_order_id }| ) ).
" Verarbeitung...
" Erfolgs-Meldung lo_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_status text = 'Order processed successfully' ) ).
" Log speichern cl_bali_log_db=>get_instance( )->save_log( log = lo_log ).
CATCH cx_bali_runtime INTO DATA(lx_error). " Error handling ENDTRY.ENDMETHOD.Log ansehen:
- Transaktion
SLG1(Classic) - Fiori App: “Application Logs”
Severity-Levels:
c_severity_error- Fehler (rot)c_severity_warning- Warnung (gelb)c_severity_information- Info (blau)c_severity_status- Status (grün)
4. SQL Trace (Performance-Debugging)
Problem: Langsame SELECT-Statements finden
SQL Trace aktivieren
In ADT:
Run→Run Configurations- Tab
Trace Requests SQL Traceaktivieren- Programm ausführen
Trace analysieren
SQL Console öffnet sich:
SELECT * FROM kna1 Duration: 1.2s ❌ LANGSAM! Rows: 1,000,000
SELECT name1 FROM kna1 WHERE kunnr = '12345' Duration: 0.001s ✅ Schnell Rows: 1Optimierung:
- ❌
SELECT *vermeiden - ❌
FOR ALL ENTRIESmit leerer Tabelle - ✅ Explizite Felder
- ✅ WHERE auf indexed Feldern
5. Feed Reader (Background Jobs)
Problem: Background Jobs debuggen
Setup
- Job starten (Fiori App / SM37)
- In ADT:
Window→Show View→Feed Reader - Feed-URL eintragen:
https://<system>/sap/bc/adt/runtime/traces/abaplogs
Output
Feed Reader zeigt:
- Console-Outputs
- Application Logs
- Laufzeit-Fehler
Live-Updates während Job läuft!
6. Debugging-Strategien ohne Debugger
Strategie 1: Unit Tests
Statt Debuggen: Test schreiben
METHOD test_calculate_discount. " Given DATA(lv_amount) = 1000.
" When DATA(lv_discount) = zcl_pricing=>calculate_discount( lv_amount ).
" Then cl_abap_unit_assert=>assert_equals( act = lv_discount exp = 100 msg = |Expected 100, got { lv_discount }| " Debug-Info! ).ENDMETHOD.Vorteil: Reproduzierbar, automatisiert
Strategie 2: Defensive Assertions
METHOD process_order. " Precondition prüfen ASSERT iv_order_id IS NOT INITIAL.
" Geschäftslogik DATA(lv_customer) = get_customer( iv_order_id ).
" Postcondition prüfen ASSERT lv_customer IS BOUND.ENDMETHOD.In Production: ASSERT wird ignoriert (nur in Debug-Modus aktiv)
Besser für Production: Exceptions
IF lv_customer IS NOT BOUND. RAISE EXCEPTION TYPE zcx_customer_not_found.ENDIF.Strategie 3: Logging-Framework
Eigenes Logging-Wrapper:
CLASS zcl_logger DEFINITION. PUBLIC SECTION. CLASS-METHODS log IMPORTING iv_level TYPE string DEFAULT 'INFO' iv_text TYPE string.ENDCLASS.
CLASS zcl_logger IMPLEMENTATION. METHOD log. " In Dev: Console IF sy-sysid = 'DEV'. cl_demo_output=>write( |[{ iv_level }] { iv_text }| ). ELSE. " In Prod: Application Log " ... BAL Code ... ENDIF. ENDMETHOD.ENDCLASS.
" Verwendungzcl_logger=>log( iv_level = 'DEBUG' iv_text = |Processing customer { lv_id }| ).7. Häufige Debug-Szenarien
Szenario 1: Exception im RAP
Problem: Validation schlägt fehl, aber warum?
METHOD validateIsbn. READ ENTITIES OF zi_book IN LOCAL MODE ENTITY Book FIELDS ( Isbn ) WITH CORRESPONDING #( keys ) RESULT DATA(lt_books).
LOOP AT lt_books INTO DATA(ls_book). " Debug-Output cl_demo_output=>write( |Checking ISBN: { ls_book-Isbn }| ).
IF strlen( ls_book-Isbn ) <> 13. cl_demo_output=>write( 'ISBN invalid - length mismatch' ).
APPEND VALUE #( ... ) TO reported-book. ENDIF. ENDLOOP.
cl_demo_output=>display( ).ENDMETHOD.Szenario 2: CDS View gibt falsche Daten
Strategie:
- SQL Console: CDS View direkt abfragen
- Data Preview: In ADT Rechtsklick auf View →
Open With→Data Preview - Quell-Tabellen prüfen: Sind Rohdaten korrekt?
Szenario 3: Performance-Problem
Vorgehen:
- SQL Trace aktivieren
- Langsame SELECTs identifizieren
- ABAP Console: Zeitstempel loggen
DATA(lv_start) = cl_abap_context_info=>get_system_time( ).
" Langsame OperationSELECT ... INTO TABLE lt_data.
DATA(lv_end) = cl_abap_context_info=>get_system_time( ).cl_demo_output=>write( |Duration: { lv_end - lv_start } µs| ).8. Debugging Best Practices
✅ DO
- Breakpoints sparsam setzen (nicht 50 Stück!)
- Conditional Breakpoints für große Datasets
- Unit Tests statt live debuggen
- Logging in produktivem Code
- SQL Trace für Performance
❌ DON’T
- Production Debuggen (nur als letztes Mittel!)
BREAK-POINTim Code lassen- Console-Output in Produktion
- Debugger als einziges Tool nutzen
9. Tools-Übersicht
| Tool | Use Case | Wo verfügbar? |
|---|---|---|
| ADT Debugger | Interaktives Debugging | ADT/Eclipse |
| ABAP Console | Schnelle Outputs | ADT (Dev only) |
| Application Log | Produkt-Logging | Alle Systeme |
| SQL Trace | Performance-Analyse | ADT |
| Feed Reader | Background Job Logs | ADT |
| Data Preview | CDS View Daten prüfen | ADT |
🎯 Zusammenfassung
ABAP Cloud Debugging Workflow:
1. Unit Tests schreiben ↓ (wenn Test fehlschlägt)2. ADT Debugger nutzen ↓ (Performance-Problem?)3. SQL Trace aktivieren ↓ (Produktion?)4. Application Log analysierenMindset-Shift:
- Classic ABAP: Debugger-First
- ABAP Cloud: Test-First, Logging, dann Debugger
Siehe auch:
Happy Debugging! 🐛