0% found this document useful (0 votes)
70 views24 pages

SAP SD User Exits With Real Project Examples

The document outlines frequently used user exits in SAP SD for various processes including sales document processing, delivery, billing, pricing, customer master, and more. It provides specific user exits, their use cases, and real production examples, highlighting the importance of these exits in customizing and enhancing SAP functionalities. Additionally, it contrasts user exits with BADIs, and includes common issues encountered with user exits along with their root causes and solutions.

Uploaded by

Izac Costa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views24 pages

SAP SD User Exits With Real Project Examples

The document outlines frequently used user exits in SAP SD for various processes including sales document processing, delivery, billing, pricing, customer master, and more. It provides specific user exits, their use cases, and real production examples, highlighting the importance of these exits in customizing and enhancing SAP functionalities. Additionally, it contrasts user exits with BADIs, and includes common issues encountered with user exits along with their root causes and solutions.

Uploaded by

Izac Costa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SAP SD Frequently Used User Exits

Sales Document Processing (VA01/VA02/VA03)

User Exit Use Case / Include Program

USEREXIT_MOVE_FIELD_TO_VBAK / VBAP Add custom fields to sales order header/item (Include:


MV45AFZZ)
USEREXIT_CHECK_VBAK / VBAP Validations when saving orders (Include: MV45AFZZ)

USEREXIT_SAVE_DOCUMENT / PREPARE Custom updates before/after save (Include: MV45AFZZ)

USEREXIT_PRICING_PREPARE_TKOMP Pass custom fields to pricing (Include: RV61AFZA)

USEREXIT_PRICING_CHECK Validate/influence condition records (Include: RV61AFZA)

USEREXIT_SALES_DOCUMENT General manipulations during order creation (Include:


MV45AFZZ)
Delivery Processing (VL01N/VL02N/VL03N)

User Exit Use Case / Include Program

USEREXIT_SAVE_DOCUMENT_PREPARE Extra validations during delivery creation (Include:


MV50AFZ1)
USEREXIT_MOVE_FIELD_TO_LIKP / LIPS Add Z-fields to delivery header/item (Include: MV50AFZ1)

EXIT_SAPLV50E_001 Change delivery header data

EXIT_SAPLV50E_002 Change delivery item data

EXIT_SAPLV50E_003 Delivery split determination

Billing Processing (VF01/VF02/VF03)

User Exit Use Case / Include Program

USEREXIT_MOVE_FIELD_TO_VBRK / VBRP Add custom fields to billing header/item (Include:


RV60AFZZ)
USEREXIT_NUMBER_RANGE Custom billing doc number range (Include: RV60AFZZ)

USEREXIT_FILL_VBRK_VBRP Populate custom fields into billing docs (Include:


RV60AFZZ)
EXIT_SAPLV60B_001 Change billing header data
EXIT_SAPLV60B_002 Change billing item data

EXIT_SAPLV60B_004 Custom split criteria for billing docs

Pricing & Conditions

User Exit Use Case / Include Program

USEREXIT_PRICING_PREPARE_TKOMP Populate new fields in pricing structures (Include:


RV61AFZA)
USEREXIT_PRICING_CHECK Validate condition determination (Include: RV61AFZA)

Customer Master (XD01/XD02/XD03)

User Exit Use Case / Include Program

EXIT_SAPMF02D_001 Checks at customer save

EXIT_SAPMF02D_002 Default values for customer fields

EXIT_SAPMF02D_003 Additional validations for customer master

Partner Determination

User Exit Use Case / Include Program

EXIT_SAPLV09A_001 Enhance customer partner determination

Availability Check (ATP)

User Exit Use Case / Include Program

EXIT_SAPLATPC_001 Influence ATP results

EXIT_SAPLATPC_002 Modify scope of check

Output Determination

User Exit Use Case / Include Program

EXIT_SAPLV61B_001 Enhance output determination

EXIT_SAPLV61B_002 Modify comm. structures for outputs

Cross Applications

User Exit Use Case / Include Program


USEREXIT_FIELD_MODIFICATION Dynamic screen field control

EXIT_SAPLV45H_001 Change incompletion log processing

EXIT_SAPMV45A_002 Additional order header checks

EXIT_SAPMV45A_003 Additional order item checks

Real Production Examples (Important for Interview)


Example 1 – Mandatory PO Number

User Exit:

MV45AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Logic:

• If PO number blank → Error

Example 2 – Block Order Based on Material

User Exit:

USEREXIT_CHECK_VBAP

Logic:

• If material type = ZBLOCK → Reject order

Example 3 – Auto Populate Sales Office

User Exit:

USEREXIT_MOVE_FIELD_TO_VBAK
Logic:

• Based on Customer → Sales Office auto fill

