User Exits Part 3: Finding User Exits in Real Transactions
Find the right user exit for a requirement: identify the main program, search for PERFORM USEREXIT and CALL CUSTOMER-FUNCTION, use SPRO "System modifications" documentation, debug with breakpoints on the exit FORMs, and verify timing and data in all processing paths.
Explanation
📌 KEY POINTS
✅ Start with the main program (System → Status) and search it for PERFORM userexit and CALL CUSTOMER-FUNCTION.
✅ SPRO → Sales and Distribution → System Modifications → User Exits documents the SD exits and their purpose.
✅ Debug the business step with breakpoints in candidate FORMs to confirm timing and available data.
⚠️ An exit that runs in VA01 may run differently (or not at all) for BAPI-created orders, copies or mass changes — check all paths.
━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE
Part 2 compared techniques. Now we find a concrete exit for a requirement.
━━━━━━━━━━━━━━━━━━━━
▶ 1. IDENTIFY THE PROGRAM
- System → Status → Program (screen) → e.g. SAPMV45A for VA01/VA02/VA03, SAPMV50A for VL01N/VL02N, SAPLV60A for VF01/VF04.
- Know the process step: entering fields, item creation, pricing, saving, output.
━━━━━━━━━━━━━━━━━━━━
▶ 2. SEARCH STATICALLY
- SE38 → program → Find (Ctrl+F) with "in main program and includes": PERFORM USEREXIT_ → list of FORM calls with their location.
- CALL CUSTOMER-FUNCTION → customer exits (SMOD for the component).
- SE80 → program → includes MV45AFZZ, MV45AFZB, … read the documentation comments.
━━━━━━━━━━━━━━━━━━━━
▶ 3. SPRO DOCUMENTATION
SPRO → Sales and Distribution → System Modifications → User Exits → "User exits in sales", "User exits for delivery processing", "User exits for billing" — describes which FORM is called when.
━━━━━━━━━━━━━━━━━━━━
▶ 4. DEBUG TO CONFIRM
- Breakpoints in the candidate FORMs (in a test system, via SE38 of the include).
- Execute the step; note which FORMs stop and in which order.
- Inspect VBAK/XVBAP etc. Is the data you need filled at that moment? Is the field you want to set still used afterwards?
━━━━━━━━━━━━━━━━━━━━
▶ 5. CHECK ALL PATHS
- BAPI_SALESORDER_CREATEFROMDAT2 runs SAPMV45A logic in the background (exits run; no screens).
- Copying from quotations, mass change (MASS), IDoc ORDERS, Fiori apps.
- Display mode (T180-TRTYP = 'A').
━━━━━━━━━━━━━━━━━━━━
▶ 6. RECORD THE DECISION
Requirement → exit FORM → reason → test paths.
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- VA01: System → Status → note program SAPMV45A.
- Search PERFORM USEREXIT in SAPMV45A including includes; count the results.
- Set breakpoints in USEREXIT_MOVE_FIELD_TO_VBAP and USEREXIT_SAVE_DOCUMENT_PREPARE; create an order and note the call order.
✅ CHECKPOINT: you can locate and verify the right user exit for a requirement.
Code example
* ===== Helper report: list user-exit FORM calls in a program and its includes =====REPORT zlist_userexits. PARAMETERS p_prog TYPE progname DEFAULT 'SAPMV45A'. DATA: lt_includes TYPE STANDARD TABLE OF progname, lv_include TYPE progname, lt_source TYPE STANDARD TABLE OF string, lv_line TYPE string, lv_upper TYPE string, lv_tabix TYPE sy-tabix. START-OF-SELECTION.* All includes of the main program CALL FUNCTION 'RS_GET_ALL_INCLUDES' EXPORTING program = p_prog TABLES includetab = lt_includes EXCEPTIONS OTHERS = 1. APPEND p_prog TO lt_includes. LOOP AT lt_includes INTO lv_include. REFRESH lt_source. READ REPORT lv_include INTO lt_source. CHECK sy-subrc = 0. LOOP AT lt_source INTO lv_line. lv_tabix = sy-tabix. lv_upper = lv_line. TRANSLATE lv_upper TO UPPER CASE. IF lv_upper CS 'PERFORM USEREXIT' OR lv_upper CS 'CALL CUSTOMER-FUNCTION'. CONDENSE lv_line. WRITE: / lv_include, lv_tabix, lv_line. ENDIF. ENDLOOP. ENDLOOP. * ===== Typical sequence observed in VA01 (debugger) =====* USEREXIT_MOVE_FIELD_TO_VBAK header fields during entry* USEREXIT_MOVE_FIELD_TO_VBAP item fields during entry* USEREXIT_PRICING_PREPARE_TKOMK/TKOMP pricing communication* USEREXIT_SAVE_DOCUMENT_PREPARE before save: checks, final changes* USEREXIT_SAVE_DOCUMENT during save: e.g. own tables (update task)Real project scenario
A requirement asked to fill a custom item field when an order is created. The developer used USEREXIT_MOVE_FIELD_TO_VBAP, which worked in VA01. Orders created from an e-commerce interface via BAPI had the field empty.
Debugging the BAPI path showed the value was derived from a partner that the interface added later in the process. The team moved the derivation to USEREXIT_SAVE_DOCUMENT_PREPARE for items with the field still empty, covering both paths.
Common mistakes
- Choosing an exit only from internet lists without debugging.
- Testing only the dialog path.
- Ignoring display mode and copies.
- Setting a field in an exit after which SAP overwrites it.
- Searching only the main program, not its includes.
Best practices
- Start from the process step and main program.
- Use SPRO documentation and searches in includes.
- Confirm timing and data in the debugger.
- Test BAPI, IDoc, copy and mass-change paths.
- Record the decision and test cases.
Interview angle
Questions: "How do you find a user exit for VA01?", "Which exit do you use for validations at save?"
Strong answer: get main program via System → Status, search PERFORM USEREXIT/CALL CUSTOMER-FUNCTION in program and includes, SPRO System Modifications documentation, debug with breakpoints to verify timing/data; for save checks USEREXIT_SAVE_DOCUMENT_PREPARE; check BAPI/IDoc/copy paths.
Practice this lesson
Quick check
1. How do you find the main program of VA01 to search for user exits?
2. Where does SAP document the SD user exits and when they are called?
3. Before adding logic in a user exit, what should you confirm first?
Interview questions
1. User exit code is not being executed after transport. Why?
Answer it in your own words first, then compare.
2. A validation must run before the sales order is saved. How do you find and confirm the right user exit?
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.
More lessons in this topic
- User Exits Part 1: What SD User Exits Are and How They Work
- User Exits Part 2: User Exits vs Customer Exits vs BAdIs — When to Migrate
- User Exits Part 4: MV45AFZZ — Sales Order Exits and Save Logic
- User Exits Part 5: MV50AFZ1 — Delivery User Exit Patterns
- User Exits Part 6: RV60AFZZ — Billing User Exit Patterns
- User Exits Part 7: Safe Coding Rules Inside User Exits
- User Exits Part 8: Performance Risks in User Exits