简体   繁体   中英

How to write HTML code in ABAP to send a mail

Can any one help me writing this code in HTML with specified spaces and conditions when given in ABAP. I am including HTML in ABAP to send a mail through ABAP.

Here I need to print flds-fieldname after 10 spaces as mentioned in the below write statement. I need to write in HTML.

loop at flds .
  assign component flds-fieldname of structure l_det to <fl>.
  assign component flds-fieldname of structure r_det to <fr>.
  if <fl> ne <fr>.
    write : /10 flds-fieldname ,
            /20 'Local -' , 30 <fl> ,
            /20 'Remote -' , 30 <fr> .
  endif.
endloop.

uline.
skip.

Thanks in advance.

If you want a suitable & maintainable code, I advise you to separate html content and ABAP content. For that you can use the SAP Web Repository .


First write your html page

   <html>
    <head>
        <meta charset="utf-8"/>
    </head>
    <body>
        <p>
            <!var!>
            Local - fl
            ...
        </p>
    </body>
    </html>

You can insert placeholder like <!var!> and replace them with ABAP variables in the driver program.


Secondly download it in the SAP Web Repository with the transaction SMW0


Finally load your html page with appropriate function module in your driver program

call function 'WWW_HTML_MERGER'
      exporting
        template           = 'YOUR_SWR_HTML_ID_TEXT'
*       MERGE_TEXTPOOL     =
*       TEMPLATE_TABLE     =
      importing
        html_table         = lv_text
      changing
        merge_table        = lt_merge
      exceptions
        template_not_found = 1
        others             = 2.
    if sy-subrc <> 0.
      raise exception type cx_swf_mail_manager.
    endif.

change argument TEMPLATE by your template ID in SAP Web Repository html placeholder are replaced in the internal table lt_merge

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM