Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to call browser in custom control

Former Member
0 Kudos

Hi experts,

Please help. I need to call internet explorer in custom control.please give the complete step.

thanks in advance.

2 REPLIES 2

uwe_schieferstein
Active Contributor
0 Kudos

Hello Abhishek

I assume sample report ZUS_SDN_SAP_PDF_VIEWER_DEMO fulfills your requirement.


REPORT ZUS_SDN_SAP_PDF_VIEWER_DEMO .
*&---------------------------------------------------------------------*
*& Thread: how to call browser in custom control
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1173671"></a>
*&---------------------------------------------------------------------*

  data: my_pdf_viewer     type ref to cl_gui_pdfviewer,
        my_main_container type ref to cl_gui_custom_container,
        entry1(100) type c,
        entry2(100) type c.

  data: okcode type sy-ucomm.

  include pdf_demo_event_receiver.

  data: l_event_receiver type ref to lcl_pdf_demo_event_receiver.

  start-of-selection.

  set screen 100.


*&---------------------------------------------------------------------*
*&      Module  pbo_0100  OUTPUT
*&---------------------------------------------------------------------*
module pbo_0100 output.

  set pf-status 'STATUS100'.
  set titlebar  'TITLE100'.

  " ----------------------------------------
  " running down the pbo for the first time,
  " create the controls and their containers
  if my_main_container is initial.
    create object my_main_container
      exporting
        container_name = 'CUSTOM_CNTL'
      exceptions
        cntl_error     = 1
        others         = 2.
    if sy-subrc <> 0.
      exit.
    else.

    " -----------------------------------
    " create PDF Viewer object
    create object my_pdf_viewer
      exporting
        parent              = my_main_container
      exceptions
        cntl_error          = 1
        cntl_system_error   = 2
        others              = 3.
      if sy-subrc <> 0.
        "could not create PDF Viewer
      endif.
    endif.

    data: view_buttons_active type char01.
    if my_pdf_viewer->acrobat_vs_reader = ''.
      view_buttons_active = 'X'.
    endif.

    " -----------------------------------
    " create SAP toolbar for PDF Viewer
    call method my_pdf_viewer->create_toolbar
      exporting
        tool_buttons      = 'X'
        view_buttons      = view_buttons_active
      exceptions
        cntl_error        = 1
        cntl_system_error = 2
        others            = 3.
    if sy-subrc <> 0.
      "could not create toolbar
    endif.

    create object l_event_receiver.
    set handler l_event_receiver->on_document_saved for my_pdf_viewer.
    set handler l_event_receiver->on_viewing_finished for
 my_pdf_viewer.

    if not my_pdf_viewer->html_viewer is initial.
      call method my_pdf_viewer->open_document
        exporting
          "url = 'http://p34198/iissamples/default/ReadMe.pdf'.
          url = 'https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907'
**          url = 'file:///C:	emp	mpGridDoc.pdf'.
      .
    endif.

  endif.

endmodule.                 " pbo_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  pai_0100  INPUT
*&---------------------------------------------------------------------*
module pai_0100 input.
  case okcode.
    when 'EXIT'.
      leave program.
    when 'LOADURL'.
      call method my_pdf_viewer->open_document
        exporting
          url = 'http://p34198/myweb/Devfaq.pdf'.
    when 'EVENT'.
      entry1 = l_event_receiver->entry_field1.
      entry2 = l_event_receiver->entry_field2.
  endcase.
endmodule.                 " pai_0100  INPUT

Regards

Uwe

Former Member
0 Kudos

Hi Abhishek,

Also look into the below sample program.... its using cl_gui_html_viewer.....

DATA: go_container       TYPE REF TO cl_gui_custom_container,
      go_html_control    TYPE REF TO cl_gui_html_viewer.

START-OF-SELECTION.

  CALL SCREEN 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'BASIC'.
  PERFORM create_objects.
ENDMODULE.                    "pbo OUTPUT
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
  LEAVE PROGRAM.
ENDMODULE.                    "pai INPUT



*----------------------------------------------------------------------*
FORM create_objects .
  IF go_container IS INITIAL.
    CREATE OBJECT go_container
      EXPORTING
        container_name = 'CUSTOM'.

    CREATE OBJECT go_html_control
      EXPORTING
        parent = go_container.

    CALL METHOD go_html_control->show_url
      EXPORTING
        url = '<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1173671"></a>'.
  ENDIF.
ENDFORM.                    " create_objects

Cheers,

Jose.