🔹 BADI vs User Exit (Interview Question)


User Exit BADI
Old technology New technology
Single implementation Multiple implementation
Modification-based Enhancement framework
MV45AFZZ type include SE18 / SE19

🔥 Top 30 SAP SD User Exits


1️. Sales Order – MV45AFZZ (Most
Important)
1. USEREXIT_MOVE_FIELD_TO_VBAK

Purpose: Populate Sales Order Header Fields

Real Example:

• Auto-fill Sales Office based on Customer Region.


• Default Incoterm automatically.

2. USEREXIT_MOVE_FIELD_TO_VBAP
User Exit BADI
Purpose: Populate Item Fields

Real Example:

• Default Storage Location based on Plant + Material


Type.

3. USEREXIT_SAVE_DOCUMENT_PREPARE
⭐⭐⭐⭐⭐

Purpose: Validation before saving order

Real Example:

• Block order if:


o Customer is blacklisted
o PO number missing
o Margin below 5%

4. USEREXIT_SAVE_DOCUMENT

Purpose: Logic after Save

Real Example:

• Trigger custom Z-table update.

5. USEREXIT_CHECK_VBAK

Purpose: Header Validation

Real Example:

• Block order if Credit Group missing.


User Exit BADI

6. USEREXIT_CHECK_VBAP

Purpose: Item Validation

Real Example:

• Block order if material discontinued.

7. USEREXIT_NUMBER_RANGE

Purpose: Custom number range logic

Real Example:

• Different number ranges per Sales Office.

8. USEREXIT_PRICING_PREPARE_TKOMK
⭐⭐⭐⭐

Purpose: Add header fields to pricing

Real Example:

• Add Customer Classification to pricing.

9. USEREXIT_PRICING_PREPARE_TKOMP
⭐⭐⭐⭐

Purpose: Add item fields to pricing

Real Example:

• Add Material Brand field into pricing condition.


User Exit BADI

10. USEREXIT_FIELD_MODIFICATION

Purpose: Screen field control

Real Example:

• Make Incoterm mandatory for Export orders.

3. Delivery User Exits – MV50AFZ1

11. USEREXIT_SAVE_DOCUMENT_PREPARE
⭐⭐⭐⭐

Purpose: Validation before PGI

Real Example:

• Block PGI if Transport not assigned.

12. USEREXIT_SAVE_DOCUMENT

Purpose: Logic after PGI

Real Example:

• Update warehouse interface table.

13. USEREXIT_MOVE_FIELD_TO_LIKP

Purpose: Delivery Header Data

Real Example:
User Exit BADI
• Populate Route automatically.

14. USEREXIT_MOVE_FIELD_TO_LIPS

Purpose: Delivery Item Data

Real Example:

• Default Picking Location.

15. USEREXIT_DELETE_DOCUMENT

Purpose: Logic during deletion

Real Example:

• Log deleted deliveries.

4. Billing User Exits – RV60AFZZ

16. USEREXIT_FILL_VBRK_VBRP ⭐⭐⭐⭐

Purpose: Fill Billing Fields

Real Example:

• Populate GST classification.

17. USEREXIT_ACCOUNT_PREP_KOMKCV
⭐⭐⭐⭐⭐
User Exit BADI
Purpose: FI Account Determination

Real Example:

• Different revenue account per product category.

18. USEREXIT_ACCOUNT_PREP_KOMPCV

Purpose: Account determination item level

Real Example:

• Freight account change dynamically.

19. USEREXIT_NUMBER_RANGE

Purpose: Billing number logic

Real Example:

• Separate number range Export vs Domestic.

20. USEREXIT_SAVE_DOCUMENT_PREPARE

Purpose: Billing validation

Real Example:

• Prevent billing if POD missing.

4. Pricing User Exits


User Exit BADI

21. USEREXIT_PRICING_COPY

Purpose: Pricing copy logic

Real Example:

• Do not copy manual discount.

22. USEREXIT_XKOMV_BEWERTEN

Purpose: Pricing Calculation

Real Example:

• Special rebate calculation.

23. USEREXIT_PRICING_CHECK

Purpose: Pricing Validation

Real Example:

• Error if net price below cost.

5. Partner Determination

24. EXIT_SAPLV09A_001

Purpose: Partner Determination

Real Example:

• Auto assign forwarding agent.


User Exit BADI

6. Shipping User Exit

25. USEREXIT_ROUTE_DETERMINATION

Purpose: Route determination

Real Example:

• Different routes for express delivery.

7. Credit Management

26. EXIT_SAPFV45K_001

Purpose: Credit Check Enhancement

Real Example:

• Include overdue invoices.

8. Output Determination

27. USEREXIT_KOMKBV1_FILL

Purpose: Header Output Fields

Real Example:

