I can display an image and a button in the HTML viewer, but I am struggling to put an image on a button.
Here is my program flow:
1. Create CL_GUI_HTML_VIEWER object.
2. Use LOAD_MIME_OBJECT to get the URL for an existing image.
3. Pass assigned URL to custom method to build HTML code table (see below).
4. Call LOAD_DATA to load HTML code.
5. Call SHOW_URL to display HTML code.
Here is the method used to load the HTML code in step 3. lv_image_url is the assigned URL from step 2.
data lv_w3_html type w3_html.
define add_html.
append &1 to lt_html_button.
end-of-definition.
concatenate ' background: url ("'
lv_image_url
'") no-repeat;'
into lv_w3_html.
refresh lt_html_button.
add_html:
'<html>',
'<style type="text/css">',
'body{margin: 0; padding: 0; background: white; overflow: auto; }',
'input.fbutton{',
' font-size: 24px;',
' font-weight: bold;',
' width: 100%;',
' height: 152px;',
' background-color: orange;',
' border-style: single;',
lv_w3_html,
' cursor: pointer;}',
'</style>',
'<body>',
'<FORM name="2050_SEARCH_BUTTON"',
' method=post',
' action=SAPEVENT:2050_SEARCH_BUTTON>',
'<input type=submit name="SEARCH_BUTTON"',
' class="fbutton" value="Search"',
' title="">',
'</form>',
'</body>',
'</html>'.
This gives me an orange button with the label "Search" as expected, but it fails to display the image. I have also validated that lv_w3_html includes the URL from step 2. Furthermore, all method calls complete successfully (no error status).
Did anybody get this to work? Any suggestions? Is it possible that the SAP HTML layer doesn't understand the CSS to load a background image into a button?
Thank you!