ERPClimb logoERPClimb
Enhancements
ABAP Developmentadvanced 7 min read

Enhancements Part 9: Performance and Safety in Enhancements

Preview · a free account unlocks the full lesson

Key takeaway

Write enhancement code that never harms the standard process: no COMMIT/ROLLBACK, no dialogs in background, correct messages, buffered reads instead of SELECTs per item, guard conditions, exception handling, and how to test and monitor enhancements (ST05, SAT, ST22).

In this lessonShow sections

Visual overview

Enhancements Part 9: Performance and Safety in Enhancements — learning sheetFlow: Review an existing item-level exit: count SELECTs with ST05 on a 100-item order → Introduce a keyed buffer as in the code example and re-measure → Search your enhancements for COMMIT WORK (SE80 code scanner / CODE_SCANNER). Key ideas: TRANSACTION CONSISTENCY; MESSAGES AND DIALOGS; PERFORMANCE; ROBUSTNESS. Watch out: One SELECT in an item-level exit can become 500,000 SELECTs in a mass run — buffer.ERPClimb.com / ABAP / LESSON 9/10 / LEARNING SHEETEnhancements Part 9: Performance and Safety inEnhancements1 · HOW IT FLOWS1Review an existingitem-level exit: countSELECTs with ST05 on a…2Introduce a keyed bufferas in the code exampleand re-measure3Search your enhancementsfor COMMIT WORK (SE80code scanner /…2 · KEY IDEAS EXPLAINEDTransaction ConsistencySAP saves the document at the end of its own LUW.A COMMIT in your code writes half-finished data orbreaks the update.Don't call BAPIs that commit, CALL TRANSACTION, orSUBMIT AND RETURN with commits inside save exits.Messages And DialogsError messages (type E) belong in validation exits(e.g. USEREXIT_SAVE_DOCUMENT_PREPARE, check BAdImethods). In other exits they can terminate…No POPUP_TO_CONFIRM, no screens when sy-batch ='X' or in update task.PerformanceAvoid SELECT inside item loops; read once perdocument (or buffer in a static/class attributekeyed by document).Use SELECT SINGLE with full key or bufferedtables; check with ST05 and SAT.RobustnessCatch exceptions from your classes; a dump in anexit stops the whole transaction (ST22).Don't rely on SAP global variables that are notdocumented for that exit.3 · REMEMBER · WATCH OUTRememberEnhancement code runs inside SAP's LUW: never COMMIT WORK, ROLLBACKWORK or CALL TRANSACTION that commits.Code in exits and BAdIs may run per item, per document and inbackground — design for volume.Messages must fit the context: type E at the right place (checkexits), no popups in background or update task.!Watch outOne SELECT in an item-level exit canbecome 500,000 SELECTs in a mass run— buffer.4 · IN A REAL PROJECTA billing exit read the customer master (KNVV) and a Z pricing table for every item. Monthly billing of400,000 items took 9 hours instead of 2, and the job overlapped with the morning shift. ST05 showed 800,000identical SELECTs. The team added a guard condition for the relevant billing types and a keyed buffer class…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 1 through 8 of this series were about choosing and implementing enhancements; this lesson makes sure they don't break or slow down standard processes once they're in place.

Transaction consistency comes first: SAP saves the document at the end of its own logical unit of work (LUW), and a COMMIT issued from your own code can write half-finished data or break that update entirely. Never call a BAPI that commits, CALL TRANSACTION, or SUBMIT AND RETURN with commits from inside a save exit. For any additional database changes of your own, use update function modules called IN UPDATE TASK, or PERFORM … ON COMMIT, so they get saved together with SAP's own commit.

On messages and dialogs: error messages of type E belong in validation exits, such as USEREXIT_SAVE_DOCUMENT_PREPARE or a checking BAdI method — used anywhere else, they can terminate processing unexpectedly. Never use POPUP_TO_CONFIRM or show screens when sy-batch = 'X' or inside an update task, since in BAPIs and IDocs there's no user present at all, so messages must be returned rather than displayed.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.