‎2010 Jun 14 11:22 AM
Dear Guru ,
I am writing an abap program that can send the 'HTML' email to external user ( such as : GMAIL , YAHOO ) ...
Up to now , everything is fine .... But i am looking for a solution that is it possibile to use a HTML template for that ?
For example :
I have one HTML file , like that :
<body>
<table>
<tr><td>&name</td></tr>
<tr><td>&address</td></tr>
</table>
And in my abap program i will fill my username ( sy-uname ) and address ( zaddress ) to this HTML file and then send to the external user ...
Any good idea for that ? My idea is very stupid that put this file to internal table and then check it line by line ....
Thanks .
Best Regards,
Carlos
‎2010 Jun 14 11:53 AM
You can use html tag like this ;
data : wa_objtxt TYPE solisti1,
it_objtxt TYPE TABLE OF solisti1,
wa_objtxt = '<body>'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '<table id="Table_01" align="center" width="700" border="0" cellpadding="0" cellspacing="0">'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '<tr>'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '<td>'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '<img src= >'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '</td>'.
APPEND wa_objtxt TO it_objtxt.
wa_objtxt = '</tr>'.
APPEND wa_objtxt TO it_objtxt.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_docdata
PUT_IN_OUTBOX = ' '
sender_address = '...'
sender_address_type = 'INT'
commit_work = 'X'
TABLES
packing_list = it_objpack
contents_txt = it_objtxt
receivers = it_reclist
‎2010 Jun 15 2:24 AM
Dear cagatay ,
Thanks .
This is the way we are using now . but it seems very diffcult to handle the complex html template ...
Imagine we have 100 html template files need to be sent and we will spend a lot of time on this hardcoding ....
Thanks again .
Best Regards,
Carlos
‎2010 Jun 15 10:11 AM
Here i share my abap code if someone internet for this topic :
FUNCTION Z_BCAPPLYTEMPLATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(FILE) TYPE CHAR255
*" TABLES
*" PARAMETERS STRUCTURE ZTMPLSTRU
*" CONTEXT STRUCTURE ZTMPLSTRU
*"----------------------------------------------------------------------
* This function can read a template file that storage in the application server
* And then replace the "^" charater to some parameters .
* Sometimes use for the HTML format email sending
*"----------------------------------------------------------------------
* By Carlos
* Defined vars
DATA : BEGIN OF IT_READ OCCURS 0.
INCLUDE STRUCTURE ZTMPLSTRU .
DATA : END OF IT_READ .
DATA : V_LENLEFT LIKE SY-FDPOS .
DATA : V_PARAMETER TYPE CHAR200 .
DATA : V_IDX TYPE I .
V_IDX = 1 .
SY-SUBRC = 0 .
OPEN DATASET : FILE FOR INPUT IN TEXT MODE ENCODING UTF-8.
CLEAR : IT_READ[] .
* Read file
DO.
IF sy-subrc <> 0.
exit.
ENDIF.
READ DATASET FILE INTO IT_READ.
IF sy-subrc = 0.
append IT_READ .
ENDIF.
ENDDO.
CLOSE DATASET FILE .
* Start apply parameters
LOOP AT IT_READ .
CLEAR : V_LENLEFT .
CONTEXT = IT_READ .
WHILE sy-subrc = 0 .
CLEAR : V_LENLEFT .
SEARCH CONTEXT-LINE for '^' .
IF SY-SUBRC = 0 .
" READ PARAMETERS
READ TABLE PARAMETERS INDEX V_IDX .
IF SY-SUBRC = 0 .
V_PARAMETER = PARAMETERS-LINE .
V_IDX = V_IDX + 1 .
ENDIF .
V_LENLEFT = SY-FDPOS + STRLEN( V_PARAMETER ) - 1 .
concatenate CONTEXT-LINE(sy-fdpos) V_PARAMETER CONTEXT-LINE+v_lenleft into CONTEXT-LINE .
else.
append CONTEXT.
endif .
ENDWHILE .
CLEAR sy-subrc .
ENDLOOP .
ENDFUNCTION.
‎2010 Jun 15 10:12 AM
‎2010 Jun 16 9:44 AM
Good Work,
if it is possible , Can you send me full code ? I want to try in my system.
what is the content of ZTMPLSTRU ?
cagatayersoylu@gmail
Thanks.