‎2021 Aug 19 6:13 AM
Hi all,
My html body for my emal gives a funny < character. I don't where its coming from after checking line by line.

* **** Email Content
CLEAR gw_text_bcsy.
REFRESH gw_text_bcsy.
CLEAR: gw_text,gw_text1,gw_text2,gw_text3,gw_text4.
* lv_text_name = 'ZFI_MISSING_ASSETS_EMAILCONTENT'.
*
* PERFORM f_get_email_text USING lv_text_name
* CHANGING gw_text_bcsy.
*
* lr_document = cl_document_bcs=>create_document(
* i_type = 'RAW'
* i_text = gw_text_bcsy
* i_subject = l_subject ).
CLEAR ls_lines.
ls_lines-tdline = '<html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
* *Set the Body background colour
CLEAR ls_lines.
ls_lines-tdline = '<body bgcolor = "#E6E6FA">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
* *Set font color and its type
* CONCATENATE '<FONT COLOR = "BLACK">' '<b>' INTO ls_lines-tdline.
ls_lines-tdline = '<FONT COLOR = "BLACK">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<p> Dear Custodian </p>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<p>Pls update below information in the attached asset list under columns K to M and reply us within 5 working days.</p>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
ls_lines-tdline = '(1) Asset Serial Number<br>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '(2) Asset Location<br>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '(3) Type of Asset Label (Refer to Note 1)<br>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<p>Note 1 - To complete if your RI has implemented the RFID tagging.</p>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
* Prepare data in table format to dispay in Mail body
CLEAR ls_lines.
ls_lines-tdline = '<table border="1">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TH>Tag No</TH>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TH>Type of Label Tag</TH>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TH>Suitability</TH>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' '1' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'Dogbone' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For non-metal assets (such as Tables, Chairs, Value Dry Cabinet)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' '2' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'Accessory Tag' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For small non-metal assets (such as Card Access System, Scanner AFM 30-Micron)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' '3' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'IQ400' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For metal assets (such as Desktop, Residual Gas Analyzer)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' '4' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'IQ150' '</FONT>'
'</td>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For small metal assets (such as Laptops, Magnetic Stirrer, Hotplate)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
MOVE '</TABLE>' TO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<p>Thank You</p>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</FONT></body></html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
lr_document = cl_document_bcs=>create_document(
i_type = 'HTM' "'RAW'
i_text = gw_text_bcsy
i_subject = l_subject ).
during debugging, my html code in tables as followed:



