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

Email formatting, stuck with HTML code

former_member202077
Participant
0 Likes
2,818

Hello

I am new to HTML stuff, my requirement is to build the email body having a table in it, as shown in attachmnet / pic.

So, i tried with the below code, but not getting table as per my requirements, i coded like below

* Message Body in HMTL
*****************  gs_objtxt-line = '<html> <body style="background-color:#FFE4C4;">'. "pale yellow; delete this line bcz i want white backgr.
  gs_objtxt-line = '<html>'.
  APPEND gs_objtxt TO gt_objtxt.

  gs_objtxt-line = '<p> List of Employees </p>'.
  APPEND gs_objtxt TO gt_objtxt.

* Table display
  gs_objtxt-line = '<table style="MARGIN: 10px" bordercolor="#90EE90" '. "green
  APPEND gs_objtxt TO gt_objtxt.
  gs_objtxt-line = ' cellspacing="0" cellpadding="3" width="400"'.
  APPEND gs_objtxt TO gt_objtxt.
  gs_objtxt-line = ' border="1"><tbody><tr>'.
  APPEND gs_objtxt TO gt_objtxt.

* Table header

************  gs_objtxt-line = '<th bgcolor="#90EE90">Project Name</th>'. ===> This gives green back ground, but i want grey color
  gs_objtxt-line = '<tr style="background-color:#eeeeee;"><td>Emp Name</td>'.
  APPEND gs_objtxt TO gt_objtxt.
  gs_objtxt-line = '<th bgcolor="#90EE90">Number</th></tr>'.
  APPEND gs_objtxt TO gt_objtxt.
  gs_objtxt-line = '<th bgcolor="#90EE90">Department</th>'.
  APPEND gs_objtxt TO gt_objtxt.

* Table Contents
  DO 5 TIMES.
    gs_objtxt-line = '<tr style="background-color:#eeeeee;"><td>TEST_EMP</td>'. "==> Its grey color as back ground, but i need white backgr.
    APPEND gs_objtxt TO gt_objtxt.
    CONCATENATE '<td>' 'Test_Number' '</td> </tr>' INTO gs_objtxt-line.
    APPEND gs_objtxt TO gt_objtxt.
    CONCATENATE '<td>' 'Test_Dept' '</td> </tr>' INTO gs_objtxt-line.
    APPEND gs_objtxt TO gt_objtxt.
  ENDDO.

So, pls. let me know what changes i hv to do to the above my code to get the table as shown in the pic. / attachment?

Thank you

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,383

I would like you to create a basic html page which shows desired table in web browser.

Once concept is clear, same code can be created using ABAP.

This W3Schools article would teach the basics of HTML Table.

To assist you, here is html code taken from your code, and indented (pretty printed) so you can locate errors.

<html>

    <body style="background-color:#FFE4C4;">

    <html>

    <p> List of Employees </p>

    <table style="MARGIN: 10px" bordercolor="#90EE90" cellspacing="0" cellpadding="3" width="400" border="1">

        <tbody>

        <tr>

        <th bgcolor="#90EE90">Project Name

        </th>

        <tr style="background-color:#eeeeee;">

            <td>Emp Name

            </td>

            <th bgcolor="#90EE90">Number

            </th>

        </tr>

        <th bgcolor="#90EE90">Department

        </th>

        <tr style="background-color:#eeeeee;">

            <td>TEST_EMP

            </td>

            <td>Test_Number

            </td>

        </tr>

        <td>Test_Dept</td>

        </tr>

Here are some of the errors.

  1. HTML tag appears twice, both of them not closed
  2. BODY tag not closed
  3. TABLE tag not closed
  4. TBODY tag not closed
  5. Table would have list of TR (table rows) at same hierarchy level. Here we have 1 row, and 2 rows inside first row.
3 REPLIES 3
Read only

Former Member
0 Likes
1,383

Hi MSR,

I see that you have not nested the HTML tags properly. For Example, you have two <HTML> tags in the beginning.

Use the below wiki and code accordingly.

http://wiki.sdn.sap.com/wiki/display/Snippets/Formatted+HTML+Email+Attachments+using+ABAP

Regards,

Karthik

Read only

Former Member
0 Likes
1,384

I would like you to create a basic html page which shows desired table in web browser.

Once concept is clear, same code can be created using ABAP.

This W3Schools article would teach the basics of HTML Table.

To assist you, here is html code taken from your code, and indented (pretty printed) so you can locate errors.

<html>

    <body style="background-color:#FFE4C4;">

    <html>

    <p> List of Employees </p>

    <table style="MARGIN: 10px" bordercolor="#90EE90" cellspacing="0" cellpadding="3" width="400" border="1">

        <tbody>

        <tr>

        <th bgcolor="#90EE90">Project Name

        </th>

        <tr style="background-color:#eeeeee;">

            <td>Emp Name

            </td>

            <th bgcolor="#90EE90">Number

            </th>

        </tr>

        <th bgcolor="#90EE90">Department

        </th>

        <tr style="background-color:#eeeeee;">

            <td>TEST_EMP

            </td>

            <td>Test_Number

            </td>

        </tr>

        <td>Test_Dept</td>

        </tr>

Here are some of the errors.

  1. HTML tag appears twice, both of them not closed
  2. BODY tag not closed
  3. TABLE tag not closed
  4. TBODY tag not closed
  5. Table would have list of TR (table rows) at same hierarchy level. Here we have 1 row, and 2 rows inside first row.