Field exit in sap abap with tutorial

Field exit in sap abap with tutorial

Read this article to know what is  FIELD EXIT and How to work with Field Exit ?

Author : Raj

Author's Website | Articles from Raj

Raj is an Application Developer focusing on Custom Development - particularly in the areas of ABAP ,WD4A , JAVA , APO , Enterprise services and PI Developer/consultant . He is also certified in ABAP and PI. Facebook

Suppose you want to put a validation on a particular field then you can use Field exit.

There are two types of field exits, Global and local.

Global Field EXIT (suffix 0)

Which is applicable for screens.

LOCAL Field EXIT: (with suffix 1-9 , A-Z)

Which is applicable to a particular screen (that means, if you want to create a validation for batch field in MSC1n only, the same validation will not be applicable for other screens like VL32N, MB1C etc.. )

Let’s take a simple example:

The requirement is to put a validation on field Production allocation in Basic data1 tab of Material Master.(See the below screen shot)

IT should give an error message when user enters the value ‘RDC’ in the Production Allocation field.

fieldexit_Req

You can create a field exit for such kind of requirements.

There are two ways to create field exit :

Option 1:

1) For field exits in R/3 4.6C, execute transaction CMOD. Then type PRFB in the command field.
2) On the top menu…click on Field exit-> create ->enter the name of data element
3) Enter the data element required for screen field to be mandatory and Execute
4) Another screen comes with a function module name FIELD_EXIT_name of data element
5) Click create and save it to corresponding function group
6) You will get a function module with
import parameter as : INPUT
export parameter as : OUTPUT
7) In the source code write the code :for validation
8)Again to activate execute transaction CMOD. Then type
PRFB in the command field. on the top menu…click on Field
exit->Activate

now wherever data element is used the mandatory check will

come but you need it only for your program ,so in the same

screen click on Assign prog./screen tab and write the name

of the program and screen number where you want the

particular check

Option 2

You can also run the report RSMODPRF to create a field exit.

For this example we will create a GLOBAL Field exit. So it will validate Production version for all the screen where-ever it is used.(Note : will are going to use option No 2 to create this field exit for this tutorial.)

Step1

Go to SE38 and run program RSMODPRF.

Enter the data element name as KOSCH : you can find out the data element name using F1 help for that particular field: and Press F8.

fieldexit_step1

Step2:

It will open the Function builder screen with FM name : FIELD_EXIT_KOSCH (FIELD_EXIT_<dataelement>_Suffix)

Just click on create button and create a FM with the following code:

( Note : it will ask for Function group name , You can create your own Function group and use it here)

If you check the IMPORT and EXPORT data you can see the INPUT and OUTPUT.it is nothing but the value of the field.

if input = ‘RDC’.
message ‘RDC type is not allowed’ type ‘E’.
endif
.

fieldexit_step2

Step 3:

Activate this Function module and click on back button.

and execute the report RSMODPRF with out the dataelement and suffix.

fieldexit_step3

It will display the below list : find out your exit

fieldexit_step3_1

Select that entry and activate it using menu bar FIELD EXITà ACTIVATE

Now it’s time to test it…

Go to MM02 enter any material name and select Basic data 1.and enter production type as RDC.Press Enter.

fieldexit_fin

Related Posts



Like this post? Share it!

  • Tweet
  • Facebook
  • Diggit
  • Delicious
  • Diggit
  • Diggit
  • Diggit
  • Diggit
  • Diggit

ADVERTISE HERE


User Comments


  1. Derek
    February 14, 2012

    What’s the date on this article? From what I have been reading, Field Exits were discontinued in 4.6D.
     
    Was wondering if anyone was using these as a part of an upgraded system.

    Reply


  2. Name
    April 16, 2012


  3. AC
    September 14, 2012

    Hi Raj,
    I tried this method and found error system is not configured for field exit..

    Reply


    • Raj
      September 15, 2012

      Hello AC ,

      To enable the field exit in ur system .

      Set the abap/fieldexit parameter to YES in the system profile and restart your SAP system.

      Thanks
      ~Raj
      SAP IGnite

      Reply


  4. Azhar
    September 17, 2012

    Thanks Man! Thanks for All the Tutorials.. :)
    they are real easy to grab and remember…the way you explain!

    Reply


  5. Badami
    December 20, 2012

    You are a Star

    Reply


  6. ram
    December 23, 2012

    very useful…….. thanks……………. :wink:

    Reply


  7. tom
    February 14, 2013

    thanks…was really helpfull

    Reply


  8. SIDDHARTHA
    March 4, 2013

    hi sir,
    My name is siddhartha,
    I have a doubt in enhancement , what is an enhancement and why we go for enhancement?
    What are the types of enhancement?
    In real-time scenario , which enhancement is usefull for us?Explain me with an example?
    Please help me for the above document?
     

    Reply


    • Raj
      March 6, 2013

      Hello
      Please check our enhancement section we have enough articles posted here which can answer your questions

      Thanks
      RAJ
      SAP IGnite

      Reply


  9. THANKS RAJ
    May 14, 2013

    THANKS BRO

    Reply

Leave a Reply

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!:
  Twitter Followers Email Updates