11-18-2017 6:58 AM
I have written the following code to convert an internal table to HTML. however, when i open the html attachment in the email, the allignment of some records (NOT ALL) is wrong, a few entries have been put at the top and the font color is purple for some entries at random. Please help.
my code :
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }
FORM itab_to_html2 TABLES t_gr
USING p_gr TYPE char30.
DATA:
lt_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE, "
lt_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE, "
lfs_header TYPE w3head,
lw_head TYPE w3head.
DATA: t_fcat TYPE lvc_t_fcat, "
wa_fcat LIKE LINE OF t_fcat.
*-Populate Fieldcatalog
REFRESH t_fcat. CLEAR wa_fcat.
wa_fcat-coltext = 'SN Number'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'CA Number'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Customer Name'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SR Type'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SR Category'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Mobility Indicator'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SR Status'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Group Resp ID'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Service Org'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Volatage Level'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Planning Dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Cons Comp Dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'KIV '.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Work Typ'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'No of poles'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'project no'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'contract strt dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SN No'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'KIV(meter)'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SO comp dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'CC paid dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'SD paid dt'.
APPEND wa_fcat TO t_fcat.
wa_fcat-coltext = 'Days on status'.
APPEND wa_fcat TO t_fcat.
" Fill the Column headings and Properties
LOOP AT t_fcat INTO wa_fcat.
lw_head-text = wa_fcat-coltext.
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = lw_head-text
fgcolor = 'black'
bgcolor = 'grey'
TABLES
header = lt_header.
*-Populate Column Properties
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
justified = 'justify'
fgcolor = 'black'
size = '1'
TABLES
fields = lt_fields.
ENDLOOP.
REFRESH t_fcat[].
*-Title of the Display
lfs_header-text ' Group Responsible FRONTLINER'
lfs_header-font = 'Arial'.
lfs_header-size = '2'.
untitled.png
*-Preparing the HTML from Intenal Table
REFRESH gt_html.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
EXPORTING
table_header = lfs_header
TABLES
html = gt_html
fields = lt_fields
row_header = lt_header
itable = t_gr.
CLEAR lfs_header.
LOOP AT gt_html INTO gwa_htmlline.
CONCATENATE gv_tmp_str gwa_htmlline INTO gv_tmp_str.
ENDLOOP .
REFRESH gt_html[].
IF NOT gv_tmp_str IS INITIAL.
CALL FUNCTION 'SSFH_STRING_TO_TABUTF8'
EXPORTING
cstr_input_data = gv_tmp_str
codepage = '4110'
* IMPORTING
* OSTR_INPUT_DATA_L =
TABLES
ostr_input_data = gt_table
EXCEPTIONS
conversion_error = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gt_attachment[] = gt_table[].
REFRESH: gt_table[].
CLEAR gv_tmp_str.
ENDIF.
ENDFORM.
11-18-2017 10:31 AM
WWW_ITAB_TO_HTML returns an HTML table with lines of 255 characters. If you want to transfer it to a STRING variable, it must be done by concatenation and by keeping the trailing blanks of all lines.
So, one obvious issue is about this line:
CONCATENATE gv_tmp_str gwa_htmlline INTO gv_tmp_str.
It must be replaced with:
CONCATENATE gv_tmp_str gwa_htmlline INTO gv_tmp_str RESPECTING BLANKS.
Note apart: you are using the unreleased function module SSFH_STRING_TO_TABUTF8 for code page conversion, instead use the class CL_ABAP_CODEPAGE (documented in the official ABAP documentation).
11-18-2017 10:31 AM
WWW_ITAB_TO_HTML returns an HTML table with lines of 255 characters. If you want to transfer it to a STRING variable, it must be done by concatenation and by keeping the trailing blanks of all lines.
So, one obvious issue is about this line:
CONCATENATE gv_tmp_str gwa_htmlline INTO gv_tmp_str.
It must be replaced with:
CONCATENATE gv_tmp_str gwa_htmlline INTO gv_tmp_str RESPECTING BLANKS.
Note apart: you are using the unreleased function module SSFH_STRING_TO_TABUTF8 for code page conversion, instead use the class CL_ABAP_CODEPAGE (documented in the official ABAP documentation).
11-27-2017 11:46 AM
Hi Sandra,
I really appreciate your help, my issue is resolved.
Thanks,
Animesh
03-27-2020 2:41 PM
11-28-2018 1:45 PM
Thanks for this solution it is extremely helpful for me. After 1 week of standard debugging I found this solution and resolve issue within 10 Sec. Thanks a ton Man!!!!
03-27-2020 2:57 PM