100% found this document useful (1 vote)
94 views27 pages

Customer Exit Programs

1) This document describes how to implement customer exits in SAP for different scenarios like screen exits, menu exits, and function module exits. 2) It provides step-by-step instructions for adding a field to a screen, adding a custom menu option, and setting a default customer for a sales order based on certain conditions. 3) The function module exits allow validating customer data and predetermining sales order fields using ABAP code implemented in function module exits.

Uploaded by

Karthik K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
94 views27 pages

Customer Exit Programs

1) This document describes how to implement customer exits in SAP for different scenarios like screen exits, menu exits, and function module exits. 2) It provides step-by-step instructions for adding a field to a screen, adding a custom menu option, and setting a default customer for a sales order based on certain conditions. 3) The function module exits allow validating customer data and predetermining sales order fields using ABAP code implemented in function module exits.

Uploaded by

Karthik K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Customer Exits Programs

1) Screen Exit's : (Program)

2). Menu Exit's : (Program)

3). Function Exit :(Two -Program)

4). In Single Program used for all Customer Exit's like Function, Screen & Menu
Exit's.

5). Identify Exit Names in Report program through Tcode.

--------------XXXXXXXXX---------------

1) Screen Exit's : (Program)


Business Requirement : Add field in AS03 Tcode.

Add field in Origin Tab

Step :1 : Goto Tcode AS03 -> System status -> Program name : SAPLAIST

Screen No : 1000 : Normal Screen

1082 : Sub Screen

Step 2: Double Click on Program and goto Object Navigator

Step 3: Double Click on screen 1082

Click on layout

Here Table is : ANLA

Field is : AENAM

Drag and drop field

Step 4: Save and Activate Layout

Step 5: Goto Tcode AS03. Click on origin added a field.

Page 1 of 27
2. Menu Exit's : (Program)
Business Requirement

Adding a custom menu in MC94 Transaction to display MC98 transaction

Steps

- Find the Package name for the MC94 Transaction

Finding Package Name


1. Go to SE93
2. Give the transaction name MC94.

3. Click on display
4. Then u will get the Package name i.e. MCP2

5. Then go to SMOD transaction


6. Go to Utilities and Click on find as below

7. Then give the Package name and click on Execute (F8).

Page 2 of 27
8. Then we will get the enhancements

9. Then we have to check for the MENU exit


10. double click on each exit one by one if the ‘+’ symbol is available .

11. Here as per our requirement MCP20003 is suitable because ‘+’ symbol is
available here.
12. Then Go to CMOD transaction and create the Project

Page 3 of 27
13. Inside the Project give the Enhancement name by , Click on enhancement
Assignment Button as below

14. Then give the Enhancement as below

15. Then Click on components


16. It will be in Red in colour

17. Once you click on Activate then it will became green in color as below

Page 4 of 27
18. Double Click on ‘+CU1’ and give the function text as below

19. Click on copy


20. Then Double click on EXIT_SAPMMCP6_003.
21. Then it will display below screen and find For ZINCLUDE
22. Then double click on ZXSOPU03.
23. Click on ctrl+F1 then write the code as below

24. Click on Activate


25. Go Back then click on Activate
26. Go Back then click on Activate
27. Go Back then click on Activate
28. Go to MC94 Transaction

Page 5 of 27
29. Give the planning type is COMMIT press ENTER
30. Click on Active Version as below

31. Then fallow as below

32. Then go to main SAP Screen and check bye giving MC98 Tcode

Page 6 of 27
3). Function Exit :(Program)
(1) Business Requirement: Whenever we create a customer. We need to check
whether the customer belongs to Country : GERMANY and if Region is equal to
space .

Then, Raise an Error message.

Technical requirements:

 Tcode is : XD01/ XD02/ XD03.


 Country Field is : LAND1 .
 Region Field is : REGIO.
 Table name is : KNA1 .
 The above tables and fields are given by functional consultants.

Step1 : Find the FM exit for the requirement:

 Goto XD02
 Give any customer no, Ex : 2006
 Press enter

 Customer Details will be displayed.


 Click System from Menu bar -> Status ->
 Double click on Program (Screen)

 Now, Click on Find Icon


 Type Call customer in the Find field, then click the In Main program radio
button and hit Enter
Page 7 of 27
 A list of call customer functions will be displayed.
 Based on requirement, Check Import/Export Parameters for each Function
Module
 And roughly select some Customer Function Modules .

As per my requirement, I need KNA1 Table details, SO I have selected the below
Customer Function Module which has an exporting parameter I_KNA1.

 Now, double click on the above Function Module and Put a break-point .
 Now execute the Transaction.
 Goto XD02
 Give any customer number, Ex : 2006
 Press Enter
 Customer screen will be displayed.
Page 8 of 27
 Click on Save.
 Our break-point will be triggered. Please check the below screen shot ..

 Stop the Debugging and now implement the Functional Module Exit.
 As this exit is triggered, this is the suitable Functional Module Exit for our
requirement.

Step 2: Implement the Exit using CMOD Transaction .

Exit name is : SAPMF02D

 So the Enhancement name is SAPMF02D .


 Give Enhancement Name and press enter.

 Click on Button.

