Skip to Content

Applies to:

SAP Netweaver, ABAP, Email, standard text

Summary

This tutorial will take you step by step process to develop ABAP program which will send E mail in HTML format. The email body content is maintained separately in Std. text object; so that it can be maintained independent of Program.

With this; email is generated in HTM format which is more asthetic than a RAW format. Email body can be formatted with all rich text properties like bold, italic fonts, text sizes, tables, etc.

Additionally email body content can be changed without changing the ABAP program; since it is maintained separately in standard text. Program modularization & ease of maintenance can be achieved.

Author:        Amit Talekar

Company:   Capgemini India

Created on: 23rd July 2012

Create Standard text object

Create standard text object from /SO10

1.JPG

     Maintain text with HTML tags

     In this example HTML tags for table structure are maintained.

1.JPG

    For dynamic contents; program global variables are used

1.JPG

    Read std. text in ABAP Program

     Call FM READ_TEXT


     Using Standard Function module READ_TEXT read Std. text in the program.

1.JPG

     READ_TEXT FM returns LS_HEAD & LT_LINES.

     LS_HEAD contains Header data and LT_LINES contains text maintained in the object.

1.JPG

     Call FM TEXT_SYMBOL_REPLACE

     Call FM to replace variables in std. text with actual values.

1.JPG

    

     FM TEXT_SYMBOL_REPLACE returns LT_LINES with values (passed as program global variables).

1.JPG

    Send E-mail

     Prepare E-mail subject & E-mail body

1.JPG

     Call Std. FM to send E-mail in HTML format

1.JPG

   Check the output in MS-Outlook

1.JPG

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Thomas Zloch

    Please try posting code as text and not screen dumps, so people can easier try out what you are suggesting.

    Also I would rather use the newer functionality of the CL_BCS class for sending mails than the older SO_NEW_DOCUMENT… function modules.

    Thomas

    (0) 
  2. Ravindran Pather

    Hi Amit , thanks for the share ,

    i am hoping you can give me some guidance on the following :

    i have a user requirement to replace the following functionality we provide , the user when working with certain transactions have the option to send email

    we provide the user with a standard text editor (like S000) which then use the text contents to be populated as the email body text with the outgoing email

    now we want to provide them wth the ame functionality but use a HTML editor allwoingthe user much more functionality like bold , colour tools etc

    can you help me please

    thank you

    Ravi

    (0) 
    1. Radoslaw Gref

      Hi,

      I have a similar feeling. There are multiple ways to create texts in XML-based format.

      And I’m not so convinced about this: “Program modularization & ease of maintenance can be achieved.”
      How ease if maintanance can be achieved when you create manually HTML code in standard text ….

      Regards, Radek

      (0) 
  3. Florin Wach

    I was looking for a simple-to-be-used example for reading a Standard text from SO10 and replace the symbols from the current main program.

    This blog helped me a lot here, although there was one piece missing for me, and another small correction:

    – The program (sy-repid) needs to be transferred an the call to the replace-FM, otherwise it doesn’t replace any program symbols

    – The replace-FM doesn’t need the sy-tfill. When not provided, it uses the complete table.

    Thanks and best regards

       Florin

    (0) 

Leave a Reply