Customer Exit Programs
Customer Exit Programs
4). In Single Program used for all Customer Exit's like Function, Screen & Menu
Exit's.
--------------XXXXXXXXX---------------
Step :1 : Goto Tcode AS03 -> System status -> Program name : SAPLAIST
Click on layout
Field is : AENAM
Page 1 of 27
2. Menu Exit's : (Program)
Business Requirement
Steps
3. Click on display
4. Then u will get the Package name i.e. MCP2
Page 2 of 27
8. Then we will get the enhancements
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
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
Page 5 of 27
29. Give the planning type is COMMIT press ENTER
30. Click on Active Version 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 .
Technical requirements:
Goto XD02
Give any customer no, Ex : 2006
Press enter
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.
Click on Button.
IF I_KNA1-LAND1 = 'DE' AND I_KNA1-REGIO = ''.
MESSAGE 'Region is mandatory for german customers' TYPE 'E'.
ENDIF.
Page 10 of 27
Give customer no
Press enter
Check 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 4: Test It .
Goto SE93
Give Transaction code name as : VA01
Click on Display
Transaction code will be displayed.
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”.
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 .
Goto VA01.
Give the Order Type as OR.
Press Enter
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 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
For this we need to implement Menu Exits and Screen Exits for transaction CJ92
Technical requirements:
STEPS:
Step5 : Test it
Goto SE93
Give Transaction code name as : Cj92
Click on Display
Transaction code will be displayed.
Note down the package name.
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.
Goto CJ92
Give any Std. project def., Ex : A-10000
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
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.
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
EXIT_SAPLCJSS_002 –
EXIT_SAPLCJSS_003 –
SAPLCJSS +CUD – is used for the description to appear in the menu. “+CUD” acts
as
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
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”.
Write the Below Code.
Page 22 of 27
Always we write the logic in FM exits.
Menu Exit
Now to call this screen. We need Menu Exit.
Go back to the below screen.
Page 23 of 27
Now activate the Project.
Step5 : Test it
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--------------------
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