The below Screen will be displayed with RED colours.

 Double click on “EXIT_SAPMF02D_001”.


Page 9 of 27
 Function Module will be opened .
 Below you will find an Include .

 Double click on Include .


 A warning message will appear.
 Just press Enter.
 Create the Include
 Include will be opened.
 Write the below code.

IF I_KNA1-LAND1 = 'DE' AND I_KNA1-REGIO = ''.
MESSAGE 'Region is mandatory for german customers' TYPE 'E'.
ENDIF.

 Save activate the Include.


 Click on BACK
 Activate the Function Module.
 Click on BACK
 Click on Activate.
 The RED lights will turn to GREEN Colour.
 Activate the Exit.

 Now, Run the transaction and test .


 Goto XD02.

Page 10 of 27
 Give customer no
 Press enter

 Customer Screen is displayed.


 Remove the region and save it.

Check below

 Now save it . Our Exit will be triggered and


 The error message will be displayed as below .

Page 11 of 27
(2) Business Requirement: Whenever we create a Sale Order, We need to
Predetermine the Sold-to-Party Based on some conditions.

Sold-to-Party means the customer for whom the sale order is created.

Technical requirements:

 Tcode is : VA01/VA02/VA03.
 Sold-to-Party is : KUNNR.
 Table name is : VBAK.
 The above tables and fields are given by functional consultants.

STEPS:

Step1 : Find the Package Name for the sale order transaction

Step 2: Find the Enhancements(FM exits) using package name in SMOD Transaction.

Step 3: Implement the Exit using CMOD Transaction .

Step 4: Test It .

Step1 : Find the Package Name:

 Goto SE93
 Give Transaction code name as : VA01
 Click on Display
 Transaction code will be displayed.

 Note down the package name , Here it is “VA”.

Step 2: Find the Enhancements(FM exits) using package in SMOD transaction

 Goto SMOD
 Click on UTITLITIES From menu bar
 Select FIND
 Give Package name as VA

Page 12 of 27
 Click on Execute
 A list of Enhancement Names will be displayed .
 Choose the Exact Enhancement by reading the description.
 Here for my requirement, this Enhancement is suitable” V45A0002”.

 So, Let me check whether it is Correct Enhancement or not .


 Now goto CMOD, Give the Project Name as ZA_CUST
 Click on change
 Click on Enhancement Assignments
 Give the Above Enhancement Name.

 Click on Components Button


 The below screen will be displayed.

 Double click on the EXIT_SAPMV45A_002


 Double click on the Function Module
 Check Importing/Exporting Parameters
 Here for my Requirement, I need Kunnr..so it is available as Exporting
Parameter.


 Now , GO to the source code, Double click on the INCLUDE and create it .
 Write the below code in it I.E. BREAK-POINT
 BREAK-POINT .

 Save activate the Include.


 Click on BACK
 Activate the Function Module.
 Click on BACK
 Click on Activate.
 The RED lights will turn to GREEN Colour.
 Activate the Exit.
Page 13 of 27
 Now, Run the transaction and test .

Testing the Enhancement from Transaction

 Goto VA01.
 Give the Order Type as OR.

Press Enter

 Our Break-point will be triggered.

 Stop the Debugging and now implement the Functional Module Exit.
 As this exit is triggered, this is the suitable Functional Module Exit for our
requirement.

Step 3: Implement the Exit using CMOD Transaction.

 Now goto CMOD, Give the Project Name as ZA_CUST


 Click on change
 Click on Enhancement Assignments
Page 14 of 27
 Click on Components Button
 Double click on the EXIT_SAPMV45A_002
 Double click on the Function Module
 Double click on the INCLUDE
 Write the below code in it

 Save activate the Include.


 Click on BACK
 Activate the Function Module.
 Click on BACK
 Click on Activate.
 The RED lights will turn to GREEN Colour.
 Activate the Exit.

Step 4: Test It .

 Goto VA01.
 Give the Order Type as OR.

 Press Enter
 Sale order screen will be displayed with SOLD-TO-PARTY as 60

Page 15 of 27
4). In Single Program used for all Customer Exit's like Function, Screen
& Menu Exit's.
Business Requirement: Add a custom screen in CJ92 transaction to

Display the date/name of the person created the PROJECT.

For this we need to implement Menu Exits and Screen Exits for transaction CJ92

Technical requirements:

 Tcode is : CJ91/ CJ92/ CJ93.


 Date : Field Name is ERDAT.
 Nmae : Field Name is ERNAM.
 Table name is : PROJ
 The above tables and fields are given by functional consultants.

STEPS:

Step1 : Find the Package Name

Step 2: Find the Enhancements(FM exits) using package name in SMOD


Transaction.

Step 3: If no Enhancements are available, use CALL CUSTOMER and find an


enhancement.

Step 4: Implement the enhancement using CMOD Transaction .

Step5 : Test it

Step1 : Find the Package Name

 Goto SE93
 Give Transaction code name as : Cj92
 Click on Display
 Transaction code will be displayed.
 Note down the package name.

Step 2: Find the Enhancements(Screen/FM exits) using package in SMOD


