Send Spool list of background job to SAP Inbox
It was a requirement in one of the implementation project I worked, to send email to users with a report of success or errors that occured during a program execution. For example, a program that works on some data from SAP tables and it needs to report to user if any data is missing. If the program is run in online, the program can display the list of errors (due to missing data, etc.) in online via a simple basic list or simple ALV. But if the program is run in background, the program cannot produce a report in online and hence the report output can be written into a spool. Spool requests can be viewed from transaction code SP01. But the users have to check the spool request as and when the background program has been scheduled to run. In the project, the requirement was to send the error report or success report to a list of users via email.
SAP provides an easy way to acheive this without writing any coding for email functionality. Still the ABAP program has to produce report output using basic list or ALV. Please take care that your ALV using CL_GUI_CUSTOM_CONTAINER does not throw short dump due to non-availability of screen in background.
1. While scheduling the job for the program using transaction code SM36, you can configure to send the spool to SAP users inbox.
2. Go to SM36, specify a jobname for example, YRECONKEYCLOSE. In the same screen of SM36, you will find a button as "Spool list recipient".
3. Click the button "Spool list recipient". A dialog box will appear that will request for the "Recipient name". Press F4 (value help) on Recipient name field. A dialog box similar to shown below will appear. Choose the option "Internal user" and enter the SAP user id in the "Find" field.
4. Press Enter. Now the "Recipient name" will be populated with user id SAKTHI. This is the SAP user id who will receive the spool list in their SAP inbox after the execution of the background program. Press Copy button.
5. Press "Step" button to specify the ABAP program name to be scheduled to run in background. Enter the program name in the field "ABAP program Name" and press Save button. For example, here we will schedule the program RFKKFIKEYCLOSE - a SAP standard program to close the reconciliation keys created in SAP IS-U.
6. Press "Start condition" button to specify when the background program to be executed. For example, press "Immediate" button to run the program immediately after you complete the job scheduling. Press Save button.
7. Press "Save" button again to release the job.
8. Press "Own jobs" button to view the list of jobs scheduled by you. Check the job YRECONKEYCLOSE produced a spool request. If a spool request was found in SM37, then an email would have been sent to the SAP inbox.
9. Go to transaction code SBWP - SAP Business WorkPlace. Expand Inbox node and click "Unread Documents". Hurray, you got the mail from SM36 with the spool request as attachment in htm format.
10. Double-click on the mail displayed on the right pane of the window. You can view the attachment by clicking on the attachment and even you can save it to your desktop.
1. Sending spool to multiple users
If the spool has to be send to multiple users, create a distribution list via transaction code SBWP. Specify the list of SAP user ids to whom the spool output to be sent as email. Specify this distribution list when scheduling job in SM36 at the time of specifying spool list recipient. In above example, the Recipient name is chosen as the option Internal user. Now select the option as Distribution list and specify the distribution list name.
1. Sending email from SAP inbox to user's Outlook
Assuming the SMTP has been configured in transaction code SCOT, please contact your System administrator to configure SMTP in your server. Create Automatic Forwarding using transaction code SO36. Specify the SAP user id in the field "User" and the Outlook email address in the field "Forward to". Specify the recipient address type as "U - Internet address" and press Execute. Thus if SMTP was correctly configured, then as soon as email is received in your SAP inbox, you will receive an email in Outlook as well. To change the Outlook email address, use transaction SO36.