cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic HTML generation

former_member206377
Active Contributor
0 Kudos

Hi All,

I would like to know how dynamic HTML can be generated in WD,.? Is there any method that can be used?

Thanks,

Vasuki

Accepted Solutions (0)

Answers (3)

Answers (3)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I think you do need to provide more details on what you want. Do you want to dynamically generate the Web Dynpro layout - in which case you can use the WDDOMODIFYVIEW. We can supply more details if that is what you want. Or do you actually some form of external HTML generation - and if so how do you want it displayed? Within WDA or in another window?

former_member206377
Active Contributor
0 Kudos

Hi Thomas,

I have to dynamically generate the API code for Google Maps . i need to alter the google API based on the address, icon to be displayed, pop up text etc. I can then call this generated html from an external window.

As u know we have standard template for the API except for few changes depending on the address , icons, etc,..

However i got a method "LOAD_DATA" of class CL_GUI_HTML_VIEWER whch can be used to load the HTML content in internal table and the importing parameter URL can be used as URL to be displayed.. BUt how do i pass the address ,icon to it dynamically ?

Thanks,

Vasuki

former_member206377
Active Contributor
0 Kudos

HI Thomas,

can i store the static text of the API which is always same i.e the code lines except the dynamically regquired data,as a html file in MIME , and insert the code for address, icon dynamically depending on the requirement..? If so, is there any Method that can read the contents of a MIME object and modify it dynamically?

Thanks,

Vasuki

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You can't use any functionality of CL_GUI_HTML_VIEWER and there is nothing like the load data when working in your situation. You would have to use the MIME Repository API (CL_MIME_REPOSITORY_API) to read the stored content into memory. You can then convert to a STRING and find and replace content using the text commands in ABAP.

former_member206377
Active Contributor
0 Kudos

Hi Thomas,

Just want to know , Why the class CL_GUI_HTML_VIEWER or its methods cannot be used?

what is the work around you would suggest in this case to use the Google API dynamically? Reading from the MIME repository,converting to a string and finding it and then modifying it is the only other option? isn't there any other way to dynamically generate the HTML page ?

Thanks,

Vasuki

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The CL_GUI* classes are designed for the SAPGUI. They have SAPGUI Control calls that aren't possible from within Web Dynpro because there is no connection to the SAPGUI. Most of the time you can't even do a create object on these classes from WDA because that would trigger calls to the control framework. If there are some static methods that are utilities, you might be able to re-use those.

>isn't there any other way to dynamically generate the HTML page ?

I provided my suggestion already in my previous post.

former_member206377
Active Contributor
0 Kudos

Hi Thomas,

Thanks for your reply.

As suggested by you, i am using "cl_mime_repository_api" for downloading and uploading the MIME rep objects.

IMy code is as follows :

data :

mime_repository type ref to if_mr_api,

content type xstring,

mime_type type string,

url type string value 'SAP/BC/WebDynpro/SAP/ZDFPS_WD_GOOGLEMAP'.

mime_repository = cl_mime_repository_api=>get_api( ).

call method mime_repository->get

exporting

i_url = url

importing

e_content = content

e_mime_type = mime_type.

In the debuging mode i notice that 'CONTENT' and MIME_TYPE are not getting populated.

Is the URL ('SAP/BC/WebDynpro/SAP/ZDFPS_WD_GOOGLEMAP')that i have passed is wrong?

This is for getting the contents of the mime repository, but i have stored a HTML file in repository, how can i change its contents(HTML code in it)?

Thanks,

Vasuki

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Is the URL ('SAP/BC/WebDynpro/SAP/ZDFPS_WD_GOOGLEMAP')that i have passed is wrong?

Yes. This is just a folder URL. You need to supply the URL for the object itself.

>This is for getting the contents of the mime repository, but i have stored a HTML file in repository, how can i change its contents(HTML code in it)?

It will be returned as an XSTRING. Convert the XSTRING to STRING. HTML is just a text document afterall. Use ABAP text manipulation statements (like FIND, REPLACE, CONCATENATE, etc) to manipulate the HTML content.

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Vasuki

create a dynamic HTML string lv_html_string and upload to ICM Cache by constructing a dynamic URL.

data: cached_response type ref to if_http_response.

create object cached_response

type

cl_http_response

exporting

add_c_msg = 1.

try. " ignore, if compression can not be switched on

call method cached_response->set_compression

exporting

options = cached_response->co_compress_based_on_mime_type

exceptions

others = 1.

catch cx_root.

endtry.

data: l_app_type type string.

cached_response->set_cdata( lv_html_string ).

l_app_type = 'text/html' .

cached_response->set_header_field( name = if_http_header_fields=>content_type

value = l_app_type ).

concatenate '/sap/public' '/' 'pagename.html' into lv_URL.

cl_http_server=>server_cache_upload( url = lv_url

response = cached_response

SCOPE = IHTTP_INV_global ).

lv_url is the link to a html page, put all the html content in lv_html_string.

Abhi

Former Member
0 Kudos

Hi,

Can you provide more inputs on your requirement.

In IF_WD_CONTEXT_NODE there is method TO_XML but not HTML.

I think HTML option is available in BSPs.

Do you want to have the HTML generation for UI elements?

Regards,

Lekha.