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 Order amount validation.

former_member605939
Participant
0 Kudos

My requirement is to apply the po amount check validation. User cannot able to create the Po with amount more than 2 lakh. If the user try to create the po with 2 lakh system throw a message .

Is it feasible using user exit or badi or any other way ?

Thanks

10 REPLIES 10

SimoneMilesi
Active Contributor
0 Kudos

There are plenty of similar questions and blogs too on the topic, you just need to google "SAP PO BADI CHECK" and you'll find them, like this one

raymond_giuseppi
Active Contributor
0 Kudos

Look at the multiple threads/questions suggesting BAdI ME_PROCESS_PO_CUST.

You can use method CHECK which allows error message and is always executed before save, you could also use method PROCESS_ITEM if you want to raise the error as soon as the user override the amount limit. In both case get list of items and sum their amount.

NB: Usually this kind of check is part of the Purchase Order Release Strategy

0 Kudos

I checked the BAdI ME_PROCESS_PO_CUST with method IF_EX_ME_PROCESS_PO_CUST~CHECK. In this case find out the following

CALL METHOD im_header->get_items

RECEIVING

re_items = lt_items.

LOOP AT lt_items INTO ls_item.

CALL METHOD ls_item-item->get_data

RECEIVING

re_data = ls_item_data.

CALL METHOD lo_po_doc->get_tkomv

IMPORTING

ex_tkomv = lt_conditions.

SORT lt_conditions BY kschl.

collected the line item wise data. Now need to write the logic based on lt_conditions table using kschl.

Is it right way to do the processing.

similarly if i am using exit EXIT_SAPMM06E_017. the following structures are updated

TEKPO STRUCTURE BEKPO OPTIONAL

TEKET STRUCTURE BEKET OPTIONAL

TEKKN STRUCTURE EKKNU OPTIONAL

TKOMV STRUCTURE KOMV OPTIONAL

need to do the calculations based on po line item and komv .

Is it right way to do the processing.

Is there any other way that can i get the total amount (directly no need to do calculations ) and trigger a message based on amount. Like it is populating in the PO Header conditions Total Value 1905.92

I want to capture the Total Value 1905.92 and trigger the message .

0 Kudos

Try to read in CHECK or PROCESS_HEADER the conditions at header level using GET_CONDITIONS on IM_HEADER

0 Kudos

Hi raymond.giuseppi

Thank you.

I checked the IF_EX_ME_PROCESS_PO_CUST~CHECK and IF_EX_ME_PROCESS_PO_CUST~POST. It is working fine for TCODE :ME21N/ME22N but the BADI is not triggering for T-CODE :ME21/ME22 .Is this badi for Enjoy transactions only ?

My requirement is getting fulfilled for ME21N AND ME22N.

0 Kudos

Yes this BAdI is only for Enjoy transactions.

NB: The old transactions are now obsolete from some time (1803189 - FAQ: End of Support of ME21, ME51, BAPI_PO_CREATE and Archiving Reports etc. - '... from April 2013 onwards ...')

The question is 'why these old transactions are still active in your systems', do users really need them or are some old BDC programs still active and have not yet migrated to BAPI processing?

NB: Even if you try to use an 'old' customer exit such as MM06E005, the behavior of the old transactions can (and will, Murphy's Law) differ from that of the Enjoy transactions, you may have to process some customer screens for customer fields and the like, and you will have some difficulties maintaining the exit to perform well for both versions (9 years difference).

aoyang
Contributor
0 Kudos

Alternatively, you can use customer exit MM06E005. Implement a project and put below code in EXIT_SAPMM06E_017 component, inside include ZXM06U42. You can add the logic to check currency if you want(assuming lakh is currency expression in INR).

  IF I_EKPO-NETWR > 'Your amount limit'.
MESSAGE 'Item amount not allowed. Please correct the net price or quantity' TYPE 'E'.
ENDIF.

0 Kudos

EXIT_SAPMM06E_017. used the structures

TEKPO STRUCTURE BEKPO OPTIONAL

TEKET STRUCTURE BEKET OPTIONAL

TEKKN STRUCTURE EKKNU OPTIONAL

TKOMV STRUCTURE KOMV OPTIONAL

need to do the calculations based on po line item and komv . If po has multiple line items need to loop at line item and prosess the TKOMV table.

Is it right way to do the processing.

Is there any other way that can i get the total amount (directly no need to do calculations ) and trigger a message based on amount. Like it is populating in the PO Header conditions Total Value 1905.92

0 Kudos

abaplearner I see that you want to capture 1905.92 of condition type(Total Value) on PO header, not PO item.

Then the easiest is to implement exit in EXIT_SAPMM06E_012(same in MM06E005). This exit will be triggered when you save the PO.

Below is a sample code and it's working for me. The error message will be prompted if the amount exceeds and prevent user from saving.

  READ TABLE TKOMV ASSIGNING FIELD-SYMBOL(<LS_TKOMV>)
WITH KEY
KSCHL = 'Your condition type'. "Search for total amount

IF SY-SUBRC = 0.
IF <LS_TKOMV>-KAWRT > '20000000'.
MESSAGE 'Item amount not allowed. Please correct the net price or quantity' TYPE 'E'.
ENDIF.
ENDIF.

0 Kudos

HI aocheng

I implemented the EXIT_SAPMM06E_012(same in MM06E005). it is working fine for ME21N/ME22N but but for ME21/ME22 it is giving dump.

The system attempted to use dynpro 0111 in program "SAPLXM06".

This dynpro does not exist.

"DYNPRO_NOT_FOUND" " "

"SAPLXM06" or "MM06EO0C_CUSTSCR1_ITEM_SET_DAT"

"EXIT_SAPMM06E_006"