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: 

Which EXITS and BAdIs should i use for Blocking PO cancellation based on condition?

Former Member
0 Kudos

Hi,

I need to know which all EXIT(S) and BAdI(s) i need if i need the system to block PO and items

cancellation (deletion) if advance payment has been made for that PO.

Following points would really help:

1. EXIT/BAdI which is triggered at PBO and has i_ekko as input parameter.

2. EXIT/BAdI which would help me to cancel that PO.

I tried using

EXIT MM06E005 -> EXIT_SAPMM06E_013 &  EXIT_SAPMM06E_012(Function Module)->

INCLUDE ZXM06U44

For exporting PO Number to ABAP memory, but none of them triggers at PBO or while cancelling the PO.

In ZXM06U44 , wrote the following code, for exporting PO Number to ABAP memory:

EXPORT zebeln FROM i_ekko-ebeln TO MEMORY ID 'ZABC'.

Then in BAdI 'ME_ACTV_CANCEL_PO' -> CHECK_ACTIVITY, wrote this:

IF sy-tcode = 'ME22' OR sy-tcode = 'ME22N' OR sy-tcode = 'ME23' OR sy-tcode = 'ME23N' OR sy-tcode = 'ME29' OR sy-tcode = 'ME29N'.

TYPES: BEGIN OF IT_BSEG,

       EBELN TYPE BSEG-EBELN,

       BELNR TYPE BSEG-BELNR,

        GJAHR TYPE BSEG-GJAHR,

        END OF IT_BSEG,

        BEGIN OF IT_BKPF,

        BELNR TYPE BKPF-BELNR,

        GJAHR TYPE BKPF-GJAHR,

        BLART TYPE BKPF-BLART,

        END OF IT_BKPF.

DATA: GT_BSEG TYPE TABLE OF IT_BSEG,

       GS_BSEG TYPE IT_BSEG,

       GT_BKPF TYPE TABLE OF IT_BKPF,

       GS_BKPF TYPE IT_BKPF,

       VAR(1).

SELECT EBELN BELNR GJAHR FROM BSEG

   INTO TABLE GT_BSEG

   WHERE EBELN = yebeln.

   SELECT BELNR GJAHR BLART  from bkpf

     INTO TABLE GT_BKPF

     FOR ALL ENTRIES IN GT_BSEG

     WHERE BELNR = GT_BSEG-BELNR AND GJAHR = GT_BSEG-GJAHR.

   LOOP AT GT_Bkpf INTO GS_Bkpf.

     IF GS_bkpf-BLART = 'DP'.

       VAR = 'X'.

     ENDIF.

   ENDLOOP.

   IF VAR = 'X'.

     IS_ACTIVE = 1. "   IS_ACTIVE is standard export parameter.

   ENDIF.

ENDIF.

-> I chose this BAdI because the name kind of says that it is for cancelling PO "ME_ACTV_CANCEL_PO".

But when i put debugger on them, none of them are triggered.

Can someone tell me the exact BAdI(s) and EXITS i should be using here?

Thanks & Regards,

KS




1 ACCEPTED SOLUTION

Former Member
0 Kudos

Its finally done. Thanks all of you!!

Steps to do this:

