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: 

Program to execute WWW

Former Member
0 Kudos
82

Hi Friends ,

Can anyone please give the solution for the following issue

To write an SAP program to execute the following.

http://133.0.1.91:7777/epaprod

http://pkg_epadb:7777/epaprod

Hosts:

Entry in hosts file.

133.0.1.91 pkg_epadb

Thanks in advance.

4 REPLIES 4

Former Member
0 Kudos
40

Hello,

Try with the FM <b>WS_EXECUTE</b>

Vasanth

Former Member
0 Kudos
40

Check the blog for running external commands..

/people/sameej.tk2/blog/2006/12/07/using-external-operating-system-commands

Regards,

Abhijit

Former Member
0 Kudos
40

&----


*& Report YH627_HTML_CONTROL

*&

&----


*&

*&

&----


REPORT YH627_HTML_CONTROL.

TYPE-POOLS: ICON.

CLASS CLS_EVENT_HANDLER DEFINITION DEFERRED.

*----


  • G L O B A L V A R I A B L E S

*----


DATA:

OK_CODE LIKE SY-UCOMM,

  • Container for html viewer

W_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

  • HTML viewer

W_HTMLVIEWER TYPE REF TO CL_GUI_HTML_VIEWER,

  • Container for toolbar

W_TOOLBAR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

  • SAP Toolbar

W_TOOLBAR TYPE REF TO CL_GUI_TOOLBAR,

  • Event handler for toolbar

W_EVENT_HANDLER TYPE REF TO CLS_EVENT_HANDLER,

  • Variable for URL text field on screen 100

W_SCREEN100_URL_TEXT(255) TYPE C,

W_SCREEN100_DISPLAY_URL(255) TYPE C.

*----


  • I N T E R N A L T A B L E S

*----


DATA:

  • Table for button group

T_BUTTON_GROUP TYPE TTB_BUTTON,

  • Table for registration of events. Note that a TYPE REF

  • to cls_event_handler must be created before you can

  • reference types cntl_simple_events and cntl_simple_event.

T_EVENTS TYPE CNTL_SIMPLE_EVENTS,

  • Workspace for table T_EVENTS

FS_EVENT TYPE CNTL_SIMPLE_EVENT.

START-OF-SELECTION.

SET SCREEN '100'.

----


  • CLASS cls_event_handler DEFINITION

*----


  • Handles events for the toolbar an the HTML viewer

----


CLASS CLS_EVENT_HANDLER DEFINITION.

PUBLIC SECTION.

METHODS:

  • Handles method function_selected for the toolbar control

ON_FUNCTION_SELECTED

FOR EVENT FUNCTION_SELECTED OF CL_GUI_TOOLBAR

IMPORTING FCODE,

  • Handles method navigate_complete for the HTML viewer control

ON_NAVIGATE_COMPLETE

FOR EVENT NAVIGATE_COMPLETE OF CL_GUI_HTML_VIEWER

IMPORTING URL.

ENDCLASS. " CLS_EVENT_HANDLER DEFINITION

----


  • CLASS cls_event_handler IMPLEMENTATION

----


*

----


CLASS CLS_EVENT_HANDLER IMPLEMENTATION.

  • Handles method function_selected for the toolbar control

METHOD ON_FUNCTION_SELECTED.

CASE FCODE.

WHEN 'BACK'.

CALL METHOD W_HTMLVIEWER->GO_BACK

EXCEPTIONS

CNTL_ERROR = 1.

WHEN 'FORWARD'.

CALL METHOD W_HTMLVIEWER->GO_FORWARD

EXCEPTIONS

CNTL_ERROR = 1.

WHEN 'STOP'.

CALL METHOD W_HTMLVIEWER->STOP

EXCEPTIONS

CNTL_ERROR = 1.

WHEN 'REFRESH'.

CALL METHOD W_HTMLVIEWER->DO_REFRESH

EXCEPTIONS

CNTL_ERROR = 1.

WHEN 'HOME'.

CALL METHOD W_HTMLVIEWER->GO_HOME

EXCEPTIONS

CNTL_ERROR = 1.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMETHOD. " ON_FUNCTION_SELECTED

  • Handles method navigate_complete for the HTML viewer control

METHOD ON_NAVIGATE_COMPLETE.

  • Display current URL in a textfield on the screen

W_SCREEN100_DISPLAY_URL = URL.

ENDMETHOD. " ON_FUNCTION_SELECTED

ENDCLASS. "CLS_EVENT_HANDLER IMPLEMENTATION

&----


*& Module STATUS_0100 OUTPUT

&----


MODULE STATUS_0100 OUTPUT.

IF W_HTML_CONTAINER IS INITIAL.

  • Create container for HTML viewer

CREATE OBJECT W_HTML_CONTAINER

EXPORTING

CONTAINER_NAME = 'HTML_CONTAINER'.

  • Create HTML viewer

CREATE OBJECT W_HTMLVIEWER

EXPORTING PARENT = W_HTML_CONTAINER.

  • Create container for toolbar

CREATE OBJECT W_TOOLBAR_CONTAINER

EXPORTING

CONTAINER_NAME = 'TOOLBAR_CONTAINER'.

  • Create toolbar

CREATE OBJECT W_TOOLBAR

EXPORTING