• Add Customer Group into output.


User Exit BADI

28. USEREXIT_KOMPBV1_FILL

Purpose: Item Output Fields

Real Example:

• Print Material Brand.

9. Text Determination

29. USEREXIT_TEXT_MODIFY

Purpose: Modify Text

Real Example:

• Auto print legal clause.

🔟 Copy Control

30. USEREXIT_COPY_DOCUMENT

Purpose: Copy Control Logic

Real Example:

• Prevent order copy after 30 days.


Top 15 SAP SD User Exit ABAP Code Examples

1️.Mandatory Customer PO Number


User Exit: MV45AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Scenario: Customer PO number must be mandatory in Sales Order.

IF vbak-bstnk IS INITIAL.
MESSAGE e001(zsd) WITH 'Customer PO Number is mandatory'.
ENDIF.

✅ Used in: VA01 / VA02 validation

2️. Block Order for Blacklisted Customer


User Exit: MV45AFZZ → USEREXIT_CHECK_VBAK

Scenario: Block sales order if customer is blacklisted.

SELECT SINGLE kunnr


FROM zblacklist
INTO @DATA(lv_kunnr)
WHERE kunnr = vbak-kunnr.

IF sy-subrc = 0.
MESSAGE e002(zsd) WITH 'Customer is Blacklisted'.
ENDIF.

3️. Auto Populate Storage Location


User Exit: MV45AFZZ → USEREXIT_MOVE_FIELD_TO_VBAP

Scenario: Storage location auto determination.

IF vbap-werks = '1000'.
vbap-lgort = '0001'.
ENDIF.

4️. Default Incoterm


User Exit: MV45AFZZ → USEREXIT_MOVE_FIELD_TO_VBAK

Scenario: Default Incoterm based on Customer.

IF vbak-kunnr = '100000'.
vbak-inco1 = 'FOB'.
ENDIF.

5️. Block PGI Without Transport


User Exit: MV50AFZ1 → USEREXIT_SAVE_DOCUMENT_PREPARE

Scenario: Prevent PGI without transport assignment.

IF likp-traty IS INITIAL.
MESSAGE e003(zsd) WITH 'Transport must be assigned'.
ENDIF.

6️. Add Custom Field into Pricing


User Exit: USEREXIT_PRICING_PREPARE_TKOMP

Scenario: Add Brand field into pricing.

tkomp-zzbrand = vbap-zzbrand.
7️. Margin Check Logic ⭐⭐⭐⭐⭐
User Exit: MV45AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Scenario: Block order if margin below 5%.

DATA: lv_margin TYPE p DECIMALS 2.

lv_margin = (vbap-netwr - vbap-mtpos) * 100 / vbap-netwr.

IF lv_margin < 5.
MESSAGE e004(zsd) WITH 'Margin below 5% not allowed'.
ENDIF.

✅ Very common in projects

8️. Revenue Account Determination Enhancement


User Exit: RV60AFZZ → USEREXIT_ACCOUNT_PREP_KOMKCV

Scenario: Revenue account based on Product Category.

IF vbrp-matkl = 'FG01'.
komkcv-prctr = 'PC1000'.
ENDIF.

9️. Prevent Billing Without POD


User Exit: RV60AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Scenario: Billing allowed only after POD.

IF likp-podkz IS INITIAL.
MESSAGE e005(zsd) WITH 'POD not completed'.
ENDIF.

🔟 Auto Route Determination


User Exit: MV50AFZ1 → USEREXIT_MOVE_FIELD_TO_LIKP

Scenario: Route auto determination.

IF likp-vstel = '1000'.
likp-route = 'R001'.
ENDIF.

11. Pricing Validation

User Exit: USEREXIT_PRICING_CHECK

Scenario: Net price cannot be zero.

IF xkomv-kwert = 0.
MESSAGE e006(zsd) WITH 'Price cannot be zero'.
ENDIF.

12. Auto Partner Assignment

User Exit: EXIT_SAPLV09A_001

Scenario: Auto assign forwarding agent.

e_partner-kunnr = '200000'.

13. Copy Control Restriction

User Exit: USEREXIT_COPY_DOCUMENT

Scenario: Prevent copy after 30 days.

IF vbak-audat < sy-datum - 30.


MESSAGE e007(zsd) WITH 'Copy not allowed after 30 days'.
ENDIF.

14. Output Determination Enhancement

User Exit: USEREXIT_KOMKBV1_FILL


Scenario: Add Customer Group to output.

komkbv1-kdgrp = vbak-kdgrp.

15. Delivery PGI Validation ⭐⭐⭐⭐

User Exit: MV50AFZ1 → USEREXIT_SAVE_DOCUMENT_PREPARE

Scenario: Prevent PGI if picking incomplete.

