Hello Gurus,
i am sending email from SAP, i have problem with data alignment in email BODY in both SAP and actual email.
email data has data as below.
text 1
text 2
text 3
table like data
vblen posnr vkrog vtweg spart
101 01 VK VT SP
102 01 VK VT SP
table like data , is acatually formated using spaces.
But when email is sent both on SAP and actual email data is displated as below
text 1
text 2
text 3
table like data
vblen posnr vkrog
vtweg spart
101 01 VK
VT SP
102 01 VK
VT SP
but when data was copied to notepad , with was displayed well.
so requested to correct. After a alot of R&D i found HMTL code to get this done.
But nowis everything is going welll, table is displayed in SAP ,But in Actual email there is no email data at all. this is a big problem
Please check below my code.
*&---------------------------------------------------------------------*
*& Report ZTEST_JAY_TABLE_HTML
*&
*&---------------------------------------------------------------------*
*&
*&Following Function Modules are used to convert internal table data to HTML Table.
*& 1. WWW_ITAB_TO_HTML_HEADERS is used to populate column headings.
*& 2. WWW_ITAB_TO_HTML_LAYOUT is used to populate column cell properties.
*& 3. WWW_ITAB_TO_HTML is used to convert internal table data to HTML.
*&---------------------------------------------------------------------*
REPORT ztest_jay_table_html.
*Types declaration
TYPES: BEGINOF ty_sflight,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
fldate TYPE s_date,
price TYPE s_price,
currencyTYPE s_currcode,
ENDOF ty_sflight.
DATA:
t_header TYPESTANDARDTABLEOF w3head WITHHEADERLINE, "Header
t_fields TYPESTANDARDTABLEOF w3fields WITHHEADERLINE, "Fields
t_html TYPESTANDARDTABLEOF w3html, "Html
wa_html TYPE w3html,
wa_header TYPE w3head,
w_head TYPE w3head.
DATA:
it_sflight TYPETABLEOF ty_sflight,
it_fcat TYPE lvc_t_fcat WITHHEADERLINE. " Fieldcatalog
*---------------------------------------------------------------------*
* S T A R T - O F - S E L E C T I O N
*---------------------------------------------------------------------*START-OF-SELECTION. SELECT * FROM
START-OF-SELECTION.
SELECT * FROM
sflight
INTO CORRESPONDING FIELDSOFTABLE it_sflight
UPTO20ROWS.
*---------------------------------------------------------------------*
* E N D - O F - S E L E C T I O N
*---------------------------------------------------------------------*
END-OF-SELECTION.
*-Populate Fieldcatalog
it_fcat-coltext = 'Document'.
APPEND it_fcat.
it_fcat-coltext = 'Docuemtn code '.
APPEND it_fcat.
it_fcat-coltext = 'Date'.
APPEND it_fcat.
it_fcat-coltext = 'Cost'.
APPEND it_fcat.
it_fcat-coltext = 'Currency'.
APPEND it_fcat.
*-Fill the Column headings and Properties
LOOPAT it_fcat.
w_head-text = it_fcat-coltext.
*-Populate the Column Headings
CALLFUNCTION'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = w_head-text
fgcolor = 'black'
* bgcolor = 'green'
TABLES
header = t_header.
*-Populate Column Properties
CALLFUNCTION'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
fgcolor = 'black'
size = '3'
TABLES
fields = t_fields.
ENDLOOP.
*-Title of the Display
wa_header-text = 'Change details' .
wa_header-font = 'Arial'.
wa_header-size = '2'.
*-Preparing the HTML from Intenal Table
REFRESH t_html.
CALLFUNCTION'WWW_ITAB_TO_HTML'
EXPORTING
table_header = wa_header
TABLES
html = t_html
fields = t_fields
row_header = t_header
itable = it_sflight.
DATA : wa_doc_chng_mail TYPE sodocchgi1,
tb_receivers_mail TYPESTANDARDTABLEOF somlreci1,
wa_receivers_mail LIKELINEOF tb_receivers_mail.
wa_doc_chng_mail-expiry_dat = sy-datum + 1.
*wa_doc_chng_mail-obj_descr = p_mail_object.
wa_doc_chng_mail-sensitivty = 'F'.
wa_doc_chng_mail-doc_size = 5 * 255.
DATA :tb_objtxt_mail LIKE solisti1 OCCURS20,
wa_objtxt_mail TYPE solisti1.
wa_objtxt_mail-line = '<BR>The price will validate </BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Date: 08/26/2014</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Model: H7450</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Customer Reference: 237791AM</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Vehicle Order Number: 0012166588</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Sales order number:0080890758</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>SOLD TO: 0000100056</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>SHIP TO: 0000100056</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
wa_objtxt_mail-line = '<BR>Order Type: Indirect sales NV</BR>'.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
LOOPAT t_html INTO wa_html.
wa_objtxt_mail-line = wa_html-line.
APPEND wa_objtxt_mail TO tb_objtxt_mail.
CLEAR : wa_objtxt_mail ,wa_html.
ENDLOOP.
wa_receivers_mail-receiver = 'give ur email ID'.
APPEND wa_receivers_mail TO tb_receivers_mail.
DATA tbl_pack TYPETABLEOF sopcklsti1.
DATA stl_pack TYPE sopcklsti1.
stl_pack-transf_bin = space.
stl_pack-head_start = 1.
stl_pack-head_num = 0.
stl_pack-body_start = 1.
DESCRIBETABLE tb_objtxt_mail.
stl_pack-body_num = sy-tfill.
stl_pack-doc_type = 'HTM'.
APPEND stl_pack TO tbl_pack.
CLEAR stl_pack.
DATA tb_attachment TYPETABLEOF solisti1.
CALLFUNCTION'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_chng_mail
put_in_outbox = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
commit_work = 'X'
* IP_ENCRYPT =
* IP_SIGN =
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
packing_list = tbl_pack
* OBJECT_HEADER =
CONTENTS_BIN = tb_attachment
contents_txt = tb_objtxt_mail
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = tb_receivers_mail
* EXCEPTIONS
* TOO_MANY_RECEIVERS = 1
* DOCUMENT_NOT_SENT = 2
* DOCUMENT_TYPE_NOT_EXIST = 3
* OPERATION_NO_AUTHORIZATION = 4
* PARAMETER_ERROR = 5
* X_ERROR = 6
* ENQUEUE_ERROR = 7
* OTHERS = 8
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
tried using both FM SO_DOCUMENT_SEND_API1 or SO_NEW_DOCUMENT_SEND_API1.
Please help me with is, where i am going wrong.
Appriciate all you responses, i am in need of solution.
Regards,
Jayant.