03-31-2009 1:01 PM
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
03-31-2009 1:37 PM
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.
03-31-2009 1:20 PM
03-31-2009 1:22 PM
03-31-2009 1:37 PM
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.
03-31-2009 5:49 PM
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.
03-31-2009 6:07 PM
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.
04-01-2009 11:49 AM
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
04-06-2009 8:39 AM
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?