PARENT = W_TOOLBAR_CONTAINER.

  • Add buttons to the toolbar

PERFORM ADD_BUTTON_GROUP.

  • Create event table. The event ID must be found in the

  • documentation of the specific control

CLEAR FS_EVENT.

REFRESH T_EVENTS.

FS_EVENT-EVENTID = W_TOOLBAR->M_ID_FUNCTION_SELECTED.

FS_EVENT-APPL_EVENT = 'X'. " This is an application event

APPEND FS_EVENT TO T_EVENTS.

FS_EVENT-EVENTID = W_HTMLVIEWER->M_ID_NAVIGATE_COMPLETE.

APPEND FS_EVENT TO T_EVENTS.

  • Use the events table to register events for the control

CALL METHOD W_TOOLBAR->SET_REGISTERED_EVENTS

EXPORTING

EVENTS = T_EVENTS.

CALL METHOD W_HTMLVIEWER->SET_REGISTERED_EVENTS

EXPORTING

EVENTS = T_EVENTS.

  • Create event handlers

CREATE OBJECT W_EVENT_HANDLER.

SET HANDLER W_EVENT_HANDLER->ON_FUNCTION_SELECTED

FOR W_TOOLBAR.

SET HANDLER W_EVENT_HANDLER->ON_NAVIGATE_COMPLETE

FOR W_HTMLVIEWER.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


MODULE USER_COMMAND_0100 INPUT.

  • Handles the pushbutton for goto url

CASE OK_CODE.

WHEN 'GOTOURL'.

PERFORM GOTO_URL.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form add_button_group

&----


  • Adds a button group to the toolbar

*----


FORM ADD_BUTTON_GROUP.

  • BACK button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'BACK'

ICON = ICON_ARROW_LEFT

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = ''

QUICKINFO = 'Go back'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • FORWARD button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'FORWARD'

ICON = ICON_ARROW_RIGHT

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = ''

QUICKINFO = 'Go forward'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • STOP button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'STOP'

ICON = ICON_BREAKPOINT

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = ''

QUICKINFO = 'Stop'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • REFRESH button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'REFRESH'

ICON = ICON_REFRESH

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = ''

QUICKINFO = 'Refresh'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • Home button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'HOME'

ICON = ''

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = 'Home'

QUICKINFO = 'Home'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • Separator

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'SEP1'

ICON = ' '

BUTN_TYPE = CNTB_BTYPE_SEP

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • EXIT button

CALL METHOD CL_GUI_TOOLBAR=>FILL_BUTTONS_DATA_TABLE

EXPORTING

FCODE = 'EXIT'

ICON = ICON_CLOSE

BUTN_TYPE = CNTB_BTYPE_BUTTON

TEXT = ''

QUICKINFO = 'Close porgram'

CHANGING

DATA_TABLE = T_BUTTON_GROUP.

  • Add button group to toolbar

CALL METHOD W_TOOLBAR->ADD_BUTTON_GROUP

EXPORTING

DATA_TABLE = T_BUTTON_GROUP.

ENDFORM. " ADD_BUTTON_GROUP

&----


*& Form goto_url

&----


  • Calls method SHOW_URL to navigate to an URL

*----


FORM GOTO_URL.

CALL METHOD W_HTMLVIEWER->SHOW_URL

EXPORTING

URL = W_SCREEN100_URL_TEXT.

ENDFORM. " GOTO_URL

Before executing the program,

you need to define HTML container and TOOLBAR container....

So, double click on call screen 100 and then define the containers....

Then give the URL which you want to give and then execute the program....

Regards,

Pavan P.

jaideeps
Advisor
Advisor
0 Kudos
40

hi,

check out this and also refer to abapdocu->javascript...section

DATA: BEGIN OF URL_TABLE OCCURS 10,

L(25),

END OF URL_TABLE.

----


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

----


START-OF-SELECTION.

*-append internal table---

URL_TABLE-L = 'http://www.yahoomail.com'.

APPEND URL_TABLE.

URL_TABLE-L = 'http://www.gmail.com'.

APPEND URL_TABLE.

URL_TABLE-L = 'http://www.sap.com'.

APPEND URL_TABLE.

URL_TABLE-L = 'http://email.rapidigm.com'.

APPEND URL_TABLE.

----


  • P R I N T T H E U R L L I N K

----


LOOP AT URL_TABLE.

SKIP. FORMAT INTENSIFIED OFF.

WRITE: / 'Single click on '.

FORMAT HOTSPOT ON.

FORMAT INTENSIFIED ON.

WRITE: URL_TABLE.

HIDE URL_TABLE.

FORMAT HOTSPOT OFF.

FORMAT INTENSIFIED OFF.

WRITE: 'to go to', URL_TABLE.

ENDLOOP.

CLEAR URL_TABLE.

----


  • E V E N T F O R C L I C K

----


AT LINE-SELECTION.

IF NOT URL_TABLE IS INITIAL.

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

program = 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'

commandline = URL_TABLE

INFORM = ''

EXCEPTIONS

PROG_NOT_FOUND = 1.

*- sy-subrc check----

IF SY-SUBRC <> 0.

WRITE:/ 'Cannot find program to open Internet'.

ENDIF.

thanks

jaideep

*reward points if useful.