i want to use user exit for transaction ME51N i have found a user exit named MEREQ001 and there are around 10 different exits EXIT_SAPLMEREQ_001 to 10
but the problem is i want to have a check for plant with costcentre now thing is that i m getting plant in table IM_DATA_PERSISTENT of user exit EXIT_SAPLMEREQ_005
but i not getting costcentre anywhere can anyone plz help me out
if this is not possible than is there any other alternative by which i can apply check between plant and costcentre for transaction ME51N (purchase requistion)
Check the Enhancement : MEREQ001
You can use this enhancement to:
o Maintain/supply your own customer fields in purchase requisitions
o Update your own customer-specific tables
o Change standard fields to a limited extent
You add your customer fields, which should be saved in the database, to
the include CI_EBANDB (in table EBAN). You can also add customer fields
that you want to use during the program run to the include CI_EBANMEM
(in structure MEREQ_ITEM) These fields are not stored in database table
If you use the enhancement, you must create and generate screen 111 in
function group XM02 (even if the screen is not to be used).
You must flag the screen as a subscreen, The screen does not have to
contain fields but it must exist to prevent the program terminating.
The function exits described below communicate with the standard program
using object references. These references point to objects of type
if_purchase_requisition (for the purchase requisition header) or
if_purchase_requisition_item (for the purchase requisition item) Using
this interface, you can reach the purchase requisition data. You can
find out via the Workbench or the Class Builder (transaction SE24) which
methods are offered.
The screen is linked to the standard program via function modules.
There are function modules that:
o Provide your subscreen with data (export)
- EXIT_SAPLMEREQ_001 Export Data to Customer Subscreen for
- EXIT_SAPLMEREQ_002 Prepare Customer Subscreen for Requisition
(PAI Before Subscreen PAI)
o Get data from your subscreens (import)
- EXIT_SAPLMEREQ_003 Import Data from Customer Subscreen for
You can set or supply your own data fields in the PBO function modules.
You receive the current (possibly changed in comparison to the PBO call)
standard program data in the PAI function module.
You can return your fields to the standard program in the import
function modules. For this purpose, read the current status of the
purchase requisition object using the method get_data in a local
structure of type mereq_item. Now write the customer data in this
structure and reset the data in the purchase requisition object using
the method set_data.
You should note that function exits 001, 002, and 003 are determined for
dialog purposes only and are not headed for when creating purchase
requisitions using function modules or BAPIs. Do not issue any error
messages in these function modules either.
There is a separate function exit for verifying the customer fields
(EXIT_SAPLMEREQ_005 Checking Customer's Own Purchase Requisition Data
(Without Dialog)). The object reference, the new data, the data from the
last verification, and the database status of the purchase requisition
items are available to you here. Parameter IM-FULL_CHECK is set if the
user has chosen to update or check explicitly. Parameter
IM_ITEM_HAS_ERRORS informs you whether the purchase requisition item has
been classified by the standard program as containing errors.
The task of this function exit is to ensure the consistency of the
customer-specific fields. You can also change standard fields using the
public interface if_purchase_requisition_item. The fields listed in
structure MEREQ_ITEM_S_CUST_ALLOWED are available for changing.
You fill the return table EX_MESSAGES to issue the errors and warnings
to the standard program and the user. The fields TYPE, ID, NUMBER, and
MESSAGE_V1 thru MESSAGE_V4 are analyzed and added to the standard error
You have to set the return parameter EX_RECHECK_ITEM if you have changed
standard fields. The standard program checks the purchase requisition
item after exiting the function exit again. You should note that the
functions exits are chosen again when this is done. To avoid endless
loops, you should not set this parameter every time.
The purchase requisition is updated in two steps. In the first step
(PREPARE), the function exit EXIT_SAPLMEREQ_008 (Prepare for Update of
Customer's Own Purchase Requisition Data) is called up. The system tells
you the old (temporary) purchase requisition number and the new purchase
requisition number. In addition, the changes are given to tables EBAN
and EBKN. You can no longer change the fields here. You use this module
to prepare for updating your own data and tables. Do not execute any
database operations or call any function modules for the update (in
update task). Make a note of which data you want to update in your
function group. You should note that more than one purchase requisition
can be processed at the same time (for example, source of supply
assignment or collective release). This function exit is processed once
for each header in the purchase requisition.
The second step in the update process performs the database operations
or calls the update modules. Function exit EXIT_SAPLMEREQ_006 (Update of
Customer's Own Purchase Requisition Data for all PReqs Prepared). This
function exit is called up only once for all purchase requisitions that
have been changed. You now update the data that you noted in the first
When all purchase requisitions have been successfully updated, function
exit EXIT_SAPLMEREQ_004 (Reset Customer Data After Updating All Purchase
Requisitions (Without Dialog)). You reset the data for your function
If you want to read your own tables for this, you should use the
function module EXIT_SAPLMEREQ_007. This is called when the purchase
requisition is read from the database.
You receive the transaction type via the purchase requisition header.
The interface if_purchase_requsition_item provides a method,
GET_REQUISITION, that returns the purchase requisition header. Using
method GET_TRANSACTION_STATE for interface if_purchase_requisition, you
can determine the transaction type from field ex_document.