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: 

Sending email in ZXM02U06

maria_merino
Active Participant
0 Kudos

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

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

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.

9 REPLIES 9

FredericGirod
Active Contributor
0 Kudos

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

maria_merino
Active Participant
0 Kudos

Yes I tried but it doesn't stop.

SimoneMilesi
Active Contributor
0 Kudos

Which kind of dump do you receive?

former_member182915
Active Contributor

Hello Maria,

Inside BAPI 'BAPI_REQUISITION_CREATE' few other customer exits triggered.

Did you check those for your requirement ?

raymond_giuseppi
Active Contributor

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.

0 Kudos
I wrote my code in method post of badi ME_PROCESS_REQ_CUST but didn't work, I'll try as you say and see if it Works.

Thanks!!

0 Kudos

Raymond, solved using ME_REQ_POSTED. Thanks a lot !!

pokrakam
Active Contributor

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.

0 Kudos

The consultant wants to manage the message like this..