Notifications can be configured in the FAB Process Designer. Templates define the structure and content of the Notification.
Notifications / Emails
From FAB V3.2.0 onwards it is possible to design and configure Notifications from within the Process Designer. FAB V3.2.0 supports Email Notifications only.
Designing a Notification
Press the 'Notifications' tab of the Process Designer.
Templates
Templates define the structure and content of the Notification. Each Template consists of 'Sections', and Sections can consist of 'Subsections'. Sections and Subsections consist of 'Content' (usually HTML).
To create a new Template, press the Add Button and give the Template a meaningful Id. To demonstrate, we will create a Notification Template that will be used to send an email to the Initiator stating that the request has been submitted for approval.
Id
The Id is a unique identifier for the Notification. It is used elsewhere when configuring which Notification to generate at what point in time. The Id can also be used in various FAB user-exits to identify the Notification being processed at run-time
Description
The Description helps further explain the purpose of the Notification
From
The From property is a required property that is used by the email send process. Every email needs to have a valid sender 'from' email address; this is a requirement of SAP's emailing functionality. This will be dependent on your organization's policies.
Subject
Emails should have a Subject; this is simply the subject of the email as it appears in the recipient's email inbox.
Master Template
We will look at Master Templates later, but briefly, it is possible to base the Notifications on a Master Template to obtain consistency among different notifications, and to avoid duplicating content in several Templates.
Shown below is the Template definition so far. In this example we are not using a Master Template.
Sections
Now we will begin to define the content of our Notification in Sections.
Right-click the Notification in the 'Template Structure' tree-view and choose 'Add Section'.
Id
Template Sections also have an Id to identify the section during editing. It is recommended to use something meaningful so that the Template structure is easily understood.
Description
Template Sections also have a Description to identify the section during editing, and to make the definition understandable.
Content
Content is the actual content of the Notification. FAB has two means of declaring content; 'HTML' and 'Standard Text'.
HTML
HTML content is what is used to define the text and other visual elements in the resulting Notification.
The HTML must be well-formed (ie valid HTML with proper opening and ending of tags)
To demonstrate a simple email, we will add a basic paragraph of text to our HTML Content with:
<p>Your request has been submitted.</p>
Preview
Notice that once the Content is updated, the 'Preview' section shows the resulting formatted HTML. This preview can be used to check for errors in the HTML, for example, if incorrectly formed HTML is used, the Preview will not generate as expected.
Initial Testing
Before proceeding with a more complex Notification, we will see how to configure the Notification so that it sends when the Request is submitted.
Configure Notifications on the Action
There are several places where the Notification can be configured. We will start with the Outcome of the Action.
Here we want to send the Notification when the user presses 'Submit', so we configure the 'SUBMIT' Action on the 'Start' Task.
Choose the Outcome 'Approve' of the Action 'SUBMIT', then choose the Notification to send - in this case there is only one Notification to choose from. Then choose the 'Recipient' of the Notification. There are several options (which will be explained later), but in this case we choose 'Initiator' because we want to send the Notification to the initiator of the request.
Save & Close the Process Designer and test by submitting a new Instance of the application.
Now check the Data Report (/IQX/FAB_DATA_REPORT) and take notice of the 'Logs' tab:
If all went well, there will be a success message in the Log. Also, the recipient should eventually receive an email.
Note that successful emailing depends on the correct configuration of the SAP emailing system, such as SCOT and SOST, and the recipient users must have valid email addresses configured on their user-ids or 105 Infotype of their HR Personnel Master record (PA30)
The initial testing has proven that the Notifications and Emailing system are generally functioning correctly. We will now look further at developing more complex Notifications.
More Complex Templates
Add Instance Data to Notification
It is likely that you would want to add some information about the request to the email, for example, the Requested Amount.
Data Model fields can be added to the HTML Content by enclosing them in curly brackets {}. For example:
<p>Your request for {RequestAmount} has been submitted.</p>
Using Real Data in Preview
If you look at the 'Preview' now, you will still see the Data Model field as {RequestAmount}:
If you want to see the Preview with actual data, you can specify a 'Test Instance' (GUID) to use, and press the 'Test with Instance Data' button (don't forget to Save the Process Design before testing)
Tip: use the Data Report to obtain an Instance GUID for testing.
Testing with Instance Data will show the Preview with actual data from the specified Instance.
Now it is obvious the actual value of 'RequestAmount' is not formatted suitably for the email (it is in exponential notation format, because that is the internal representation of the FLOATVALUE SAP Data Type used in the Data Model)
" Your request for 1.2000000000000000E+03 has been submitted"
There are a few options for improving this. One option is to create another Data Model variable 'RequestAmountFormatted' (with Character based SAP Type) and use ABAP code in one of the user-exits like PERFORM_ACTIONS_FOR_STATUS_CHG to set this value.
Then change the HTML Content to use {RequestAmountFormatted} instead.
Another option is to implement similar logic in user-exit CHECK_AND_SEND_NOTIFICATION before calling the SUPER implementation.