Skip to Content

Sending email in ZXM02U06

Hi experts,

In include ZXM02U06 we have the necessary code to send an email depending on some conditiones when executing ME51N. It is working fine.

Now we have a new requirement which is to create a new purchase requisition after creating a material document. I did it in badi MB_DOCUMENT_BADI, method

MB_DOCUMENT_BEFORE_UPDATE. As I got a dump while executing it, I did it like this:

CALL FUNCTION 'BAPI_REQUISITION_CREATE' IN BACKGROUND TASK

But the email is not sent. I think BAPI_REQUISITION_CREATE should trigger ZXM02U06, isn't it? I aldo tried to send the email after calling BAPI_REQUISITION_CREATE but I need the purchase requisition number and at this moment (while debugging) this value is empty.

Is there any way to send this mail ? how can i get purchase requisition number after calling the bapi in background?

Thanks in advance!

Maria

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Nov 06, 2017 at 01:22 PM

    Personnaly I would have used method POSTED of BAdI ME_REQ_POSTED or method POST of ME_PROCESS_REQ_CUST and not an old customer-exit provided for customer fields update.

    I would also have wrapped the call of the BAPI in an RFC customer FM to manage the RETURN parameter and manage the COMMIT.

    NB: The IN BACKGROUND registered FM are executed after the COMMIT WORK, after the V1 update FM. (Execute transaction SM58 to find any error during their execution) Check also for your debug options.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 01:18 PM

    Hello Maria,

    Inside BAPI 'BAPI_REQUISITION_CREATE' few other customer exits triggered.

    Did you check those for your requirement ?

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 01:35 PM

    Why not implement a mail as an output type? Seems the most sensible way to do it and you have a lot more control via output conditions.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 11:34 AM

    Hi,

    did you try to debug in background & put a break-point in your include ? to check if your code is executed or not ?

    regards

    Fred

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 11:44 AM

    Yes I tried but it doesn't stop.

    Add comment
    10|10000 characters needed characters exceeded