cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering an email from SAP HANA SQL console/Procedure

hemanth_kumar21
Contributor
0 Kudos

Hi,

I have a client requirement that, based on the Table field value, email has to be triggered.

I have a table called STOCKS, whenever the field 'Stage' is updated with 'Critical' we have to trigger/send an email.

I have created a trigger to check the 'Stage' value is 'Critical' or 'Not Critical'. After finding this, I want to trigger an email.

If we want to send an email in ABAP,  we have a function module 'SO_NEW_DOCUMENT_SEND_API1'.

Do we have any thing in HANA?

I have gone through the below link,

But, I am not sure how to use the XSJS in my procedure/trigger?

I am using Service pack 9.

Thanks in advance.

Hemanth.

View Entire Topic
lbreddemann
Active Contributor
0 Kudos

You can't "call up" from a trigger to a XS engine functionality.

And there's no direct way to send emails out from trigger functionality.

In fact, that's not your requirement. You requirement is to send an email-notification when some sort of business event occurs. This business event is represented by the data in the table - but it's not the event itself.

So, your solution should not handle the warnings on a higher level.

For example you could write a stored procedure that enters the data into the table and that has a return parameter to indicate that the new "Stage" level is "Critical".

Your application could then trigger whatever action is required.

- Lars

hemanth_kumar21
Contributor
0 Kudos

Hi Lars Breddemann,

Thanks for your reply and confirming that there is no direct way to send email from trigger/procedure.


For example you could write a stored procedure that enters the data into the table and that has a return parameter to indicate that the new "Stage" level is "Critical".

Your application could then trigger whatever action is required.

The business logic behind this is, whenever the Ordered quantity exceeds the Available quantity, we want to send an email/notification to concerned person to intimate that about the Available quantity.

As you mentioned, I am maintaining this data in one HDBtable using the stored procedure.

Example, now the record is created and the Stage is 'Critical'.

Do, we have any standard functionality to send email?

I have gone through the standard procedures in package _SYS_STATISTICS.

which are using to send mail. Inserting the records into this table _SYS_STATISTICS.statistics_email_processing.

After going through the SCN, I understand that we shouldn't use that table, that is only for sap internal use.

So, my intention is to send an email/alert to concerned team based on the business logic.

Thanks in advance.

Hemanth.

lbreddemann
Active Contributor
0 Kudos

Hmm.. why do you assume that the procedures/functions/objects in _SYS_STATISTICS are for you? These are not in any way supported APIs that you should use in your projects.

You have a task at hand - sending an email based on stock level - and you have an application that uses SAP HANA as a databases. How about using the application layer for all user facing interactions (e.g. showing stuff on the screen, sending emails, etc.) instead of spreading this across your whole architecture?

Just sayin'...

- Lars