1. Identify the BAdIs which you will need in following ways:

               a. SE24->cl_exithandler->[double click on] GET_INSTANCE.

               b.    Set a break point at CALL METHOD cl_exithandler=>get_class_name_by_interface

               c. Call your transaction, eg: ME23N. It will trigger this break-point. Check the value of  "EXIT_NAME". Or else execute SE37  with SXV_GET_CLIF_BY_NAME. ( As shown  in http://scn.sap.com/docs/DOC-33611  ) - I still dont know why in both the methods, we get   EXIT_NAME = ME_PROCESS_PO at the 1st go, but still actual BAdI  is ME_PROCESS_PO_CUST.

2. Now create an implementation for this BAdI in SE19 -> Create implementation -> Classic BAdI.

3.Go to SE18 -> In Enhancement Spot  give EXIT name -> execute-> On left side, drill down ME_PROCESS_PO_CUST (or whichever BAdI you are using ) and select "Implementations". Double click on YOUR "Enhancement Implementation". Make sure that "Implementation is active" checkbox is marked and that this implemenatation is active. Also check "Effect in Current Client"

4. Then based on your requirement edit the method in your BAdI implementation.

               - To know which method suits your requirement either google it or else, put BREAK-POINT in each method of your implementation and then see which method is getting triggered at the event you want. In my case i needed for delete button on header level. So for me the right method was "PROCESS_HEADER".

5. Write code for your method. For this requirement i just needed PO Number, so i put:

              

DATA:lmepoheader TYPE mepoheader.

data: itm_data type mepoitem.

DATA: lv_reslo TYPE ekpo-reslo.

DATA: it_items TYPE purchase_order_items,

         wa_items LIKE LINE OF it_items.

CALL METHOD im_header->get_data

RECEIVING

re_data = lmepoheader.

" Then used  lmepoheader-ebeln in condition for my requirement.

6. Now set a breakpoint in your method and call transaction to see if your BAdi implementation is working the way it should.

This link is also helpful:

http://dtwchan99.wordpress.com/2011/12/05/how-to-use-enhancement-spot/

Regards,

KS

23 REPLIES 23

GauthamV
Active Contributor
0 Kudos

Try Badi ME_PROCESS_PO_CUST.

Regards,

Gautham.

Former Member
0 Kudos

Hi

I tried using it, but im not getting how to really use it.

As much i can dig in, i suppose there are only 2 ways to do this:

1. Either save ebeln value from ME_PROCESS_PO_CUST->PROCESS_HEADER (or any other method of this BAdI) and import it to a BAdI which will cancel that PO itself, eg: ME_ACTV_CANCEL_PO

2.  Take the PO Number and check its document number  and check for condition and display the error message in same BAdI method.

But in  any case i need EBELN value. Which im not able to use in methods of this BAdI.


Or should i be following some other approach?

Thanks & Regards,

KS


0 Kudos

Hi

Gautham is right, but you need to use the method CHECK for displaying the error messages and in your method (HEADER or ITEM) you need coding as this (as a sample, I'll write for PROCESS_ITEM)

data: ls_mepoitem type mepoitem,
         l_ebeln type ekko-ebeln,
         ls_header type ref to if_purchase_order_mm,
         ls_data_header type mepoheader..

   ls_mepoitem = im_item->get_data( ).

   ls_header = im_item->get_header( ).
   ls_data_header = ls_header->get_data( ).

" Your coding, checks, modifications and so on

" save data

   im_item->set_data( ls_mepoitem ).

So, look for the proper fields for blocking the PO.

I hope this helps you

Regards

Eduardo

Former Member
0 Kudos

Hi Eduardo,

Thank-you so much, im almost there now. Made changes in PROCESS_ITEM and then based on conditions made changes in CHECK as you explained.

But its not triggering the debugger still. In ME22, i tried deleting/cancelling an item and then saved. Its still not going to debugger. I checked everything, its active.

Waiting for your reply. Is there anything else im suppose to check?

Thanks,

KS

0 Kudos

Hi KS

I believe I am aware what is the origin of confusion. This BADI is triggered only for Enjoy PO, ie, tcode ME21N or ME22N, not for ME21 or ME22.

Regards

Eduardo

0 Kudos

Hi,

pls check the proper user exit or badi.

for user exits we have to check input & output parameters.

coming to badi , for finding a badi 2 methods are there.

1) goto class exithandler in that put a break point at  "get instance" method

2) by using package.

after  find out the badi , while debugging time check what and all parameters are there in global definition. we can use those global parameters. by using those we have to do our manipulation work.

