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: 

BAdI --> validations for purchase orders

Former Member
0 Kudos

Hi Gurus,

It's the first time I'm modifying a BAdI and I'm not sure how to do this.

I need to do a validation for copying of an existing order. If the user attempts to import a purchase order using the copy option and it has a quantity of '0' it is not allowed to be copied to the purchase order.

I have found the items in the method 'PROCESS_ITEM' of the class 'IF_EX_ME_PROCESS_PO_CUST' using the method 'im_item->get_data( ).' but I can't figure out how to stop it from assigning the positions to the purchase order and display an error message.

Tips anyone?

Simon

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Simon,

Try in CHECK method for same BADi. It is triggered when user presses save .

IF <Check for item qty>.

INCLUDE mm_messages_mac.

ch_failed = 'X'.

mmpur_message_forced 'E' 'ZMSGCLS' '000' ' ' ' ' ' ' ' '.

ENDIF. " IF w_avgquan ..

Regards,

Raju.

7 REPLIES 7

Former Member
0 Kudos

check the GET_DATA-MENGE <> 0 .

trigger u r error message

0 Kudos

put the condition

im_item~get_data->menge NE 0.

Former Member
0 Kudos

Hi Simon,

Try in CHECK method for same BADi. It is triggered when user presses save .

IF <Check for item qty>.

INCLUDE mm_messages_mac.

ch_failed = 'X'.

mmpur_message_forced 'E' 'ZMSGCLS' '000' ' ' ' ' ' ' ' '.

ENDIF. " IF w_avgquan ..

Regards,

Raju.

0 Kudos

No, this validation comes before the CHECK method.

I'm 99% sure i's in the PROCESS_ITEM method, well that's where the validation takes place but what I need to do is stop the data from the purchace order from arriving to the dynpro, I suppose it's in another standard process aside from the BAdI.

I'm not sure why they want this done because with the validation in the CHECK method we can stop it from being saved anyway. It seems to be that they wanna stop users from copying the orders and modifying them (if it has a quantity of 0 (MENGE)), they'll have to create it from scratch instead.

The best I have came up with so far is;

IF ls_mepoitem-menge LE 0.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

TITEL = 'ERROR'

textline1 =

'No es pot transferir una comanda que té la quantitat de 0'. "error message

leave to transaction 'ME21N'.

ENDIF.

But as you can see it's not really a feasable solution.

0 Kudos

use RAISE error_with_message. to stop the process.

CALL FUNCTION 'POPUP_TO_DECIDE_INFO'
        EXPORTING
          defaultoption = 'Y'
          textline1     = text-001
          textline2     = text-002
          titel         = 'Title'
        IMPORTING
          answer        = lv_answer.
*Based on user decision
      CASE lv_answer.
        WHEN 'A'.
          RAISE error_with_message. "<<stop
      ENDCASE.

0 Kudos

Thanks to everyone for the suggestions.

J@Y, your suggestion worked a treat. I couldn't get it to stop and display the message but I suppose it was quite obvious to use the Raise clause.

Thanks,

Simon

Former Member
0 Kudos

Oh no, I've just noticed a problem with this method. My validation is only supposed to work when an order is copied from the little window on the left, "Document overview". Is there any variable which would be flagged if P. orders are copied in this manner?