Skip to Content
avatar image
Former Member


Hello together,

I'll hope you can help me with the following issue...

We're using class CL_GUI_HTML_VIEWER to create for example HTML Input fields within a normal dynpro Screen. The used HTML-Templates include some JavaScript coding which will be raised via SET_SCRIPT/EXECUTE_SCRIPT methods of class CL_GUI_HTML_VIEWER. We'll receive Information from the HTML object via the SAPEVENT Options provided by SAP. With the including Javascript we'll Change for example the Option "checked" for radiobuttons.

The whole process is working very well in the SAP GUI for Windows Environment. Unfortunatelly we'll Need that Scenario in the SAP GUI for HTML (webgui) Environment as well. Due to the fact that the webgui already includes a lot of JavaScript by Default, I've never thought this would be an issue, but the Javascipt won't be executed in this Environment.

Has anybody already had the Need to Trigger JavaScript from ABAP using the SAP GUI for HTML? Please give me a hint!

Thank you very much!

Best regards


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Feb 21, 2017 at 06:26 PM

    Here is a non-functional example which shows the principle: you must define a subclass.

    class lcl_html definition INHERITING FROM cl_gui_html_viewer.
      public section.
      methods CONSTRUCTOR
          !PARENT type ref to CL_GUI_CONTAINER.
        methods execute_a_script.
    class lcl_html implementation.
      method constructor.
        call method super->constructor
            parent = parent
            others = 1.
      method execute_a_script.
        data scripttab type soli_tab.
        data script type string.
        script = |document.getElementById("regex").value = "aaaaa";|.
        scripttab = cl_bcs_convert=>string_to_soli( script ).
        set_script( script = scripttab ).
        execute_script( EXCEPTIONS dp_error = 1 cntl_error = 2 ).
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 22, 2017 at 08:09 AM

    Hello Sandra,

    thank you very much for your quick Response. Unfortunately the SET_SCRIPT / EXECUTE_SCRIPT is not working in the SAP GUI for HTML (webgui). In SAP GUI for Windows your coding is working great.

    Within my HTML Viewer object I've created some Radio Buttons. This HTML page also includes the following JavaScript function.

    function set_checked(id){
    	if(document.getElementById(id).checked == true ) {
    		document.getElementById(id).checked = false;
    	else {
    		document.getElementById(id).checked = true;

    Within my ABAP coding I'll Trigger the JavaScript by using methods set_script / execute_script of class CL_GUI_HTML_VIEWER.

      lv_script TYPE string,
      lt_script type soli_tab.
    lv_script = 'set_checked(''' && iv_id && ''');'.
    lt_script = cl_bcs_convert=>string_to_soli( lv_script ).
           script = lt_script ).
    me->execute_script( ).

    I'll don't get an error, but as already mentioned in SAP GUI for HTML nothing happend.

    Is there another method/function to Trigger JavaScripts in SAP GUI for HTML?

    Thank you very much!

    best regards


    Add comment
    10|10000 characters needed characters exceeded

  • Mar 17, 2018 at 10:44 PM

    Hi Alexander,

    It is not recommended to use javascript functions from the HTML Viewer inside WEBGUI.
    There is a mix of js environments.

    You should develop a regular dynpro t-code and then call it via WEBGUI.


    Add comment
    10|10000 characters needed characters exceeded