next in that exit or badi write ur code like for that PO num any payment happened or not (how u 'll check . tis ur que. 2 methods arr there one is by using select queries or check any function module is there for checking the payment happen or not).

if payment happens then block the PO(as per ur req. u can put blocking code or wt ever.)


if payment not happen ten cancel directly.


Thanks in advance,

Krishna

Former Member
0 Kudos

Yes

i had put debugger in CL_EXITHANDLER->GET_INSTANCE. And then i executed ME22.

Badi me_process_po_cust, as you and Gautham suggested. And i am running ME22 after setting debugger in methods for this BAdI and dont see it getting triggered. Everything is active.

Hope im not missing anything.

Thankyou,

KS

0 Kudos

Hi

Go to tcode SE18, see the badi ME_PROCESS_PO_CUST and read the documentation, as it says, it only works for tcodes ME21N, ME22N, ME23N, and ME29N and for BAPI's BAPI_PO_CREATE1 and BAPI_PO_CHANGE.

Regards

Eduardo

Former Member
0 Kudos

Eduardo,

Thankyou for all your replies. Really thankyou. My debugger is not getting triggered for me22n as well   If there was something wrong with the code logic for cancellation i could have checked if atleast it triggers that debugger, but it ant triggering it. Well. I dont know.

Thankyou for your replies though.

Regards,

KS

0 Kudos

whether the badi is active mod or  not..

Former Member
0 Kudos

0 Kudos

Hi

This note refers to other problem in an industry solution. Note suggest to do as I show you in the next screenshot

and if it appears the mentioned implementation, then delete it.

But I believe it is not related with your issue.

Please, check in tcode SE19 if all objects are active.

Regards

Eduardo

Former Member
0 Kudos

Hi Eduardo Hinojosa,

I need to clarify few stuffs on this point:

-> I checked SAP R3 4.7 for this BAdI implementation (ME_PROCESS_PO_CUST) and there were no implementations (none - neither z/y implementation nor standard implementation).

-> So i created an implemenatation for this BAdI and put a debugger in 1 of its method - PROCESS_ITEM.

-> Then i executed ME22N and it TRIGGERED THIS METHOD. Which means that this BAdI will work.

-> But in current R3 6.0, there is a non-z/y (standard implementation - CON_FIN_SUBCONTRACT), which is not editable.

So what should i do?

-> Should i delete this Implementation so that my y/z implementation will automatically get triggered

OR

-> Is there a method to deactivate or close the switch kind of mechanism to this BAdI implementation (CON_FIN_SUBCONTRACT).

Thankyou for your help and waiting for reply.

Regards,

KS

Former Member
0 Kudos

enhancement's and badi's

find and use which suits your requirement.

Enhancement

MRFLB001                                Control Items for Contract Release Order

MMFAB001                                User exit for generation of release order

MMDA0001                                Default delivery addresses

MMAL0004                                ALE purchasing info record distribution: Inbound processing

MMAL0003                                ALE purcasing info record distribution: Outbound processing

MMAL0002                                ALE source list distribution: Inbound processing

MMAL0001                                ALE source list distribution: Outbound processing

MM06E010                                Field selection for vendor address

MM06E009                                Relevant texts for "Texts exist" indicator

MM06E008                                Monitoring of contr. target value in case of release orders

MM06E007                                Change document for requisitions upon conversion into PO

MM06E005                                Customer fields in purchasing document

MM06E004                                Control import data screens in purchase order

MM06E003                                Number range and document number

MM06E001                                User exits for EDI inbound and outbound purchasing documents

MEVME001                                WE default quantity calc. and over/ underdelivery tolerance

MEQUERY1                                Enhancement to Document Overview ME21N/ME51N

MELAB001                                Gen. forecast delivery schedules: Transfer schedule implem.

AMPL0001                                User subscreen for additional data on AMPL

LMEDR001                                Enhancements to print program

LMELA002                                Adopt batch no. from shipping notification when posting a GR

LMELA010                                Inbound shipping notification: Transfer item data from IDOC

LMEQR001                                User exit for source determination

LMEXF001                                Conditions in Purchasing Documents Without Invoice Receipt

LWSUS001                                Customer-Specific Source Determination in Retail

M06B0001                                Role determination for purchase requisition release

M06B0002                                Changes to comm. structure for purchase requisition release

M06B0003                                Number range and document number

M06B0004                                Number range and document number

M06B0005                                Changes to comm. structure for overall release of requisn.

M06E0004                                Changes to communication structure for release purch. doc.

M06E0005                                Role determination for release of purchasing documents

ME590001                                Grouping of requsitions for PO split in ME59

MEETA001                                Define schedule line type (backlog, immed. req., preview)

MEFLD004                                Determine earliest delivery date f. check w. GR (only PO)

Business Add-in

ME_DP_CLEARING                          Clearing (Offsetting) of Down Payments and Payment Requests

ME_FIELDSTATUS_STOCK                    FM Account Assignment Behavior for Stock PR/PO

ME_GUI_PO_CUST                          Customer's Own Screens in Enjoy Purchase Order

ME_HOLD_PO                              BAdI: Deactivation of 'Hold'/'Park' in Enjoy Purchase Order

ME_INFOREC_SEND                         Capture/Send Purchase Info Record Changes - Internal Use

ME_PO_PRICING                           Enhancements to Price Determination: Internal

ME_PO_PRICING_CUST                      Enhancements to Price Determination: Customer

ME_PO_SC_SRV                            BAdI: Service Tab Page for Subcontracting

ME_PROCESS_COMP                         Processing of Component Default Data at Time of GR: Customer

ME_PROCESS_PO                           Enhancements for Processing Enjoy Purchase Order: Intern.

ME_PROCESS_PO_CUST                      Enhancements for Purchase Order Processing: Customer

ME_PROCESS_REQ                          Enhancements for Processing Enjoy PReqs: Internal

ME_PROCESS_REQ_CUST                     Enhancements for Processing Enjoy PReqs: Customer

ME_PURCHDOC_POSTED                      Purchasing Document Posted

ME_RELEASE_CREATE                       BAdI: Release Creation for Sched.Agrmts with Release Docu.

ME_REQ_OI_EXT                           Commitment Update in the Case of External Requisitions

ME_REQ_POSTED                           Purchase Requisition Posted

ME_TAX_FROM_ADDRESS                     Tax jurisdiction code taken from address

ME_TRF_RULE_CUST_OFF                    BADI for Deactivation of Field T161V-REVFE

ME_TRIGGER_ATP                          Triggers New ATP for Changes in EKKO, EKPO, EKPV

ME_WRF_STD_DNG                          PO Controlling Reminder: Extension to Standard Reminder

SMOD_MRFLB001                           Control Items for Release Creation

MM_DELIVERY_ADDR_SAP                    Determination of Delivery Address

MM_EDI_DESADV_IN                        Supplementation of Delivery Interface from Purchase Order

ARC_MM_EKKO_CHECK                       BAdI: Enhancement of Archivability Check (MM_EKKO)

ARC_MM_EKKO_WRITE                       BAdI: Enhancement of Scope of Archiving (MM_EKKO)

EXTENSION_US_TAXES                      Extended Tax Calculation with Additional Data

ME_DEFINE_CALCTYPE                      Control of Pricing Type: Additional Fields

MEGUI_LAYOUT                            BAdI for Enjoy Purchasing GUI

ME_ACTV_CANCEL_PO                       BAdI for Activating the Cancel Function at Header Level

ME_BADI_DISPLAY_DOC                     BAdI for Internal Control of Transaction to be Invoked

ME_BAPI_PO_CREATE_01

ME_BAPI_PO_CREATE_02

ME_BAPI_PR_CREATE_01

ME_BAPI_PR_CREATE_02

ME_BSART_DET                            Change document type for automatically generated POs

ME_CCP_ACTIVE_CHECK                     BAdI to check whether CCP process is active

ME_CCP_BESWK_AUTH_CH                    BAdI for authorization checks for procuring plant

ME_CCP_DEL_DURATION                     Calc. of Delivery Duration in CCP Process (Not in Standard)

ME_CHANGE_CHARACTER                     Customer-Specific Characteristics for Product Allocation

ME_CHANGE_OUTTAB                        Enrich ALV Output Table in Purchasing

ME_CHECK_ALL_ITEMS                      Run Through Items Again in the Event of Changes in EKKO

ME_CHECK_OA                             Check BAdI for Contracts

ME_CHECK_SOURCES                        Additional Checks in Source Determination/Checking

ME_CIN_LEINRF2R                         BADI for CIN India - Delivery charges

ME_CIN_LEINRF2V                         BADI for LEINRF03 excise_invoice_details

ME_CIN_MM06EFKO                         Copy PO data for use by Country version India

ME_CIP_ALLOW_CHANGE                     Configuration in Purchasing: Changeability Control

ME_CIP_ALLOW_CHANGE                     Configuration in Purchasing: Changeability Control

ME_CIP_REF_CHAR                         Enables Reference Characteristics in Purchasing

ME_COMMITMENT_RETURN                    Commitment for return item

ME_COMMITMENT_STO_CH                    BadI for checking if commitments for STOs are active

ME_COMMTMNT_PO_RELEV                    Check for Commitment-Relevance of Purchase Orders

ME_COMMTMNT_PO_REL_C                    Check for Commitment-Relevance of Purchase Orders

ME_COMMTMNT_REQ_RELE                    Check of Commitment Relevance of Purchase Requisitions

ME_COMMTMNT_REQ_RE_C                    Check of Commitment Relevance of Purchase Requisitions

0 Kudos

thanks Nilesh,

But just for those who want to know how this list is populated:

1. go to the transaction for which you need to find BAdI (eg: ME22)

2. System -> status->Program (GUI)->Goto->Attributes-> copy Package (For mE22, its 'ME')

3. SE84->Enhancements->Business Add-ins ->Definitions-> Paste the copied package name (ME) for field-label 'Package' on right side-> Execute-> and we have the list of BAdIs for that transaction populated.

Regards,

KS

krishna_k19
Contributor
0 Kudos

check whether the badi is active or not

Former Member
0 Kudos

Thankyou everyone!!!

Its not working but its because the basic settings for this BAdI - its does not support multiple use.

And the standard implementation is not  editable. So i guess, i will have to go with

ZME_PROCESS_PO_CUST ~post.

Similar problem discussion in this post (ME_PROCESS_PO_CUST  does not trigger.) :

http://scn.sap.com/thread/1363372

Ill try this and then update.

Thanks & Regards,

KS

Former Member
0 Kudos

hi,

tyy to user badi ME_PURCHDOC_POSTED method : posted

0 Kudos

Hi

I created an implemenatton for this BAdI as you said. Activated implementation and its method. Set break-point and then executed ME22n for a PO number. Then tried to delete an item but its not triggering that breakk-point.  This BAdI is multiple use, so is there anything i need to do to get it triggered on deletion/cancellation.

Regards,

KS

Former Member
0 Kudos

Hi,

Its working.

Just followed poornima v's instruction from thread https://scn.sap.com/thread/2048066:

" In SE18 give ME_PROCESS_PO_CUST as the enhancement spot and display. At the left side of the screen you can see the badi definition ME_PROCESS_PO_CUST. Expand the tree and double click on implementations. You can see the enhance implementations created. Double click on the enhancement implementation and in that screen there is a check box 'Implementation is active' and field 'Effect in current client'.

If you know the enhancement implementation name(not the badi implementation name), you can check it directly from se19."

Regards,

KS

Venkat_Sesha
Advisor
Advisor
0 Kudos

HI KS,

Please check the below document which I have written for find a BADI in a Easy way.

It is as simple as that. For every operation you perform you will find a BADI name.

http://scn.sap.com/docs/DOC-33611

I hope this will be very informative for you to find the relevant badis you need.

Thanks,

Bhargav.

0 Kudos

Thankyou.

Former Member
0 Kudos

Its finally done. Thanks all of you!!

Steps to do this:

1. Identify the BAdIs which you will need in following ways:

               a. SE24->cl_exithandler->[double click on] GET_INSTANCE.

               b.    Set a break point at CALL METHOD cl_exithandler=>get_class_name_by_interface

               c. Call your transaction, eg: ME23N. It will trigger this break-point. Check the value of  "EXIT_NAME". Or else execute SE37  with SXV_GET_CLIF_BY_NAME. ( As shown  in http://scn.sap.com/docs/DOC-33611  ) - I still dont know why in both the methods, we get   EXIT_NAME = ME_PROCESS_PO at the 1st go, but still actual BAdI  is ME_PROCESS_PO_CUST.

2. Now create an implementation for this BAdI in SE19 -> Create implementation -> Classic BAdI.

3.Go to SE18 -> In Enhancement Spot  give EXIT name -> execute-> On left side, drill down ME_PROCESS_PO_CUST (or whichever BAdI you are using ) and select "Implementations". Double click on YOUR "Enhancement Implementation". Make sure that "Implementation is active" checkbox is marked and that this implemenatation is active. Also check "Effect in Current Client"

4. Then based on your requirement edit the method in your BAdI implementation.

               - To know which method suits your requirement either google it or else, put BREAK-POINT in each method of your implementation and then see which method is getting triggered at the event you want. In my case i needed for delete button on header level. So for me the right method was "PROCESS_HEADER".

5. Write code for your method. For this requirement i just needed PO Number, so i put:

              

DATA:lmepoheader TYPE mepoheader.

data: itm_data type mepoitem.

DATA: lv_reslo TYPE ekpo-reslo.

DATA: it_items TYPE purchase_order_items,

         wa_items LIKE LINE OF it_items.

CALL METHOD im_header->get_data

RECEIVING

re_data = lmepoheader.

" Then used  lmepoheader-ebeln in condition for my requirement.

6. Now set a breakpoint in your method and call transaction to see if your BAdi implementation is working the way it should.

This link is also helpful:

http://dtwchan99.wordpress.com/2011/12/05/how-to-use-enhancement-spot/

Regards,

KS