Skip to Content
Former Member
Feb 26, 2012 at 12:50 PM

Reg: Raising an error message for ME52N transaction using user Exit


Dear Experts,

I have a requirement, I need to validate the total valuated amount entered in PR, If the amount is exceeded, it should not allow to create a purchase requisition.

It should raise an exception, saying the budget is exceeded, then user should be there in the current transaction to edit the amount and then finally create the PR.

I got the exit, EXIT_SAPLMEREQ_010, I have written a piece of code

 DATA: l_msg TYPE symsgv,
      wa_eban TYPE eban,
      w_preis TYPE eban-preis,
      w_amt TYPE eban-preis.

LOOP AT im_t_eban INTO wa_eban.
  IF wa_eban-werks = '1106'.
    w_amt = wa_eban-menge *  wa_eban-preis.
    w_preis = w_amt + w_preis.

IF w_preis > '10000'.
  CONCATENATE : 'Plant: ' wa_eban-werks 'max PR value 10000.00 sar'
    INTO l_msg SEPARATED BY space.
  CALL METHOD cl_message_mm=>create
      im_msgid         = 'ZMSGS'
      im_msgty         = 'E'
      im_msgno         = '899'
      im_msgv1         = l_msg
      im_force_collect = mmpur_yes. "collect message


when the enduser, checks the PR, it raises an exception as written above.

But when the enduser, saves the PR, initially it throws an error but still it gives us an option to save the PR, which should not happen in my case... It should not allow the user to save until the amount is corrected.

Kindly assist me on this.

Thanks and Regards,

Abdur Rafique