Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
Sometime ago, I was going through a non-SDN forum where I found an interesting report program which is meant for sending mails to Basis Team or the concerned person whom has to be informed about number of Users who haven't logged-on to the system for the past given number of days.

 

It would be icing on the cake, if program also sends individual emails to all the not-logged users informing them about their absence to the system, further more sending an excel-sheet containing list of all not-logged users to the Basis would also be a better idea.

I am going to demonstrate a report program that contains a selection-screen that inputs number of days, recipient address obviously Basis' mail address and recipient type (SAP Logon Name type B, External Address type A, Internet Address type U, etc). But in order to send mails to external servers from SAP system, requires a little exercise; configuration of ICM - Internet Connection Manager using a couple of standard transactions.

Let our esteemed blogger Thomas Jung explain configuration of ICM; Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface. Once mail sending capabilities of SAP system makes us content, further step can be taken.

Here we go; we'll going to use USR02, USR21, ADRP, ADR6 database tables which help us get detailed information, but using Joins to get data across the tables is not a better idea to get along, ‘FOR ALL ENTRIES' is a better substitute to it. Moreover, we'll also going to use WS_DOWNLOAD rather GUI_DOWNLOAD, since GUI_DOWNLOAD doesn't make header-lines appear in the excel sheet to be downloaded in the local drive as well as to send it as an attachment.

 

As a norm we'll begin with the declaration part first;

We have to move p_days that is an integer data type to w_days character data type since character data-types can only be used in concatenate function.

Further, we begin with functionalizing subroutines;

We use ranges to get list of last-login dates of users between the date of execution of the program and the past given determined date.

 

Moreover, email has to be sent to only those users whose email-ids have been found, else sending mails to all detected users makes no ordinary sense.

Besides sending excel-sheet as an attachment to the Basis, it should also be saved on local drive; we make here a simple download in C drive, for desired location of saving CL_FRONTEND_SERVICES can be used.

 

 

Finally, once coding is finely reviewed; save, activate and execute the program;

 

 

No sooner mail is sent successfully, a status message is given as acknowledgment.

 

As soon as mail is sent; mail is found standing in the inbox.

 

The attached excel-sheet gives details of the not logged users the following way;

 

 

Besides getting excel-sheet in the mail attachment; the same copy is found resting in C drive, as specified in WS_DOWNLOAD Function Module.

Well, the Basis team email address, the number of days and recipient type could be hard-coded, but I felt to make it more dynamic so program-executer can feel easy to specify any email address, he desires. Moreover, this also helps get a quick view of the Users logged-on for the specified time, if the logic in the first select-query is bit modified.

Besides giving the above concept, I hope this blog has surely made a room to understand the mailing concept in SAP in a more reliable way.

10 Comments