Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Purchase Requisition BADI/User Exit

former_member125661
Contributor
0 Kudos

I am looking for an enhancement where I can change an item level field when a purchase requisition is saved. This should work for Me51/Me52/Me51n/Me52n transactions.

This should trigger upon 'SAVE' of purchase requisition.

Thanks in advance,

Shareen

1 ACCEPTED SOLUTION

Former Member

Shareen,

BADI ME_PROCESS_REQ_CUST provides methods that give a lot of flexibility for changes in ME51N / ME52N. Not sure if it also works for ME51 / ME52

Andrew

10 REPLIES 10

Former Member
0 Kudos

Use the Project MEREQ001 to add checks during save of a purchase Requisition.

FM: EXIT_SAPLMEREQ_010, Hope this helps.

Rajeev

0 Kudos

Perhaps you can do checks..But you cannot modify the purchase requisition line item in this user exit.

Former Member

Shareen,

BADI ME_PROCESS_REQ_CUST provides methods that give a lot of flexibility for changes in ME51N / ME52N. Not sure if it also works for ME51 / ME52

Andrew

0 Kudos

I checked a couple of methods there in the BADI - ME_PROCESS_REQ_CUST . I dont see any method that has exports EBAN structure to edit the purchase req. line item .

0 Kudos

Shareen,

The BADI exit allows modification of most PR fields.

A number of the parameters to each method are defined as "TYPE REF TO" ABAP objects, and if you drill down to these objects you see that they then have methods such as "GET_DATA" and "SET_DATA" to retrieve details and change them.

As an example, the following code for an implementation of method PROCESS_ITEM of ME_PROCESS_REQ_CUST changes the AFNAM field:


METHOD if_ex_me_process_req_cust~process_item.

  DATA: l_preq TYPE mereq_item.

  CALL METHOD IM_ITEM->get_data
    RECEIVING
      re_data = l_preq.

* Convert Requisitioner name to upper case
  TRANSLATE l_preq-afnam TO UPPER CASE.

  CALL METHOD IM_ITEM->set_data
    EXPORTING
      im_data = l_preq.

ENDMETHOD.

Thus, even though the original BADI has only importing parameters, it actually allows changes to the data.

The SAP example implementation CL_EXM_IM_ME_PROCESS_REQ_CUST appears to have very little example code - there is some information on how to present error messages in the OPEN method, but not much else.

The corresponding BADI (ME_PROCESS_PO_CUST) for Purchase Order transactions ME21N / ME22N is similar and has example code in method PROCESS_ITEM of CL_EXM_IM_ME_PROCESS_PO_CUST. This might help you.

You could also search SDN for previous posts on how this BADI works.

To create an implementation for the BADI use transaction SE19.

Andrew

0 Kudos

Thanks Andrew that helped. I was of the impression that I can only use standard export signatures inside a BADI implementation. Btw, I have a qn. How am i able to use

CALL METHOD IM_ITEM->get_data

RECEIVING

re_data = l_preq.

Where is this method being define ? How is the BADI pulling this data ? I am new to object oriented programming.

0 Kudos

Shareen,

BADI ME_PROCESS_REQ_CUST method PROCESS_ITEM has three parameters:

IM_ITEM Type Ref To IF_PURCHASE_REQUISITION_ITEM

IM_COUNT Type I OPTIONAL

IM_REF_ITEM Type Ref To IF_PURCHASE_REQUISITION_ITEM OPTIONAL

The call to the method IM_ITEM->get_data is a call to the method defined in interface IF_PURCHASE_REQUISITION_ITEM as per the definition of the first parameter. If you look at this object by drilling down or display it in SE24 you will see it has a lot of methods available, including some that are references to other objects such as IF_ACCT_CONTAINER_MM for account assignments.

In using the methods within the original BADI you will sometimes find you need to first call a method of the method parameter to return a value that may be a handle to another object that then has methods to return further data.

For example, in the HEADER method you may first call a method GET_ITEMS which returns a table of item handles, and then call a method GET_DATA inside a loop for each of the returned handles to get the actual line data.

Andrew

0 Kudos

Now, my requirement has changed. I want a BADI to trigger when a Purch Req is created from MRP. (MD50 transaction). I found some BADI's which are triggered. But none of them have methods or even type refs to other methods which are useful ? Can I call the prev BADI from this BADI ?

0 Kudos

I am not familiar with the MRP application, but a BADI is an add in specific to a program and thus cannot be used in another program,

A search in ECC6 of SAPMM61X (program for MD50) and its includes for "ENHANCEMENT" shows a large number of enhancement points in the code. It is possible some of these are in the form routines you need to modify. Code can be added via SE38 enhancement functionality.

If you are on an earlier version of SAP I am not sure what exits would be available. Search the code for "BADI", "CUSTOMER" or "EXIT" may help.

Andrew

0 Kudos

Andrew,

Great and Thanks for your response. It is really useful.

Regards

Badari