IF lips-pikmg <> lips-lfimg.


MESSAGE e008(zsd) WITH 'Picking not complete'.
ENDIF.

🔥 20 Real Production SAP SD User Exit Issues with RCA

1️. Sales Order Not Saving


User Exit: MV45AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Issue:
Users unable to save Sales Order.

Root Cause (RCA):


Hard error message added in User Exit without condition.

MESSAGE e001(zsd) WITH 'Error'.

Solution:
Add proper condition check.

2️. Sales Order Slow Performance


User Exit: MV45AFZZ

Issue:
VA01 taking 20–30 seconds.
Root Cause:
SELECT query inside LOOP.

LOOP AT xvbap.
SELECT SINGLE * FROM mara
INTO wa_mara
WHERE matnr = xvbap-matnr.
ENDLOOP.

Solution:
Use FOR ALL ENTRIES.

3️. Pricing Not Determined


User Exit: USEREXIT_PRICING_PREPARE_TKOMP

Issue:
Condition record not found.

Root Cause:
Custom field not passed.

tkomp-zzbrand = vbap-zzbrand.

Field missing in KOMPAZ structure.

Solution:
Append field properly.

4️. Wrong Revenue Account Posted


User Exit: RV60AFZZ → USEREXIT_ACCOUNT_PREP_KOMKCV

Issue:
Incorrect GL account posting.

Root Cause:
Wrong Profit Center logic.

komkcv-prctr = 'PC2000'.
Solution:
Add correct condition.

5️. PGI Blocked Unexpectedly


User Exit: MV50AFZ1 → USEREXIT_SAVE_DOCUMENT_PREPARE

Issue:
PGI blocked for all deliveries.

Root Cause:
Transport field mandatory for all.

IF likp-traty IS INITIAL.
MESSAGE e001(zsd).
ENDIF.

Solution:
Apply condition only for export orders.

6️. Dump in Sales Order


User Exit: MV45AFZZ

Issue:
Short dump during VA01.

Root Cause:
Division by zero.

lv_margin = netwr / kwmeng.

Solution:

IF kwmeng <> 0.
lv_margin = netwr / kwmeng.
ENDIF.

7️. Billing Not Created


User Exit: RV60AFZZ → USEREXIT_SAVE_DOCUMENT_PREPARE

Issue:
VF01 billing error.

Root Cause:
Mandatory field validation.

Solution:
Relax validation for credit memo.

8️. Duplicate Z-table Records


User Exit: USEREXIT_SAVE_DOCUMENT

Issue:
Duplicate entries.

Root Cause:
INSERT without check.

INSERT ztable.

Solution:

MODIFY ztable.

9️. Delivery Not Created


User Exit: MV45AFZZ

Issue:
VL01N fails.

Root Cause:
Incorrect schedule line logic.

🔟 Incorrect Storage Location


User Exit: USEREXIT_MOVE_FIELD_TO_VBAP

Issue:
Wrong Storage Location.

Root Cause:
Plant condition missing.

11. Pricing Value Wrong

User Exit: USEREXIT_XKOMV_BEWERTEN

Issue:
Wrong discount.

Root Cause:
Incorrect calculation.

12. Account Determination Failed

User Exit: RV60AFZZ

Issue:
Error:

Account determination not possible

Root Cause:
KOMKCV field overwritten.

13. PGI Slow Performance

User Exit: MV50AFZ1

Issue:
PGI takes long time.
Root Cause:
Heavy SELECT statements.

14. Output Not Triggered

User Exit: USEREXIT_KOMKBV1_FILL

Issue:
Invoice output missing.

Root Cause:
Field not filled.

15. Credit Check Not Working

User Exit: EXIT_SAPFV45K_001

Issue:
Credit limit ignored.

Root Cause:
Logic overwritten.

16. Order Block Applied Incorrectly

User Exit: USEREXIT_CHECK_VBAK

Issue:
Order blocked wrongly.

Root Cause:
Wrong customer group logic.
17. Pricing Redetermined Automatically

User Exit: USEREXIT_PRICING_COPY

Issue:
Manual price lost.

Root Cause:
Pricing type changed.

18. Route Determination Incorrect

User Exit: USEREXIT_MOVE_FIELD_TO_LIKP

Issue:
Wrong route.

Root Cause:
Shipping condition ignored.

19. Text Not Printed

User Exit: USEREXIT_TEXT_MODIFY

Issue:
Text missing.

Root Cause:
Overwrite logic.

20. Inconsistent Data Between SD and FI ⭐⭐⭐⭐⭐

User Exit: RV60AFZZ → USEREXIT_ACCOUNT_PREP_KOMKCV

Issue:
FI posting wrong.
Root Cause:
Custom GL logic incorrect.

You might also like