Skip to Content
0

Change sender email address using BCS_SEND_ADDRESSES

Nov 20, 2017 at 08:40 AM

63

avatar image

Hi,

When I am performing a certain action in HR Portal, an email is sent to an intended recipient, but the sender is the person who logged into the HR Portal. I want the sender to be a specific email address.

I found BCS_SEND_ADDRESSES BAdI, which allows me to change the email address of sender/recipient. However, now it seems like all emails sent by class CL_BCS use my BAdI implementation and have their sender email address changed. Is there any way I could restrict when my BAdI implementation changes the email address? This BAdI does not any filters, and the interface of the implementing class, IF_BCS_BADI_SEND_ADDRESSES, does not have any parameters that could allow me to determine which action caused the email to be sent.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Nic Teunckens Nov 20, 2017 at 09:06 PM
2

But if you Implement the BAdI you can add your own Custom Methods, right?

So what's stopping you from Creating a Method to Check for 'XYZ' (SystemParameters, Tcodes or other Business Logic) and / or filling a Private Attribute, so you can Allow / Disallow the Enhancement to change the E-mail Address ...?

Maybe I'm over-simplifying here, but if you can Determine when the User is accessing the Right Program / HR-Portal page or whatever, then set an Attribute "CHANGE_EMAIL" to 'X' and depending on that Result you can Allow for a Change in Sender or Recipient ... Again, just conceptualizing here, but that would make sence to me ...

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I ended up finding out what is the WDA-application that is causing the email to be sent using cl_wdr_task=>application_name, and if it is the one that I need, then I would change sender's email address.

Also, I found out that this BAdI requires both es_sender and es_status_recipient to be changed in order to change email address of the sender.

0
Sandra Rossi Nov 21, 2017 at 07:19 AM
0

I agree with Nic. If the possibilities of extending the caller program are limited (not possible to use the Enhancement Framework and so on), you may also get some information of the context by reading the ABAP call stack (CL_ABAP_GET_CALL_STACK=>FORMAT_CALL_STACK( CL_ABAP_GET_CALL_STACK=>GET_CALL_STACK( ) )), and reading some global variables from other programs (reserved internally to SAP - ASSIGN ('(program)global') ...).

Share
10 |10000 characters needed characters left characters exceeded