Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Inputs needed : Logic implementation on sending mail and database update.

Former Member
0 Likes
617

Hi All,

I have a requirement in which I need to send a mail and then update a database table.

Sending mail and table update should work as one transaction i.e should be consistent.

I need your inputs to implement the above.As per my understanding :

CASE I : Send mail and then update database.

ISSUE : If database table is not updated, a 'ROLLBACK WORK' is called but mail cannot be reterived.

CASE 2 :Update database and then send mail.

ISSUE : IF database update is successful but mail sending failed??

Thanks in advance.

5 REPLIES 5
Read only

former_member156446
Active Contributor
0 Likes
587

why do you think database will not update? update or insert statement should help u

Read only

0 Likes
587

There are exception : Table Load Failure

and Others.

Read only

Peranandam
Contributor
0 Likes
587

Hi its very simple.

you have to regist your subroutine with on commit addition .

for your case1.

perform send_mail on commit.

perform update_table.

*--here you have to evaluvate sy-subrc of database update .

if sy-subrc = 0.

*here you are sending mail if update has beeen sucess or trigger error what every you need.

commit work.

endif.

Regards,

Peranandam

Read only

0 Likes
587

What if mail sending fails??

Database is updated and mail sending fails, This is also not desired.

Read only

0 Likes
587

Hi,

in my point of view if you coded properly for sending mail by considering all the failiure factor then there is no problem.

or

If mail sending fails, revert back all the changes you have updated in the table and display error log.

Regards,

Peranandam