‎2021 Aug 19 1:36 PM
Got it. The row 21 is truncated after the 132th character:
<td align = "LEFT"><FONT COLOR = "BLACK">For small non-metal assets (such as Card Access System, Scanner AFM 30-Micron)</FONT></td><<br>Full minimal reproducible code:
DATA: gw_text_bcsy TYPE soli_tab,
ls_lines TYPE tline.
FIELD-SYMBOLS: <lfs_line> TYPE soli.
CLEAR ls_lines.
ls_lines-tdline = '<html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<body bgcolor = "#E6E6FA">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<table border="1">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TH>Suitability</TH>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For small non-metal assets (such as Card Access System, Scanner AFM 30-Micron)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
MOVE '</TABLE>' TO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</body></html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
DATA: send_request TYPE REF TO cl_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: bcs_exception TYPE REF TO cx_bcs.
TRY.
DATA(lr_document) = cl_document_bcs=>create_document(
i_type = 'HTM' "'RAW'
i_text = gw_text_bcsy
i_subject = 'l_subject' ).
send_request = cl_bcs=>create_persistent( ).
CALL METHOD send_request->set_document( lr_document ).
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
recipient = cl_cam_address_bcs=>create_internet_address(
'jane.doe@world.com' ).
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
CALL METHOD send_request->send( ).
COMMIT WORK.
CATCH cx_root INTO DATA(lx).
ENDTRY.Solution: you should better format your HTML code in a string variable to avoid getting truncated text, and finally convert it into the internal table using the method CL_BCS_CONVERT=>STRING_TO_SOLI.
‎2021 Aug 19 6:34 AM
There should be the option to display the HTML code in the context menu, and you will see that extra character. I hope there will be some clues around in that HTML code to understand what's going on.
‎2021 Aug 19 6:48 AM
sandra.rossi
option to display the HTML code in the context menu??? where?
The output is only viewable in sost
‎2021 Aug 19 7:46 AM
The context menu from inside the HTML Viewer control. If SAP has deactivated the context menu, it's possible to use the "F12 chooser" application to run the developer tools -> https://stackoverflow.com/questions/48710202/how-to-open-javascript-developer-console-from-sap-html-....
‎2021 Aug 19 11:44 AM
Have you tried to put your HTML into an IDE?
I noticed your code uses the FONT tag... it's deprecated (obsolete for html5)
https://www.w3schools.com/tags/tag_font.asp
Maybe your browser engine (html emails are opened through some sort of browser, I guess) messes them.
‎2021 Aug 19 12:19 PM
Back to what I previously said, I've just checked that the context menu in SOST has the option "Show source" which display the actual HTML code rendered, not the one you have passed to BCS.
‎2021 Aug 19 1:36 PM
Got it. The row 21 is truncated after the 132th character:
<td align = "LEFT"><FONT COLOR = "BLACK">For small non-metal assets (such as Card Access System, Scanner AFM 30-Micron)</FONT></td><<br>Full minimal reproducible code:
DATA: gw_text_bcsy TYPE soli_tab,
ls_lines TYPE tline.
FIELD-SYMBOLS: <lfs_line> TYPE soli.
CLEAR ls_lines.
ls_lines-tdline = '<html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<body bgcolor = "#E6E6FA">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<table border="1">'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '<TH>Suitability</TH>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</TR>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
CONCATENATE '<TR><td align = "LEFT">'
'<FONT COLOR = "BLACK">' 'For small non-metal assets (such as Card Access System, Scanner AFM 30-Micron)' '</FONT>'
'</td></tr>' INTO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
MOVE '</TABLE>' TO ls_lines-tdline.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
CLEAR ls_lines.
ls_lines-tdline = '</body></html>'.
APPEND INITIAL LINE TO gw_text_bcsy ASSIGNING <lfs_line>.
<lfs_line> = ls_lines-tdline.
DATA: send_request TYPE REF TO cl_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: bcs_exception TYPE REF TO cx_bcs.
TRY.
DATA(lr_document) = cl_document_bcs=>create_document(
i_type = 'HTM' "'RAW'
i_text = gw_text_bcsy
i_subject = 'l_subject' ).
send_request = cl_bcs=>create_persistent( ).
CALL METHOD send_request->set_document( lr_document ).
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
recipient = cl_cam_address_bcs=>create_internet_address(
'jane.doe@world.com' ).
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
CALL METHOD send_request->send( ).
COMMIT WORK.
CATCH cx_root INTO DATA(lx).
ENDTRY.Solution: you should better format your HTML code in a string variable to avoid getting truncated text, and finally convert it into the internal table using the method CL_BCS_CONVERT=>STRING_TO_SOLI.
‎2021 Aug 19 1:45 PM
How is "ASSERT" a debug helper? Ok, this is sample code, let's assume it is in a larger program: other than being easy to find when setting breakpoints and otherwise harmless, is there more to it?
‎2021 Aug 19 1:55 PM
c5e08e0478aa4727abc4482f5be390b2 🙂 I use it to set a static breakpoint for troubleshooting (show exception value if needed) because it's at the end of a reporting event, otherwise you don't have access anymore to the variables. But it shouldn't be in my answer, so I remove it 😉 Even CX_ROOT is lazy/invalid code, sorry 🙂
‎2021 Aug 20 2:28 AM
sandra.rossi
Thanks very much for your help!! Even when I see the internal table contents, there is no way I can which line seems to have the problem. What is this technique set a static breakpoint for troubleshooting though.?
‎2021 Aug 20 6:34 AM
I edited my question to remove the last line of the code which was "ASSERT 1 = 1." It's absolutely not related to your original question. I set a static breakpoint on this line to know the contents of variables at the end of the code in case the code is an executable program ("report"), because otherwise you can't know the result of the last line of code because the program is left immediately after the last statement. There is also the problem for the last line of each reporting event (like at selection-screen, etc.)
‎2021 Aug 20 6:38 AM
Concerning "there is no way I can know which line seems to have the problem". Yes there are two ways:
‎2024 Oct 19 9:41 AM
Here is the CL_BCS_CONVERT=>STRING_TO_SOLI method. there is no character limit.
DATA: lv_html TYPE string.
DATA: gw_text_bcsy TYPE soli_tab.
lv_html = '<html><body> html body or table data'.
lv_html = lv_html && '<table border="1">'.
lv_html = lv_html && '<TR><TH>Company</TH><TH>column label1.</TH><TH>column label2</TH></TR>'.
LOOP AT it_table INTO wa_area.
lv_html = lv_html && '<tr><td>' && wa_area-xxx && '</td><td>' && wa_area-xxx && '</td></tr>'
endloop.
lv_html = lv_html &&'</TABLE></body><html>'.
CALL METHOD cl_bcs_convert=>string_to_soli
EXPORTING
iv_string = lv_html
RECEIVING
et_soli = gw_text_bcsy.
CLEAR : lv_html.
Regards,
Dharmesh Thanki