RE: SAP HTML Viewer – GET and POST method

      Hi gurus,

      I’m working with SAP HTML Viewer control. I’ve seen that with this controller i can load an external html page, such as

      in the SAPHTML_DEMO1 example report. I wonder if is possible provide data from the report to html page through the controller, and receive data from the html page, after a page submi, and acquire it from the ABAP side.

      Is it possible? Any idea?

      Thanks in advance for the help!



      Hi Davide ,   Copy Code CLASS cl_myevent_handler DEFINITION.   PUBLIC SECTION. METHODS: on_sapevent FOR EVENT sapevent OF cl_gui_html_viewer IMPORTING action frame getdata postdata query_table.   ENDCLASS. "cl_myevent_handler DEFINITION DATA: evt_receiver TYPE REF TO cl_myevent_handler.   Copy Code IF html_control IS INITIAL. prog_repid = sy-repid.   CREATE OBJECT my_container EXPORTING container_name = 'MAIN'.   CREATE OBJECT html_control EXPORTING parent = my_container. IF sy-subrc NE 0. * ENDIF.   * register event myevent-eventid = html_control->m_id_sapevent. myevent-appl_event = 'x'. APPEND myevent TO myevent_tab. CALL METHOD html_control->set_registered_events EXPORTING events = myevent_tab.   CREATE OBJECT evt_receiver.   SET HANDLER evt_receiver->on_sapevent FOR html_control.   DATA:…

      User Rating: Be the first one !
      alex Default Asked on November 2, 2016 in user interface-development.
      Add Comment
      1 Answers

        Hi Davide ,


        1. CLASS cl_myevent_handler DEFINITION.
        3. PUBLIC SECTION.
        4. METHODS: on_sapevent
        5. FOR EVENT sapevent OF cl_gui_html_viewer
        6. IMPORTING action frame getdata postdata query_table.
        8. ENDCLASS. “cl_myevent_handler DEFINITION
        9. DATA: evt_receiver TYPE REF TO cl_myevent_handler.


        1. IF html_control IS INITIAL.
        2. prog_repid = sy-repid.
        4. CREATE OBJECT my_container
        5. EXPORTING
        6. container_name = ‘MAIN’.
        8. CREATE OBJECT html_control
        9. EXPORTING
        10. parent = my_container.
        11. IF sy-subrc NE 0.
        12. *
        13. ENDIF.
        15. * register event
        16. myevent-eventid = html_control->m_id_sapevent.
        17. myevent-appl_event = ‘x’.
        18. APPEND myevent TO myevent_tab.
        19. CALL METHOD html_control->set_registered_events
        20. EXPORTING
        21. events = myevent_tab.
        23. CREATE OBJECT evt_receiver.
        25. SET HANDLER evt_receiver->on_sapevent
        26. FOR html_control.
        28. DATA: doc_url(80).
        30. CALL METHOD html_control->load_html_document
        31. EXPORTING
        32. document_id = ‘ZVTLM1’
        33. IMPORTING
        34. assigned_url = doc_url
        35. EXCEPTIONS
        36. OTHERS = 1.
        38. IF sy-subrc EQ 0.
        39. CALL METHOD html_control->show_url
        40. EXPORTING
        41. url = doc_url.
        42. ENDIF.



        CLASS cl_myevent_handler IMPLEMENTATION.


        METHOD on_sapevent.


        CLEAR edaction.

        CLEAR edframe.

        CLEAR edgetdata.

        CLEAR edpostdataline.


        edaction = action.

        edframe = frame.

        edgetdata = getdata.

        postdata_tab = postdata.

        IF NOT postdata_tab IS INITIAL.

        READ TABLE postdata_tab INDEX 1 INTO edpostdataline.


        edquery_table = query_table.

        • BREAK-POINT.

        CASE action.

        WHEN ‘VEHICLE’.

        PERFORM get_vehicle.

        WHEN ‘INVOICE’.

        PERFORM get_invoice.

        WHEN ‘REPORTS’.

        PERFORM reports.

        WHEN ‘PRINT’.

        PERFORM print_invoice.

        WHEN OTHERS.


        ENDMETHOD. “on_sapevent


        ENDCLASS. “cl_myevent_handler IMPLEMENTATION



        The event mechanism of the Control Framework allows you to use handler methods in your

        programs to react to events triggered by the control (for example, a double-click).1. Assume you are working with a custom control that has the ABAP wrapper cl_gui_xyz.

        DATA my_control TYPE REF TO cl_gui_xyz.

        Registering Events with the Control Framework

        2. Define an internal table (type cntl_simple_events) and a corresponding work area (type


        DATA events TYPE cntl_simple_events.

        DATA wa_events TYPE cntl_simple_event.

        3. Now fill the event table with the relevant events. To do this, you need the event ID

        (event_id field). You can find this information in the Class Browser by looking at the

        attributes of the class cl_gui_xyz. You must also decide whether the event is to be a

        system event (appl_event = ‘ ‘) or an application event (appl_event = ‘X’).

        wa_events-eventid = event_id.

        wa_events-appl_event = appl_event.

        APPEND wa_events TO events.

        4. You must now send the event table to the frontend so that it knows which events it has to

        direct to the backend.

        CALL METHOD my_control->set_registered_events

        events = events.

        To react to the events of you custom control, you must now specify a handler method for it. This

        can be either an instance method or a static method

        Hope this will help you.

        Please revert to me if you need more help in this.




        Add Comment

        Your Answer

        By posting your answer, you agree to the privacy policy and terms of service.