Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
faisal_altaf2
Active Contributor
4,192

Send Auto Mail to Specific User on Creation of every New ABAP Program (Workflow) Part 2/3

Send Auto Mail to Specific User on Creation of every New ABAP Program (Workflow) Part 3/3 Send Auto Mail to Specific User on Creation of every New ABAP Program (Workflow) Part 2/3 Send Auto Mail to Specific User on Creation of every New ABAP Program (Workflow) Part 3/3

 

Few days back when I was getting workflow training from my Team Lead Sir Ahsan Majeed, an idea came to my mind, sending an auto mail to him whenever any developer create new program in system. From that day I start working on it and after a long time (about a month) because of other work load I am able to manage it today. Now I am going to share it with all of you friends. Hope it will be very helpful for all of you and especially for beginner who didn’t work with enhancements, sending mail using classes and workflows.


In first part we will learn how to find and implement enhancements and send mail using the concept of classes.

1. Find Enhancement

When i started the first thing that came to my mind was to find some point  where i will write my code. After a little search from SCN and Google i found the following Enhancement

SEU00001      Function exit in program attributes

As you know every time when you create any program a Attribute Window appear the above Function exit call just before appearing this window. mean i can write my code to this Function exit (Enhancement).

2. Implementation of Enhancement

1. For this we have to create project in T-Code CMOD. Run T-Code CMOD and give the project name (Starting with Y or Z) and press the Create Button as shown below.

2. Give the Short text and Press Save Button

3. Give the Package Name where you want to save

4. Select Button Own Requests if you want to place it in some old request or create new Transport Request using New Button. (I am creating new Request as below and save all object in this request related to this Requirement).

5. Give Short Description and Press Save Button.

6. Now you will see you created request is selected now press OK button.

7. From the Toolbar select Enhancement assignments Button.

8. After Selecting above button you will see following new window Give Enhancement name SEU00001 and Select Components Button.

9. It will ask for Save Data First Press Yes

10. Now you can see two Function exits we need to write code in 2nd one EXIT_SAPLSEDTATTR_010 so Double Click on it.

11. It will leads us to on Function Module where we can see a INCLUDE ZXSEUU20, now double click on the name ZXSEUU20.

12. Because this Include is not yet created so it can give the following message in Status Bar. Now Just Press Enter Key from your Keyboard.

13. This time it will conform from you to create Include. Press Yes.

14. Select the Package and Transport Request.

 

15. It will open up a ZXSEUU20 Include in Edit Able Mode here we can write our Code.

Copy Past Following Code in above Include

', '

A New Program has created, please check details below.

', '', '', '', '', '', '', '', '', '', '', '', '', '', '' , '', '', '', '', '', '', '', '', '', '', '', '
Program Name', program, '
USER', name_text, '
Computer Name', computer_name, '
Computer IP Address', ip_address, '
Date', cdatum, '
Time', cuzeit, '
', '


', ''. ****Create the Document ref_cl_document_bcs = cl_document_bcs=>create_document( i_type = 'HTM' i_text = it_mailtext i_subject = subject ). ****Add Document to Send Request ref_cl_bcs->set_document( ref_cl_document_bcs ). ****Get the Sender Object from the Current Logged on User ref_cl_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ). ****Add Sender to the Send Request ref_cl_bcs->set_sender( ref_cl_sapuser_bcs ). ****Create recipient(s) ref_if_recipient_bcs = cl_sapuser_bcs=>create( sy-uname ). " By default it will send mail to the user " who will create the program * recipient = cl_sapuser_bcs=>create( 'AMAJEED' ). " Comment out above line, uncomment this line and replace " amajeed with your user name whom you want to send mail ****Add Recipient to the Send Request ref_cl_bcs->add_recipient( ref_if_recipient_bcs ). ****Set the Send Immediately Flag ref_cl_bcs->set_send_immediately( abap_true ). ****Send Document ref_cl_bcs->send( ). COMMIT WORK. ENDIF. 

Note: For More Details about Basic ABAP OO eLearnings

16. Now Go back to the Screen showing in Step 10 this time you will see little change in that screen as it is showing below.

17. Activate the Project by Clicking Activate button or Shortcut key Ctrl+Shift+F3 as showing in below ScreenShot.

After Activation it will show like below.

 

3. For Testing Create Program

Now Create a New Program using T-Code SE80 or SE38.

4. Check Mail

1. Run T-Code SBWP or Press the Icon from Toolbar from your home screen Show Below.

2. Here you can see 1 Unread Documents.

3. Double Click on Subject to open mail

 

5 Comments
Labels in this area