field exits

33
1 SAP-Field Exits

Upload: api-3738703

Post on 11-Apr-2015

1.321 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Field Exits

1

SAP-Field Exits

Page 2: Field Exits

2

Definition – Field Exits

• Field exits are branches from a screen field with a data element reference into a function module. Field exits can be selected globally or selectively.

Page 3: Field Exits

3

• When to apply a Field Exit.• Create a Field Exit.

Objectives

Page 4: Field Exits

4

Field Exits

Field Exits

EntryEntry

Function module

Obligatoryfield checks

checks andField formatchecks and

field transportForeign

key checks

System Help

SAP R/3 SAP R/3

Field 1

Field 2

ABAP Dictionary

Page 5: Field Exits

5

Creating Field Exits

R

Creating Field Exits

Global enhancements 1 1

Create field exit 2 2

Create function module 4 4

Field exit for data element ...? 3 3

Activate function module 6 6

Assign program/screen (for local field exits only)

7 7

Activate field exit 8 8

Edit function module 5 5

System Help

Function Builder Function Builder

FIELD_EXIT_DTEL

Function module

System Help

Function module: Function module: Interface Interface

INPUT

Import parameter

OUTPUT

Export parameter

Page 6: Field Exits

6

Field Exits are branches from a screen field with data

element reference in a function module.

They are of 2 types – Global Field Exits– Local Field Exits.

Types of Filed Exits

Page 7: Field Exits

7

• Global Field Exits are not limited to one screen. If you use the data element on multiple screens, you will branch to a function module from all these screens once the exit is activated.

Global Field Exits

Page 8: Field Exits

8

• Local field exits are valid for one screen only. If you assign the screen of a specific program to the data element, then you will branch to a function module only from this screen after activation.

Local Field Exits

Page 9: Field Exits

9

• Prefix : FIELD_EXIT_• Name : <Data element name>_• Suffix (optional) : 0 to 9, A to Z

Syntax

Page 10: Field Exits

10

Data Entry

Check Required Fields

Check Field Format

Your Function Module Fires Here

Foreign Keys

When does it Trigger

Page 11: Field Exits

11

• We will create a field exit for data element ‘MATNR’.

• We will create a ‘Global Field Exit’. In which we will restrict users from entering a Material No ASD123.

• In the second instance we will create a ‘Local Field Exit’ so that it triggers only when the material no is 300 and check it using examples 1 & 2. And the filed exit should fire only in the second example.

Example

Page 12: Field Exits

12

Data element Matnr

Program : SAPLMGMM , Screen No. : 0060

Note : You can also use ‘MM02’ or ‘MM03’ transaction.

Example 1

Page 13: Field Exits

13

Data element Matnr

Program : SAPMM03Z

Screen No. : 0100

Example 2

Page 14: Field Exits

14

Creating Global Field Exits

• Global Field Exits ….step 1

Run the program using SE38

Page 15: Field Exits

15

Creating a Global Field Exit… step 2

Give your Data elements which you want to create a Field Exit

Page 16: Field Exits

16

Creating a Global Field Exit… 3

This will take you to SE37 transaction with a function module name by default

Just say Create

Page 17: Field Exits

17

Creating a Global Field Exit… 4

Write the code and generate it

And go back

Page 18: Field Exits

18

Creating a Global Field Exit… 5

Select the Data Element and say Activate

Page 19: Field Exits

19

Creating a Global Field Exit… 6

It will ask u for a

transport request

Just create it and say continue

Page 20: Field Exits

20

Creating a Global Field Exit…. 7

You have now created

a

GLOBAL FIELD EXIT

Page 21: Field Exits

21

Check the Global Field Exit…1

• Run the transactions ‘MM01’, ‘MM02’, ‘MM03’ or ‘MMAM’

It should not allow Material No ASD123 in the screens.

Page 22: Field Exits

22

Check the Global Field Exit…….2

We will check using transaction ‘MM02’.

i.e example 1.

Page 23: Field Exits

23

Check the Global Field Exit…….3

Enter Material no ASD123 press enter

you should see an error message here

Page 24: Field Exits

24

Creating a Local Field Exit

Select the Global Field

Exit you have created and then select

Assign prog / screen

Creating a Local Field Exit…….1

Page 25: Field Exits

25

Creating a Local Field Exit…….2

YOU GET A POPUP SCREEN

Enter the <Screen name> <screen no> and <fld.exit> that is

from A to Z or 0-9

And say continue

Page 26: Field Exits

26

Creating a Local Field Exit…….3

It will take you to the se37 screen with default function module name

Just say create

(this will not appear if the function mod already exists)

Page 27: Field Exits

27

Creating a Local Field Exit…….4

Write the code activate it.

Then go back to field exit screen.You will be asked for

a Transport Request just create the request and say

continue

Page 28: Field Exits

28

Creating a Local Field Exit…….5

You will see the program name and screen number appearing in the same line as the data element

Just select it and say activate

Your Local Field exit is complete

Page 29: Field Exits

29

Check the Local Field Exit…….1

We will check using transaction ‘MMAM’.

i.e example 2.

Page 30: Field Exits

30

Check the Local Field Exit……..2

Enter Material No =300 and material type then press Enter

You should see an error message here

Page 31: Field Exits

31

Check the Local Field Exit…….3

We will check using transaction ‘MM02’.

i.e example 1.

Page 32: Field Exits

32

Check the Local Field Exit…….4

Enter Material No 300 and press Enter

If the material is already created it show that material details or a error message other than the error message we have given should be shown here

Page 33: Field Exits

33

Thank You