SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

HTML броузер



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu May 29, 2008 4:59 pm    Post subject: HTML броузер Reply with quote

Code:
*&---------------------------------------------------------------------*
*& Report  SAPHTML_DEMO1                                               *
*&---------------------------------------------------------------------*
REPORT  ZERUB_EXEC_HTML_INTERACTIVE.

DATA: html_control TYPE REF TO cl_gui_html_viewer,
      my_container TYPE REF TO cl_gui_custom_container,
      fcode LIKE sy-ucomm,
      myevent_tab TYPE cntl_simple_events,
      myevent TYPE cntl_simple_event,
      edurl(2048),
      alignment TYPE i.

*****************************************************
*              CLASS cl_myevent_handler             *
*****************************************************
CLASS cl_myevent_handler DEFINITION.

  PUBLIC SECTION.
    METHODS: on_navigate_complete
               FOR EVENT navigate_complete OF cl_gui_html_viewer
               IMPORTING url,
             on_sapevent
               FOR EVENT sapevent OF cl_gui_html_viewer
                 IMPORTING action frame getdata postdata query_table.

ENDCLASS.

DATA: evt_receiver TYPE REF TO cl_myevent_handler.

SET SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'TESTHTM1'.
  SET TITLEBAR '001'.

  IF my_container IS INITIAL.

    CREATE OBJECT my_container
        EXPORTING
            container_name = 'HTML'
        EXCEPTIONS
            others = 1.
    CASE sy-subrc.
      WHEN 0.
*
      WHEN OTHERS.
        RAISE cntl_error.
    ENDCASE.
  ENDIF.

  IF html_control IS INITIAL.
    CREATE OBJECT html_control
         EXPORTING
              parent    = my_container.
    IF sy-subrc NE 0.
      RAISE cntl_error.
    ENDIF.

    alignment = html_control->align_at_left +
                html_control->align_at_right +
                html_control->align_at_top +
                html_control->align_at_bottom.

    CALL METHOD html_control->set_alignment
       EXPORTING
         alignment = alignment.

* register event
    myevent-eventid    = html_control->m_id_sapevent.
    myevent-appl_event = 'X'.
    APPEND myevent TO myevent_tab.

    myevent-eventid    = html_control->m_id_navigate_complete.
    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_navigate_complete
                FOR html_control.

    SET HANDLER evt_receiver->on_sapevent
                FOR html_control.

    PERFORM load_home_page.
  ENDIF.
ENDMODULE.                             " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE fcode.
    WHEN 'BACK'.
      IF NOT html_control IS INITIAL.
        CALL METHOD html_control->free.
        FREE html_control.
      ENDIF.
      IF NOT my_container IS INITIAL.
        CALL METHOD my_container->free
          EXCEPTIONS
            OTHERS = 1.
        IF sy-subrc <> 0.
*         MESSAGE E002 WITH F_RETURN.
        ENDIF.
        FREE my_container.
      ENDIF.

      LEAVE PROGRAM.

    WHEN 'HHOM'.                       " show the home page
      CALL METHOD html_control->go_home.

      CALL METHOD html_control->get_current_url
           IMPORTING
                url  = edurl.

    WHEN 'HBAK'.
      CALL METHOD html_control->go_back.

      CALL METHOD html_control->get_current_url
           IMPORTING
                url  = edurl.

    WHEN 'HFWD'.
      CALL METHOD html_control->go_forward.

      CALL METHOD html_control->get_current_url
           IMPORTING
                url  = edurl.

    WHEN 'HRFR'.
      CALL METHOD html_control->do_refresh.

      CALL METHOD html_control->get_current_url
           IMPORTING
                url  = edurl.

    WHEN 'HNAV'.
      IF NOT edurl IS INITIAL.
        CALL METHOD html_control->show_url
             EXPORTING
                  url = edurl
             EXCEPTIONS
                  cnht_error_parameter = 1
                  OTHERS = 2.
        IF sy-subrc GE 2.
          RAISE cntl_error.
        ENDIF.
      ENDIF.

    WHEN OTHERS.
      CALL METHOD cl_gui_cfw=>dispatch.

  ENDCASE.
  CLEAR fcode.
ENDMODULE.                             " USER_COMMAND_0100  INPUT

* Homepage form
FORM load_home_page.
  DATA: doc_url(128).
  DATA: lt_html   TYPE TABLE OF w3html INITIAL SIZE 10.
  DATA: lt_merge  TYPE SWWW_T_MERGE_TABLE.

*  CALL METHOD html_control->load_mime_object
*       EXPORTING
*            object_id    = 'HTMLCNTL_TESTHTM2_BACKGROUND'
*            object_url   = 'HOME_BACKGROUND.GIF'
*       IMPORTING
*            assigned_url = doc_url
*       EXCEPTIONS
*            OTHERS       = 1.
*
doc_url = text-URL. edurl = doc_url.
*
*  CALL METHOD html_control->load_html_document
*       EXPORTING
*            document_id  = 'HTMLCNTL_TESTEVNT_HOME'
**            DOCUMENT_URL = doc_url
*       IMPORTING
*            assigned_url = doc_url
*       CHANGING
*            merge_table  = lt_merge
*       EXCEPTIONS
*            OTHERS       = 1.
*
*  CASE sy-subrc.
*    WHEN 0.
*    WHEN 1.
*      RAISE dp_invalid_parameter.
*    WHEN OTHERS.
*      RAISE dp_error_general.
*  ENDCASE.
*
*  IF sy-subrc EQ 0.
    CALL METHOD html_control->show_url
         EXPORTING
              url = doc_url.
*  ENDIF.

ENDFORM.                               " LOAD_HOME_PAGE

****************************************************
*    cl_myevent_handler implementation             *
****************************************************
CLASS cl_myevent_handler IMPLEMENTATION.

  METHOD on_navigate_complete.
    edurl = url.
  ENDMETHOD.
*--
  METHOD on_sapevent.

  ENDMETHOD.

ENDCLASS.



screen_0100.txt
 Description:

Download
 Filename:  screen_0100.txt
 Filesize:  2.78 KB
 Downloaded:  1813 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.