You are on page 1of 29

Menu Exit is use to add custom menu option to the standard menu.

As an example suppose you want to add the extra option to navigate to transaction SU01D from
the SE! "rogram Display screen. Suppose you want put that menu option #ust $elow the
Utilities%&ersions. 'hec( the $elow screen shot.
Step 1)
*ind out the Menu exit which can $e used to achieve this functionality.
+o to System status and find out the pac(age name used for this SE! Source code Display
screen. ,he program name is SA"-S!E to display the source code in transaction SE!. +o to
attri$ute of this "rogram. you can find the pac(age as SED/.
,a(e this pac(age name SED/ and +o to transaction code 'M0D .Use the menu path Utilities1
2SA" Enhancement.
+ive the pac(age name as SED/ and execute it. 3ou can find the $elow list of enhancements
As per the description ) Enhancement SEUED001 'an $e used. So 4ow when you got your
dream enhancement let5s start the movie.
Step 6)
+o to ,ransaction 'M0D and create a "ro#ect 7ME,ES, 83ou can give any name9.'lic( on the
$utton Assign Enhancement and include the Enhancement SEUED001.'lic( on the components
$utton you can see the $elow Exits.
Step )
Dou$le clic( on the E:/, SA"-S!E ;"+E. /t will popup you the extra menu
option which you want to add.
Step <)
=hen you clic( on the >+o to Su01d? menu option the screen execution should go to the SU01D
transaction. ,o write this navigation code we can use *unction exit
E:/,@SA"--0'A-@ED,1@006 8Some time you need to try trial and error method to find out
the related function module name9.Dou$le clic( on it and write the $elow code into the include
7:SEUU6A.8which is inside the *unction module E:/,@SA"--0'A-@ED,1@0069.
84ote) Set parameter statement is not reBuired it is #ust for setting the user id as your id in
SU01D9
set PARAMETER ID XUS FIELD SY-uname.
Call transactin SU!"D .
Step A)
+o $ac( to 'M0D screen and activate your pro#ect.
Step C)
0pen Se! screen with any report program and go to the menu path Utilities%+o to Su01d.
/t will ta(e you to Su01d screen.
User
A user exit is a place in a software program where a customer can arrange for their own tailor1
made code. SD module has a large num$er of User exit availa$le.
,he $elow is the createD change sales order screen 8&A01D&A069.
,he reBuirement is to put the validation to the line items such that the Buantity field for the line
item should not $e less than 6 units.
Step 1) Eow to find the appropriate USEF E:/,.
+o to o$#ect navigator8SE!09 and select pac(age from the list and enter &M0D in it. All of the
userexits in SD are contained in the development class &M0D. "ress enter and you will find all
includes which contain userexits in SD for different functions li(e "F/'/4+. 0FDEF
"F0'ESS/4+ etc. Select the userexit according to the reBuirement and read the comment
inserted in it and start coding .
,here is a lot of confusion in using USEF E:/,. li(e do we need access (ey to modify the USEF
E:/, G.
,he answer is 3es as well as 40.
/f you see the include M&<AA*77.we have many *0FMS and E4D*0FMS init which is in
custom name space. So we don5t need (ey to modify it. 'hec( out the $elow screen shot.
So open that include and write your logic in 7M&<AA*77@SA&E@D0'UME4,@"FE".
=hile some E:/,s li(e M&A0A*71. 3ou need an access (ey to modify it Don5t get puHHled. this
is how SA" has given I.
Step 6)
So we got our USEFE:/, 7M&<AA*77@SA&E@D0'UME4,@"FE". 0pen it and put the
$elow code inside it.
#ata$ l%&'la()"* t+,e c.
- e.it i' nt SA/E
i' s+-ucmm ne SIC0.
lea%e t screen s+-#+nnr.
en#i'.
- c1ec2 line items
clear l%&'la(.
l, at .%3a, 41ere u,#25 ne D.
- T1is c1ec2s 'r 6uantit+ less t1an 7
- As .%3a,-24men( is ,ac2 4it1 8 #ecimal 4e are cm,arin( 4it1 7!!!
i' .%3a,-24men( 9 7!!!.
messa(e i!!!)'3* 4it1 6uantit+ is less t1an 7:.
l%&'la( ; X.
clear s+-ucmm.
e.it.
en#i'.
en#l,.
i' l%&'la( ; X.
lea%e t screen s+-#+nnr.
en#i'.
+o ,o ,ransaction &A01D&A06 and try to createDchange the order item Buantity less than 6.
Jefore we start with this article of how to create a screen E:/, have a loo( into the $elow
image.
2 =henever the statement 'A-- 'US,0MEF1SUJS'FEE4 Karea2 /4'-UD/4+ K:1
function1pool2 Kscreen@num$er2 occurs at "J0 in the flow control of a screen. a su$screen is
included in the su$screen area defined $y SA" application programmers. At this point. all
modules called during the "J0 event of the su$screen are also processed.
2 ,he "A/ event of a su$screen is processed when the calling screen calls the su$screen during
its "A/ event using the statement 'A-- 'US,0MEF1SUJS'FEE4 Karea2.
2 ,he glo$al data of the calling program is not (nown to the : function group that contains your
su$screenL SA" application programmers use function module exits to explicitly provide this
data to su$screens.
2 /n order to facilitate data transport. modules are called in the flow control of the calling
program that contain function module exits for transferring data via interface parameters.
2 *unction modules $elonging to these (inds of function module exits can $e found in the same
function groups as their corresponding su$screens.
2 Data must $e transported in the other direction as well. since glo$al data from the : function
group that contains your su$screen is not (nown to the calling program either. *or this reason.
SA" application programmers use function module exits to return any data to the calling
program that was changed in the su$screen.
2 ,his is done $y calling a module during the main screen5s "A/ event that contains a function
module exit for returning customer data via interface parameters.
So In simple words Screen exit also require Two function module exits to make it to stand
properly.
Starting with the "ractical)
Jelow is ME664 screen. 4ow the reBuirement is to modify it with few extra fields into item
level data.
Step 1 )'M0D is the transaction code using which we can use this components
+o to ,ransaction code 'M0D 12 Enter the "ro#ect name As 7DE"0 8you can give any name9.
Step 6 )
'lic( on the $utton Enhancement Assignment
/nclude this Enhancement MM0E00! ",ransaction code SM0D is used to find the proper
enhancement needs to $e used9 Fead article En#ancement in S$% to (now how to find out
appropriate enhancement.
=e have already discussed how to find the respective component for your change.
Step )
'lic( on 'omponents Jutton.
3ou can see the $elow components into your "ro#ect)
/t is having *unction E:/,s. Screen E:/,s and few includes for the ta$le.
As we have discussed you want to Display Extra fields into ME664 screen.
Dou$le clic( on the '/@EM"0DJ it will ta(e you to SE11 screen.
Step <)
/nclude the field which you want to Show or enhance.
Eere we have used field 77"0,3" which is of type 'har<. Save it and activate it.
84ote) it may ta(e long time to activate as this field will $e inserted into EM"0 ta$le.9
Step A)
'lic( on the JA'M $utton and go $ac( to the $elow screen. 4ow you can design visual part of
your wor(.
Dou$le clic( on the Screen E:/, 0111./t will ta(e to you to Screen painter SeA1.
Step C)
'lic( on the layout $utton in the screen. And create la$el and text field.
Eere we are going to insert our created field 77"0,3".
'lic( on the $utton Dict.D"rogram fields.
Enter the ,a$leD*ield name as ) EM"0@'/177"0,3" and clic( +et *rom Dictionary $utton.
Select that field and insert it into the screen.
Save your changes and activate this screen.
Step N) Again go $ac( to the $elow screen using $ac( $utton.
,ill now we have created a S'FEE4. 8*irst image of this article) 'alling customer su$screen 9.
4ow we need to implement ,wo *unction E:/, to transfer data to the su$ screen and to read the
data from the su$screen .
Eere *unction E:/,)
E:/,@SA"MM0CE@01C.O2 use to transfer data to the su$screen.
E:/,@SA"MM0CE@01!.O2 use to get the data $ac( from the su$screen.
Dou$le clic( in the *irst 01C exit it will ta(e you to the function module . you will find one
include
/4'-UDE 7:M0CU<1 .
Dou$le clic( on this include and create it. "ut your code to initialiHe the varia$le EM"01
77"0,3" here.
Step !)
*or learning purpose we have #ust use a single line of code to ma(e it easy.
E<P=&CI->>P=TYP ; A?CD.
Ste, @$
Same way you can use the E:/,) E:/,@SA"MM0CE@01!. *or reading the value if use modify it
in screen.
*or time $eing ignore this step. And +o $ac( Again to the 'M0D screen and $cti&ate your
pro'ect (DE%).
Step 10)
+o to transaction code ME664 open any existing "0. 3ou can see an extra ta$ is added into
/,EM detail
'ustomer Data. =hich will have your new field 77"0,3".
,his Extra ta$ *ustomer Data is added $y standard SA" code. =henever it finds any active
screen exit while execution. it will activate this ta$. 84ote) screen 0111 which we have used is
defined under >'ustomer
*unction module exitD*unction E:/, is nothing $ut a function module with a 7 include where
you can put your code.
*unction module E:/, is called using 'A-- 'US,0MEF1*U4',/04 PK:::25.syntax.
=here ::: is three digits no. So the *unction module name loo(s li(e
E:/,@SA"-SUS*@:::.
Scenario+ -et5s ta(e an example in that the reBuirement is to put a welcome message to user
when heDshe log in into SA" system.
Step 1)
+o to the transaction SM0D) use menu path utilities% find
And give the "ac(age name as SUSF and execute it you can see the $elow component in it)
Step 6
=e have SUSF0001 component. *rom the description of the component you can ma(e out that
this E:/, is called after user log in into SA" system so we can use it for our purpose.
+o to ,ransaction 'M0D and create a "ro#ect named 7+U/'E'M 8you can give any name
starting with 7 9.
Step
'lic( on the Enhancement Assignment to include the component into this pro#ect. +ive our
component SUSF0001 and clic( enter $utton.
+o to 'omponents window 8/t will show all the exits included in this enhancement9. in our case
only one *unction Exit will $e shown.
Dou$le clic( on the *unction exit E:/,@SA"-SUS*@001./t will open *unction module Editor.
Dou$le clic( on the /4'-UDE 7:USFU01.
=rite down your welcome message here. you can use $elow code )
I' s+-uname e6 9useri#A.
Messa(e Belcme S4eet 0eart t+,e I.
En#i'.
4ow logout and log in again with Kuserid2. 3ou will get the popup saying
,he FeBuirement is to put a information message while creating a material if Material +roup is
A0A and Division is) 06.
8=hy can5t we use field exit GG ) As it needs two information 8 Material group and Division 9 for
the material also user wants information message while saving the material. this cant $e
achieved using field exit 9.
Step 1)
Eow to find appropriate JAD/ for this reBuirementGG
"ut the $rea(1 point into 'lass '-@E:/,EA4D-EF5s +E,@/4S,A4'E method.
+o to transaction code MM01 . create a material and try to save it. it stops at many location with
different values of E:/,@4AME. 8After chec(ing into Se1! we got the
,$DI-M$TE.I$/-*0E*1 which can $e use for our reBuirement.
/t has a method *0E*1-D$T$ which is called $efore saving the material.
/t also has =MAFA ta$le as input data 8Material +roup and Division comes in MAFA
ta$le9.
Step 6)
+o to ,ransaction code SE1!.
0pen JAD/ + ,$DI-M$TE.I$/-*0E*1.
+o to menu option /mplementation % 'reate.
Step )
+ive the implementation name as (MM-M$T-*0E*1.
Step <)
Dou$le clic( on the method 'EE'M@DA,A./f you notice the input parameters we have many
data related to $atch . material and storage location etc..
*or our reBuirement we need material group and devision =hich exist in =MAFA."ut the
$elow code inside the method then activate the class and method.
if =MAFA1MA,M- eB PA0AQ and =MAFA1S"AF, eB P06Q.
message PMaterial creation for this +roup should $e avoided for animal productsRR5 ,3"E P/5.
endif.
,his code is #ust chec(s the material group and division.
Step A)
+o $ac( and Activate the implementation.
Step C)
So now it5s the time to Disco RRRRRRRUpsssss Sorry it5s the time to test this JAD/.
*or this go to transaction MM01 and try to create a material.
8if you are confused use material name as *0002 .
Industry sector as $nimal 0ealt# and
Material Type as ,e&era3es 9
'lic( on the E4,EF Jutton and from the view select ,$SI* D$T$ 1.
Suppose you want to put a validation on a particular field then you can use *ield exit.
,here are two types of field exits. +lo$al and local.
4lo5al 6ield E7IT "suffix 08
=hich is applica$le for screens.
/)*$/ 6ield E7IT+ "wit# suffix 19: ; $9(8
=hich is applica$le to a particular screen 8that means. if you want to create a validation for $atch
field in MS'1n only. the same validation will not $e applica$le for other screens li(e &-64.
MJ1' etc.. 9
-et5s ta(e a simple example)
,he reBuirement is to put a validation on field "roduction allocation in Jasic data1 ta$ of
Material Master.8See the $elow screen shot9
/, should give an error message when user enters the value P.D*< in t#e %roduction $llocation
field.
3ou can create a field exit for such (ind of reBuirements.
,here are two ways to create field exit )
0ption 1)
"* Fr 'iel# e.its in RC8 D.ECF e.ecute transactin CM=D. T1en t+,e PRF? in t1e cmman#
'iel#.
7* =n t1e t, menuGclic2 n Fiel# e.it-A create -Aenter t1e name ' #ata element
8* Enter t1e #ata element re6uire# 'r screen 'iel# t 3e man#atr+ an# E.ecute
D* Ant1er screen cmes 4it1 a 'unctin m#ule name FIELD&EXIT&name ' #ata element
H* Clic2 create an# sa%e it t crres,n#in( 'unctin (ru,
E* Yu 4ill (et a 'unctin m#ule 4it1
im,rt ,arameter as $ IIPUT
e.,rt ,arameter as $ =UTPUT
J* In t1e surce c#e 4rite t1e c#e $'r %ali#atin
K*A(ain t acti%ate e.ecute transactin CM=D. T1en t+,e
PRF? in t1e cmman# 'iel#. n t1e t, menuGclic2 n Fiel#
e.it-AActi%ate
now wherever data element is used the mandatory chec( will
come $ut you need it only for your program .so in the same
screen clic( on Assign prog.Dscreen ta$ and write the name
of the program and screen num$er where you want the
particular chec(
0ption 6
3ou can also run the report .SM)D%.6 to create a field exit.
*or this example we will create a +-0JA- *ield exit. So it will validate "roduction version for
all the screen where1ever it is used.84ote ) will are going to use option 4o 6 to create this field
exit for this tutorial.9
Step1
+o to SE! and run program .SM)D%.6.
Enter the data element name as 1)S*0 + you can find out the data element name using *1 help
for that particular field) and "ress *!.
Step=+
/t will open the *unction $uilder screen with *M name ) */E-D@E:/,@M0S'E
8*/E-D@E:/,@Kdataelement2@Suffix9
Iust clic( on create $utton and create a *M with the following code)
8 4ote ) it will as( for *unction group name . 3ou can create your own *unction group and use it
here9
/f you chec( the /M"0F, and E:"0F, data you can see the /4"U, and 0U,"U,.it is nothing
$ut the value of the field.
i' in,ut ; RDC.
messa(e RDC t+,e is nt all4e# t+,e E.
en#i'.
Step >+
Activate this *unction module and clic( on $ac( $utton.
and execute the report .SM)D%.6 with out the dataelement and suffix.
/t will display the $elow list ) find out your exit
Select that entry and activate it using menu $ar */E-D E:/,% A',/&A,E
4ow it5s time to test itS
+o to MM06 enter any material name and select Jasic data 1.and enter production type as
FD'."ress Enter.

You might also like