Sunteți pe pagina 1din 12

Working with User-Exits

By Santosh L.Ghonasgi, CAPGemini India

Enter the transaction VA01.

Go to menu System and select sub item status.


We will get the name of the program as (SAPMV45A).

Now go to SE38 Editor and type the program name as SAPM45A.


And select subobjects - attributes radio button and press Display.

Note the package name. In this case, it is VA


Now go to SMOD Transaction (SMOD is used to find the enhancements and user exits.)

Here if we enter the enhancement name it results the list of user exit names.
But we dont known the Enhancement name so press the Utilities > Find menu option.

Press Execute

In the above enhancements our program name SAPMV45A Matches four enhancements.
So, In the below enhancements we have to check the right one.

V45A0001
V45A0002
V45A0003
V45A0004

- Determine alternative materials for product selection


- Predefine sold-to party in sales document
- Collector for customer function module pool MV45A
- Copy packing proposal into outbound Delivery.

Click here to continue..


My Analysis :
Every Function Module for Enhancement supplies some Import and Export Parameters.
Through which we get some values.
V45A0001 The Description of this enhancement tell us that it determines the alternative materials for
product selection. (i.e., If one material is not available what is the other material that has to be used as
an alternative. So it is item specific).
FUNCTION
EXIT_SAPFV45S_001.
*"---------------------------------------------------------------------*"*"Lokale
Schnittstelle:
*"
IMPORTING
*"
VALUE(REQUESTED_DELIVERY_DATE)
LIKE
VBAK-VDATU
*"
VALUE(ENTERED_MATERIAL)
LIKE
VBAP-MATNR
*"
VALUE(REQUESTED_DELIVERY_QUANTITY)
LIKE
VBAP-KWMENG
*"
VALUE(SALES_UNIT)
LIKE
VBAP-VRKME
OPTIONAL
*"
VALUE(DELIVERED_QUANTITY)
LIKE
VBAP-KLMENG
OPTIONAL
*"
VALUE(DELIVERING_PLANT)
LIKE
VBAP-WERKS
OPTIONAL
*"
VALUE(STORAGE_LOCATION) LIKE VBAP-LGORT OPTIONAL
If we observe the Importing parameters
1.

There is no way to get VBAK EBELN (Sales Order No.) and other header data form VBAK.

So, this user exit is not useful.


V45A0002 - By Description we understand that we can predefine sold-to party in the sales document.
(i.e., it is used to populate the field sold-to party through user-exit while entering the data. ) But our
requirement comes after entering the data in the screen and save button is pressed.
FUNCTION
*"---------------------------------------------------------------------*"*"Lokale
*"
*"
VALUE(I_TVAK)
LIKE
*"
VALUE(I_TVTA)
LIKE
*"
VALUE(I_VKGRP)
*"
VALUE(I_VKBUR) LIKE VBAK-VKBUR
And even the importing parameters are not useful for us.

EXIT_SAPMV45A_002.

TVAK
TVTA
LIKE

Schnittstelle:
IMPORTING
STRUCTURE
TVAK
STRUCTURE
TVTA
VBAK-VKGRP

V45A0004 - Copy packing proposal Into Out bound delivery. This description implies that whenever we
create a Delivery Order from Sales Order it copies the packing proposal Based on the already created
Sales order. So, there is no chance for us to save the data while we create or change a Sales
order.

V45A0003 - Collector for customer function module pool MV45A - This description some what looks
good . But description there is no functionality mentioned. So, let us drill down.
We have 2 exits.
Function module

Short Text

EXIT_SAPMV45A_003

Rev.Rec.: Copy Requirements An Header

EXIT_SAPMV45A_004

Rev.Rec.: Field Modification Sales

FUNCTION
*"---------------------------------------------------------------------*"*"Lokale
*"
*"
VALUE(I_SCREEN_NAME)
*"
VALUE(I_VBAP)
LIKE
VBAP
*"
VALUE(I_VBUP)
LIKE
VBUPVB
*"
VALUE(I_SCREEN_GROUP4)
*"
VALUE(I_T180_AKTYP) LIKE T180-AKTYP

EXIT_SAPMV45A_004.

LIKE
STRUCTURE
STRUCTURE
LIKE

Schnittstelle:
IMPORTING
FELD-NAME
VBAP
VBUPVB
FELD-GRP4

From Exit 004 Description and Importing parameters we can clearly see that this exit is used for Field
modifications.
EXIT_SAPMV45A_003 - From the Description and Importing parameters we get the header data that can
be used for our requirement.
FUNCTION
*"---------------------------------------------------------------------*"*"Lokale
*"
*"
VALUE(XVBAK)
LIKE
VBAK
*"
VALUE(XVBUK)
LIKE
VBUK
*" VALUE(XKOMK) LIKE KOMK STRUCTURE KOMK

EXIT_SAPMV45A_003.

STRUCTURE
STRUCTURE

Schnittstelle:
IMPORTING
VBAK
VBUK

The purpose of SMOD is to find User Exits.


Once we find the user exits, We go to CMOD. The purpose of the CMOD is to register what we are going
to do in the particular enhancement. So, at the time of up gradation it will be easy to retain the code.

click on Create.
Now in the next screen (see below), click on Save and then on Enhancement assignments)

Now enter your enhancement name, click on Save and then on Components

Now double click on the required function exit

data:

gt_exit
gs_vbeln

type
TYPE

zexit,
zexit-vbeln,

gs_inr
gs_loc type vbak-waerk value 'INR'.
CALL

MESSAGE

ID
WITH

TYPE

vbak-netwr,

FUNCTION

'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT
=
SY-MANDT
date
=
sy-datum
foreign_amount
=
xvbak-netwr
foreign_currency
=
xvbak-waerk
local_currency
=
gs_loc
RATE
=
0
TYPE_OF_RATE
=
'M'
READ_TCURR
=
'X'
IMPORTING
EXCHANGE_RATE
=
FOREIGN_FACTOR
=
LOCAL_AMOUNT
=
gs_inr
LOCAL_FACTOR
=
EXCHANGE_RATEX
=
FIXED_RATE
=
DERIVED_RATE_TYPE
=
EXCEPTIONS
NO_RATE_FOUND
=
1
OVERFLOW
=
2
NO_FACTORS_FOUND
=
3
NO_SPREAD_FOUND
=
4
DERIVED_2_TIMES
=
5
OTHERS
=
6
.
IF
sy-subrc
<>
0.
SY-MSGID
TYPE
SY-MSGTY
NUMBER
SY-MSGNO
SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4.

ENDIF.
if
gt_exit-zstatus

gs_inr

gs_inr
gs_inr
gt_exit-zstatus

>

>
'High

'100'
<
=

gs_inr
gt_exit-zstatus
endif.

'Normal
<

'Low

gt_exit-vbeln
gt_exit-vkorg
gt_exit-vtweg
gt_exit-spart = xvbak-spart.
insert
clear gt_exit.

into

=
=
=

zexit

'1000'.
Value'.
elseif
and
'1000'.
Value'.
elseif
'100'.
Value'.

xvbak-vbeln.
xvbak-vkorg.
xvbak-vtweg.

values

gt_exit.

S-ar putea să vă placă și