transaction

 Goto SMOD
 Click on UTITLITIES From menu bar
 Select FIND
 Give Package name .
Page 16 of 27
 Click on Execute
 No Enhancement are displayed here.
 So, Use alternative approach as below.

Step 3: If no Enhancements are available, use CALL CUSTOMER and find an


enhancement.

 Goto CJ92
 Give any Std. project def., Ex : A-10000

 Click System from Menu bar -> Status ->


 Double click on Program (Screen)

 Now, Click on Find Icon


 Type Call customer in the Find field, then click the In Main program radio
button and hit Enter

Page 17 of 27
 Double click on SAPLCJSS
 A list of call customer functions will be displayed.
 We cannot put any break-points and search for screen exit.
 Double click on each call customer functions
 Note down the Function Module name and doubl click
 GOTO table SMOD and find the enhancement name for each Function Module.
 Repeat this for each Functon module .
 Below is the list which displays Enhancement name for each Function module

Now, Search for SCREEN EXITS.

 Goto SMOD
 Give the first Enhancement Name

 Click on Display.
 Click on Components
 You can observe that there are no screen exits available.

Page 18 of 27
Repeat the same for each enhancement and find the screen exits.

 Goto SMOD
 Give the first Enhancement Name

 Click on Display.
 Click on Components
 You can observe that there are screen exits/Menu exits/FM Exits available.

SO now , we can implement this Enhancement

Step 2: Implement the Screen Exit using CMOD Transaction .

 Goto CMOD Transaction.


 Give a name for the Project

Page 19 of 27
 Click on change
 Click on Enhancement Assignments
 Give the Enhancement name as “CNEX0003”

 Click on Components
 Below screen will be displayed

Here FM Exit ‘s are :

EXIT_SAPLCJSS_002 –

EXIT_SAPLCJSS_003 –

Here Menu Exit

SAPLCJSS +CUD – is used for the description to appear in the menu. “+CUD” acts
as

Fcode (user command).

Here Screen Exit

SAPLXCN1 0300 - Here we add the screen elements.

Designing the Screen

 Double click on “0205”



 Click on Continue
 A screen will be created.
 Give description

 Select the screen type as SUBSCREEN B’coz all screen exits will be of type SUB-
SCREENS
Page 20 of 27
 Click on Layout.
 Drag and drop a text label and give name, text as NAME
 Drag and drop a INPUT field and give name as V_NAME
 Drag and drop another text label and give name, text as DATE
 Drag and drop a INPUT field and give name as V_DATE
 Change the format to DATS data type

Finally, the layout should look as below.

 Click on flowlogic->activate it .
 The Below fields need to be declared in the TOP Include file .
 V_DATE, V_NAME .
 Click on Display object list ICON


Page 21 of 27
 Function Group will be opened.


 Expand XCN1
 Expand Includes
 Double click on TOP include file “LXCN1TOP”.


 Now again double click on “ZXCN1TOP”.

 Click on change button


 Click on INSERT BUTTON


 Write the Below Code.

 Save it, activate it.


 From the above steps, the custom screen is designed.
 Now we need to write the logic to display the date/time
 For the project.

Click on Back->back->back. Until the below screen is displayed.

Page 22 of 27
Always we write the logic in FM exits.

Logic in Function Exits


 Now we write the code in EXIT_SAPLCJSS_002 which will display the DATE and
NAME.
 Double click on the Function exit EXIT_SAPLCJSS_002 and then double click on
the include ZXCN1U13. Create the include program.
 Write the below logic
 v_name = SAP_PROJS_IMP-ernam .
v_date = SAP_PROJS_IMP-erdat .

Menu Exit
Now to call this screen. We need Menu Exit.
Go back to the below screen.

Double click on the menu exit.

Give the text what you need on the Menu.

For My Requirement, I need Display NAME/DATE.

Page 23 of 27
Now activate the Project.

Step5 : Test it

Now the output would be as below:


Because of Menu Exit, in the menu a new entry would appear (like ‘Click Here’) as
shown below.

Now a new screen (i.e., our custom screen) would appear. Now the PBO Function exit
would get executed and shows the following Screen.

Page 24 of 27
--------------XXXXXXXXXXX--------------------

5). Identify Exit Names in Report program through Tcode.


REPORT  ZUSEREXIT.
TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
TABLES : tstct.
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.

SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass.
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir WHERE funcname =
tfdir-funcname.
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name EQ enlfdir-area.

MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT * FROM tadir INTO TABLE jtab
WHERE pgmid = 'R3TR'
AND object = 'SMOD'

Page 25 of 27
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND
tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT jtab[] IS INITIAL.
WRITE:/(95) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
WRITE:/(95) sy-uline.
LOOP AT jtab.
SELECT SINGLE * FROM modsapt
WHERE sprsl = sy-langu AND
name = jtab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 sy-vline,
2 jtab-obj_name HOTSPOT ON,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
ENDLOOP.
WRITE:/(95) sy-uline.
DESCRIBE TABLE jtab.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , sy-tfill.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'No User Exit exists'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
AT LINE-SELECTION.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

Page 26 of 27
Page 27 of 27

You might also like