Sunday, 18 January 2009

Call Browser from SAP

This program shows how to call the Browser from SAP.

*Global data declarations
CONSTANTS:
c_selected TYPE flag VALUE 'X'.

* SELECTION-SCREEN declarations
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-002. "Document Source Section
PARAMETERS:
rb_ossnt RADIOBUTTON GROUP grp1,
rb_sdn RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK blk1.

PARAMETERS:
p_dlink TYPE char40.

*The following is the selection screen.



*--------------------------------------------------------------------*
* S T A R T - O F - S E L E C T I O N *
*--------------------------------------------------------------------*

START-OF-SELECTION.

* Show document from Nestool/Peregrine/SAP Portal
PERFORM show_document_link.

*&---------------------------------------------------------------------*
*& Form SHOW_DOCUMENT_LINK
*&---------------------------------------------------------------------*
* Show document from SAP Portal/SDN
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_document_link.
* Local data declarations
DATA: l_v_url TYPE char0241.

* Display documents according to the selection made

CASE c_selected.

* Show SAP OSS Note
WHEN rb_ossnt.

CONCATENATE 'https://service.sap.com/sap/support/notes/'
p_dlink INTO l_v_url.

PERFORM call_browser USING l_v_url.

WHEN rb_sdn.

l_v_url = 'https://www.sdn.sap.com'.
PERFORM call_browser USING l_v_url.
ENDCASE.

ENDFORM. " SHOW_DOCUMENT_LINK *&---------------------------------------------------------------------*
*& Form CALL_BROWSER *&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_V_DOCLINK text
*----------------------------------------------------------------------*
FORM call_browser USING fp_l_v_url TYPE char0241.

* Remove Gaps

CONDENSE fp_l_v_url NO-GAPS.

* Call browser to display the corresponding document.

CALL FUNCTION 'CALL_BROWSER'
EXPORTING
url = fp_l_v_url
new_window = c_selected
EXCEPTIONS
OTHERS = 6.

* In case of failure issue specific system message if raised otherwise
* give a generic error message.

IF sy-subrc <> 0.
IF NOT sy-msgid IS INITIAL.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4.
ELSE.
* Show message: Error in calling the browser
MESSAGE 'Error in calling the browser' TYPE 'E'.
ENDIF.
ENDIF.

ENDFORM. " CALL_BROWSER

No comments: