Application Development 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: 

sending Dynamic table in mail Body.

former_member201527
Participant
0 Kudos

Hello Experts ,

  I want to send a table in the mail Body. Number of rows in the table will be dynamic. Please suggest which Function module i should use to achieve this.

Here in the below case, number of entries are dynamic.  Is it possible to achieve through some function module. WOrk flow are not configured in system.

Example :

Dear <Dynamical text >,

Below are the payment details.

XXXXXX

XXXX

XXXX

XXXXXX

XXXXXXX

XXXXX

XXXXXX

Amount

100

100

100

100

100

100

100

100

Total Cost

800

BR,

Nikhil Kulkarni

5 REPLIES 5

0 Kudos

Hi, yes, you can do it with html tags like this:

//...Firsts lines before the loop at table into workarea....

<table style="width:100%">
   <tr>
    <td>field1</td>
    <td>field2</td>
    <td>field3</td>
   </tr>

LOOP AT table INTO workarea.
  <tr>
     <td>workarea-value1</td>
     <td>workarea-value2</td>
     <td>workarea-value3</td>
   </tr>

ENDLOOP.

//....TOTALS CALCULATED CODE....

<tr>

    <td>TOTAL COST</td>

    <td>Value2</td>

    <td>Value3</td>

</tr>
</table>


FUNCTION TO USE SO_NEW_DOCUMENT_SEND_API1

with rec_type = 'U' if is a list of address or 'C' for a distribution list in structure receivers


Regards,

Alberto

0 Kudos

Hello Alberto,

Thanks alot for quick response. Can you provide some sample code. I am little confused with this. Please provide min parameters which i need to pass to USE SO_NEW_DOCUMENT_SEND_API1 function module. Thanks very much once again.

BR,

Nikhil Kulkarni

0 Kudos

With append per line into the body table for the function.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Quite a fresh code.....

Using cl_bcs for the mail .

See FORM get_html_table: It is using cl_salv_ddic=>get_by_data to get the structure of the table .

regards. 

Former Member
0 Kudos

hi nikhil,

you can create dynamic tables as below code.

TYPE-POOLS: slis.

FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,  “ Dynamic internal table name

               <fs_dyntable>,                     “ Field symbol to create work area

               <fs_fldval> type any.              “ Field symbol to assign values

PARAMETERS: p_cols(5) TYPE c.                     “ Input number of columns

DATA:   t_newtable TYPE REF TO data,

        t_newline  TYPE REF TO data,

        t_fldcat   TYPE slis_t_fldcat_alv,

        t_fldcat   TYPE lvc_t_fcat,

        wa_it_fldcat TYPE lvc_s_fcat,

        wa_colno(2) TYPE n,

        wa_flname(5) TYPE c.

* Create fields .

  DO p_cols TIMES.

    CLEAR wa_it_fldcat.

    move sy-index to wa_colno.

    concatenate 'COL'

                wa_colno

           into wa_flname.

    wa_it_fldcat-fieldname = wa_flname.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO t_fldcat.

  ENDDO.

* Create dynamic internal table and assign to FS

  CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

      it_fieldcatalog = t_fldcat

    IMPORTING

      ep_table        = t_newtable.

  ASSIGN t_newtable->* TO <t_dyntable>.

* Create dynamic work area and assign to FS

  CREATE DATA t_newline LIKE LINE OF <t_dyntable>.

  ASSIGN t_newline->* TO <fs_dyntable>.


you can do mail sending process using HTML tags.Using cl_bcs .

please refer below document.

https://www.google.com.sa/search?site=&source=hp&q=html+mail+sending+code+in+sap&oq=html+mail+sendin...

Thanks,

Marimuthu.K