How to Configure Dynamic Email in Output Parameter Determination

How to Configure Dynamic Email in Output Parameter Determination

SAP

Following what you may have learned from other blogs related to the Fiori app - Output Parameter Determination, 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.

Custom Decision Table

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 –

Custom BRF+ Function

For Result Data Object, we created a structure. In case, we need a single data object as result, we can assign here as Element as well.

result structure

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 –

Condition Context Data Objects

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.

FM for sender email

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.

Custom BRF+ application

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.

Access Level Global

We map our FM to the Procedure Call –

Custom Procedure Call

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

Mapping of 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 –

OPD Sender Email Config

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.

Receiver Email FM

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

PC for Receiver Email

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.

OPD Config for Receiver Email

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.

Try it out and let me know if you stuck at any place. Thanks for reading!

Tags: #sap#opd