Skip to Content
Technical Articles
Author's profile photo Sachin Artani

How to Configure Dynamic Email in Output Parameter Determination App

Following what we have learned from other blogs for the Output Parameter Determination app, I came across something which seemed impossible at the beginning but what’s not possible with SAP?

I had a requirement to setup dynamic Sender and Receiver email address in Output Parameter Determination app for Item Interest Calculation rule. As we know that the app generally presents a decision table for each Determination Setting such as – Output Type, Email Settings, Email Recipient, Form Template etc. And the decision table has endless possibilities for nesting with data objects and expressions. I took advantage of the expression assignment and achieved fetching email of Sender and Receiver dynamically.

Let’s get started.

Sender Email Configuration: Email Settings

For Sender Email, we will be picking data from a custom decision table created in our custom BRF+ application.

BRF+%20function

Based on input parameters – Company Code, Output Type as Mandatory and Free Parameter1, Free Parameter2 as Optional Parameter, we determine Email Body Text, Email Subject text, Logo, Sender E-mail and Sender Name.

To fetch data from the decision table, we created a Function ZFI_TEXT_DETERMINE_FM with the same importing and exporting parameter as the Decision Table –

BRF+%20function

For Result Data Object, we created a structure. If you need a single data object as result, you can assign an Element as Data Object as well.

Once the Decision Table and Function is ready, we move to the Output Parameter Determination (OPD) app.

Open the rule – Item Interest Calculation.

When we edit the decision table and click on Table Settings button, we get option to insert column in Condition Columns and in Result Columns. In insert column button, if we select “From Context Data Objects, we get below list with possible data objects to pick –

OPD%20Available%20Context%20Data%20Objects

If we use the Sender Email data object, it will always return a static email as per standard functionality and we will not have capability to write any logic or to pick the email from any other place.

So, we will be selecting from the Expressions, but then we must have an expression available which can take something as input and return us expected email. For that, we will create a procedure call expression and assign a function module to it which will have the logic written for email.

Here, I created a FM – ZFI_FETCH_SENDER_EMAIL with two importing parameters which I can expect from the OPD’s decision table – DT_EMAIL_SETTINGS.

Sender%20Email%20FM

If we notice the available context data objects once again, we have Document ID, Output Type, Recipient, and Role as condition parameters, to which we can expect Email Template and Sender Email as resulting parameter.

So, while creating the Procedure Call expression and corresponding FM, we can use either of the condition parameter as importing parameter and resulting parameters as exporting parameters.

In my case, I needed Company Code and Output Type as importing parameter to determine the email address. So, I needed a Procedure Call expression.

The pre-requisite is that the custom BRF+ application – ZFI_TEXT_DETERMINATION must be of Storage Type: System.

The Procedure Call: GET_SENDER_EMAIL must have Access Level: Global so that it can be access outside the scope of our custom BRF+ application.

We map our FM to the Procedure Call –

And also map the importing and exporting parameters with the context data objects –

Once this is done, we can look for our custom procedure call in the Table Settings Insert Column option and we can assign it to the Sender Email column –

In each of the step, I would recommend to simulate the expressions to validate if you are doing it right.

Receiver Email Configuration: Email Recipient

In case of Receiver’s email address, we are fetching the email from customer master data. So, I created a FM – ZFI_FETCH_RECEIVER_EMAIL and from the available context, I used Recipient as IV_RECEIVER.

A Procedure Call with Access Level: Global with same importing and exporting parameter and mapping of parameters with the available context data objects –

Once this is done, assign the procedure call expression to the Email Address column in the OPD’s decision table – DT_EMAIL_RECEIVER and tada! We are done.

If we do not hardcode the Recipient in the OPD’s decision table, it automatically picks up for the receiver for which the invoice has triggered.

Thanks for reading!

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas

      For completeness of the Blog:

      As of S/4 HANA Cloud 2302, this option in the blog doesn't work. Any new custom BRF+ application is created as a Local object and Local objects are not allowed to be used in Output Parameter Determination. Hopefully, SAP will fix these issues with future releases.

      Author's profile photo Sachin Artani
      Sachin Artani
      Blog Post Author

      Hi Juwin,

      Thank you for adding this information here. Yes, you are right. At this point of time, S/4 HANA Cloud 2302 restricts any Tier2/Tier3 developments to keep the systems upgrade safe. And we indeed will see some solution to these workaround solutions in the future.

       

      Author's profile photo Wilson Joelmir Hernandez Cajusol
      Wilson Joelmir Hernandez Cajusol

      hello Sachin Artani thanks for the extended explication, just one question... this configuration can work with multiple emails?

      thanks in advance

      Wilson H.

      Author's profile photo Sachin Artani
      Sachin Artani
      Blog Post Author

      Hello Wilson,

      Thanks for showing interest and reading my blog. I am a bit unclear with your question. If you mean to return multiple emails for a single row condition, then I think it's not possible.

      The E-mail Address field cannot hold more than one email address, so, you can try using a distribution list containing email addresses.

       

      Thanks,

      Sachin

      Author's profile photo Wilson Joelmir Hernandez Cajusol
      Wilson Joelmir Hernandez Cajusol

      Hello Sachin,

       

      Thanks for your quick answer, I am a bit confused, what do you mean use "Distribution List"?

       

      We need to send to multiple emails the document

       

      thanks in advance

      Wilson H

      Author's profile photo Sachin Artani
      Sachin Artani
      Blog Post Author

      Hello Wilson,

      A Distribution List (DL) is a common broadcast email to which if an email is sent, it goes to all the receivers associated with the DL. I think this cannot work for you.

      Instead you can maintain multiple rows with same condition but different E-mail receipent. This way all individuals may receive the separate email document. But maintaining multiple e-mails within a single row is not possible.

      Thanks,

      Sachin