Introduction

Understanding Customer Exits theoretically is easy.

Understanding them through a real business requirement is what actually makes you an SAP consultant.

In this blog, we’ll walk through a real-time project scenario where a Function Exit is used to implement conditional validation in a standard SAP transaction—without modifying SAP code.

By the end of this blog, you'll clearly understand:

• Why a Function EXit is required

• How to identify the correct Customer Exit

• How to implement, activate, and test it

• Why this approach is still relevant in S/4 HANA

Customer Exits – Quick Context

Customer Exits are procedural SAP enhancements that allow customers to plug in logic at predefined points.

They are classified into three types:

Type Purpose

Function Exit Add validations / checks

Screen Exit Add additional fields

Menu Exit Add new menu options

This blog focuses only on Function Exits, because validations cannot be solved correctly using screen logic.

Real Business Requirement

Transaction

• XD01 – Create Customer

Requirement

While creating customer in XD01, If Country = India, then Industry Key must be mandatory

For other countries → Industry key is optional.

By Default Industry key is not mandatory.

Note: Why Not Screen Mandatory for this requirement?

• Making a field mandatory at screen level

❌ Makes it mandatory for all countries

• Requirement is conditional (india only)

✅ So we need validation logic → Function Exit

This is a classic real-world requirement you’ll see in almost every SAP project.

Important Tables & Fields for this requirement

Field Technical Name Table

Country LAND1 KNA1

Industry Key BRSCH KAN1

👉 Found using XD01 → Industry field(value help) → F1 → Technical Information

Knowing how to find technical field details is a must-have consultant skill.

Step-by-Step Identification of Customer Exit (Most Important Part)

90% of Customer Exit work is identification. Coding is barely 10%.

Step 1: Find Main Program of the Transaction

• T-code: SE93

• Transaction: XD01

• Program found: SAPMF02D

Step 2: Find Package of Program

• Double-click program

• GoTo Menu → Attributes

• Package: VS

Step 3: Search Customer Exits

• T-code: SE84 ( Repository Information System)

• Enhancements → Customer Exits → Enhancement → double click on it

• Enter package: VS → Click on Execute

• You’ll see list of available customer exits available for the package.

• Customer Exit Name: SAPMF02D

✅ Found one customer exit: SAPMF02D

Understanding the Identified Customer Exit

• Customer Exit Name: SAPMF02D

• This exit belongs to program SAPMF02D (used by D01)

⚠️ Name saying “user exit” in description is misleading

👉 It is a Customer Exit, not a classic User Exit

Note: Every Customer Exit may have Function exit, Menu exit, Screen exit. There is no guarantee it will have all three. You need to check and find out whether it is having relevant exit according to your requirement.

For our requirement we need to look for Function Exit (validation on standard field based on condition

Tools Related to Customer Exits

For every customer exit, two T-codes are important

T-code Purpose

SMOD View exit components & documentation

CMOD Implement the exit

Without CMOD, the exit will never execute.

Checking Exit Components to check if required type of ‘function exit’ exists.

Steps:

1. Go to SMOD

2. Enter exit name: SAPMF02D

3. Click Components

What We Learned:

• This customer exit contains only Function Exits

• No Menu Exit

• No Screen Exit

👉 That's fine, because

• Our requirement → validation

• Validation → Function Exit

Reading Documentation (Very Important) to check if this customer exit suits our requirements.

In SMOD → Documentation, we see:

“User exit for checks prior to saving customer master”

Meaning

• This function exit is triggered when SAVE is pressed

• Perfect for validation logic

Understanding the Function Module found in SMOD → components

• Double-click the function exit

• Opens SE37 – Function Builder

Key Important Parameter:

I_KNA1 (same as out table so it can be used)

This structure contains

• LAND1 → Country

• BRSCH → Industry Key

✅ Exactly what we need for our validation

Conclusion from Analysis

✔ Exit is triggered before save

✔ Required fields available in I_KNA1

✔ Suitable for conditional validation

👉 This customer exit fits our requirement

Implementation Using CMOD

Step 1: Create Project

• T-code: CMOD

• Project name: Z_XD01_PRJ (any Z-name)

• Short text: XD01 Validation

Step 2: Assign Customer Exit

• Click "Enhancement Assignment"

• Enter: SAPMF02D

• Save

⚠️ If already assigned to another project → error

✔ If accepted → free to implement

Step 3. Open Exit for Coding

1. Go to Components on the same screen

2. Switch to Change mode

3. Double-click the Function Exit

4. It opens the Function Module

Step 4. Where to Write Code?

🚫 You cannot modify standard function module

SAP Provides a Z-Include inside the function module:

• Include name starts with ZX...

• Reserved only for customer code

First Time:

• Double-click include

• SAP asks to create it

• Choose Local Object / Transport

Step 5. Validation Logic (Core Concept)

Business Rule

If Country = India AND Industry Key is empty 
→ Stop save with error

ABAP Logic (Conceptual)

IF i_kna1-land1 = 'IN' AND i_kna1-brsch IS INITIAL.
  MESSAGE 'Please maintain Industry Key for Indian customers'  TYPE 'E'. 
ENDIF.

Why TYPE 'E'?

• E → Stops save

• I → Informational only

• W → Warning (Save Allowed)

Step 6. Activation

You must activate:

1. Z-Include

2. Function Module

3. CMOD Project

❌ Missing activation = exit won’t trigger

Step 7. Testing the Enhancement

Case 1: Non-Indian Customer

• Country: Australia

• Industry: blank

• Result: ✅ Customer created

Case 2: Indian Customer without Industry

• Country: India

• Industry: blank

• Result: ❌ Error message shown

• Save blocked

Case 3: Indian Customer with Industry

• Country: India

• Industry: maintained

• Result: ✅ Customer created

What If No Suitable Customer Exit Exists?

Check for other enhancement in search order.

Note: Not every SAP transaction is enhanceable.

S/4HANA Relevance

✔ Concept still valid in S/4HANA

✔ CMOD / SMOD still exist

⚠️ But

• New developments → BAdI / Enhancement Framework

• Customer exits mainly for support / legacy systems