Skip to Content
0

SET_SCRIPT / EXECUTE_SCRIPT not working in SAP GUI for HTML

Feb 21, 2017 at 03:57 PM

96

avatar image

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

Alexander

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sandra Rossi Feb 21, 2017 at 06:26 PM
0

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
    importing
      !PARENT type ref to CL_GUI_CONTAINER.
    methods execute_a_script.
endclass.
*
class lcl_html implementation.
  method constructor.
    call method super->constructor
      EXPORTING
        parent = parent
      EXCEPTIONS
        others = 1.
  endmethod.
  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 ).
  endmethod.
endclass.
Share
10 |10000 characters needed characters left characters exceeded
Alexander Kreutner Feb 22, 2017 at 08:09 AM
0

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.

DATA:
  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 ).

me->set_script(
    EXPORTING
       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

Alexander

Share
10 |10000 characters needed characters left characters exceeded