ABAP Code Sample For General Browser Using ABAP
ABAP Code Sample For General Browser Using ABAP
Applies To:
SAP / ABAP
Summary
Here is an ABAP code sample that deals with viewing files/pictures using HTML Control
This can also be used as a General Web Browser.
By : Immanuel Daniel
Company : Wipro Technologies
Date : 21 February 2005
Code
*&---------------------------------------------------------------------*
*& Report ZBROWSER *
*&---------------------------------------------------------------------*
************************************************************************
* Description : Using HTML Control as General WWW Browser *
* Author : Immanuel Daniel *
************************************************************************
REPORT zbrowser .
TABLES : sscrfields.
INCLUDE <ctldef>.
INCLUDE <icon>.
© 2005 SAP AG 1
General Browser to View
Files/Pictures & WebPages
SELECTION-SCREEN COMMENT 45(50) comment1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(28) comment2 FOR FIELD url.
SELECTION-SCREEN POSITION 31.
PARAMETERS : url(1064) LOWER CASE .
SELECTION-SCREEN PUSHBUTTON 79(4) open USER-COMMAND open.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
open = icon_transfer .
sscrfields-functxt_05 = icon_sap.
sscrfields-functxt_04 = icon_booking_stop.
sscrfields-functxt_03 = icon_refresh.
sscrfields-functxt_02 = icon_arrow_right.
sscrfields-functxt_01 = icon_arrow_left.
repid = sy-repid.
dynnr = '1000'.
it_exclude-fcode = 'ONLI'.
APPEND it_exclude.
it_exclude-fcode = 'INFO'.
APPEND it_exclude.
*Changing GUI status
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
* p_program = repid
TABLES
p_exclude = it_exclude.
© 2005 SAP AG 2
General Browser to View
Files/Pictures & WebPages
OTHERS =3
.
IF sy-subrc <> 0.
EXIT.
ENDIF.
AT SELECTION-SCREEN.
cmd = sscrfields-ucomm.
CASE cmd.
WHEN 'OPEN'.
PERFORM load_html_page.
CALL FUNCTION 'CONTROL_FLUSH'.
IF sy-subrc <> 0.
EXIT.
ENDIF.
© 2005 SAP AG 3
General Browser to View
Files/Pictures & WebPages
PERFORM get_current_url.
IF sy-subrc <> 0.
EXIT.
ENDIF.
PERFORM get_current_url.
IF sy-subrc <> 0.
EXIT.
ENDIF.
PERFORM get_current_url.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-subrc <> 0.
EXIT.
ENDIF.
PERFORM get_current_url.
CALL FUNCTION 'CONTROL_FLUSH'.
WHEN OTHERS.
© 2005 SAP AG 4
General Browser to View
Files/Pictures & WebPages
CALL FUNCTION 'CONTROL_DISPATCH'
EXPORTING
fcode = cmd.
ENDCASE.
CLEAR cmd.
CALL FUNCTION 'CONTROL_FLUSH'.
*&---------------------------------------------------------------------
*& Form get_page_name
*&---------------------------------------------------------------------
* Get Page Name
*----------------------------------------------------------------------
FORM get_file_name.
*&---------------------------------------------------------------------
*& Form load_html_page
*&---------------------------------------------------------------------
* TO load the file (URL)
© 2005 SAP AG 5
General Browser to View
Files/Pictures & WebPages
*----------------------------------------------------------------------
FORM load_html_page.
flag = 'X'.
*&---------------------------------------------------------------------*
*& Form get_current_url
*&---------------------------------------------------------------------*
* Get Current URL
*----------------------------------------------------------------------*
FORM get_current_url.
CALL FUNCTION 'HTMLCNTL_GET_CURRENT_URL'
EXPORTING
h_control = h_html_ctrl
IMPORTING
url = url.
© 2005 SAP AG 6
General Browser to View
Files/Pictures & WebPages
Screen Shots
Displaying a webpage
© 2005 SAP AG 7
General Browser to View
Files/Pictures & WebPages
Displaying a Picture
© 2005 SAP AG 8
General Browser to View
Files/Pictures & WebPages
Displaying a Text File
Copyright © 2005 SAP AG, Inc. All Rights Reserved. SAP, mySAP, mySAP.com, xApps, xApp, and other SAP products and services
mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other
countries all over the world. All other product, service names, trademarks and registered trademarks mentioned are the trademarks of
their respective owners.
© 2005 SAP AG 9