Application Development and Automation 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: 
Read only

refresh a html container from an outside program

Former Member
0 Likes
1,064

hi experts,

I call a subscreen from program1 inside of a screen of program2. inside the subscreen there is an html container displaying a web page.

Is there a way to manually perform a command(say via a button) on this html control from program2?

many thanks

stan

2 REPLIES 2
Read only

Former Member
0 Likes
526

Hi Stanley,

Once you have called the screen of the other program from your current program, you can perform the different actions you need as shown in the code below:

report zdisp_web no standard page heading line-size 255.

type-pools: icon.

class cls_event_handler definition deferred.

parameters: url(100) type c.

data:

  • Push button

goto_url(20) ,"VALUE 'Go To Url',

okcode like sy-ucomm,

  • Container for html viewer

go_html_container type ref to cl_gui_custom_container,

  • HTML viewer

go_htmlviewer type ref to cl_gui_html_viewer,

  • Container for toolbar

go_toolbar_container type ref to cl_gui_custom_container,

  • SAP Toolbar

go_toolbar type ref to cl_gui_toolbar,

  • Event handler for toolbar

go_event_handler type ref to cls_event_handler,

  • Variable for URL text field on screen 100

g_screen100_url_text(255) type c value 'www.google.com',

g_screen100_display_url(255) type c,

  • Table for button group

gt_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.

gt_events type cntl_simple_events,

  • Workspace for table gt_events

gs_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'.

message 'BACK' type 'I'.

call method go_htmlviewer->go_back

exceptions

cntl_error = 1.

when 'FORWARD'.

message 'FORWARD' type 'I'.

call method go_htmlviewer->go_forward

exceptions

cntl_error = 1.

when 'STOP' .

message 'STOP' type 'I'.

call method go_htmlviewer->stop

exceptions

cntl_error = 1.

when 'REFRESH'.

message 'REFRESH' type 'I'.

call method go_htmlviewer->do_refresh

exceptions

cntl_error = 1.

when 'HOME' or 'OKAY'.

call method go_htmlviewer->go_home

exceptions

cntl_error = 1.

when 'EXIT' or 'CANCEL' .

message 'EXIT' type 'I'.

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

g_screen100_display_url = url.

endmethod. "on_navigate_complete

endclass. "cls_event_handler IMPLEMENTATION

----


  • Module STATUS_0100 OUTPUT

----


module status_0100 output.

set pf-status 'PFSTATUS_100'.

check go_html_container is initial.

  • Create container for HTML viewer

create object go_html_container

exporting container_name = 'HTML_CONTAINER'

exceptions cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc ne 0.

message e208(00)

with 'The control HTML_CONTAINER could not be created'.

endif.

  • Create HTML viewer

create object go_htmlviewer

exporting parent = go_html_container.

  • Create container for toolbar

create object go_toolbar_container

exporting container_name = 'TOOLBAR_CONTAINER'

exceptions cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc ne 0.

message e208(00)

with 'The control TOOLBAR_CONTAINER could not be created'.

endif.

  • Create toolbar

create object go_toolbar

exporting parent = go_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 gs_event.

refresh gt_events.

gs_event-eventid = go_toolbar->m_id_function_selected.

gs_event-appl_event = 'X'. " This is an application event

append gs_event to gt_events.

gs_event-eventid = go_htmlviewer->m_id_navigate_complete.

append gs_event to gt_events.

  • Use the events table to register events for the control

call method go_toolbar->set_registered_events

exporting

events = gt_events.

call method go_htmlviewer->set_registered_events

exporting

events = gt_events.

  • Create event handlers

create object go_event_handler.

set handler go_event_handler->on_function_selected

for go_toolbar.

set handler go_event_handler->on_navigate_complete

for go_htmlviewer.

g_screen100_url_text = url.

perform goto_url.

endmodule. " STATUS_0100 OUTPUT

----


  • Module USER_COMMAND_0100 INPUT

----


module user_command_0100 input.

  • Handles the pushbutton for goto url(pushbutton has been deleted from

*original code by punnu.

okcode = sy-ucomm.

case okcode.

when 'GOTOURL'.

when '&IC1' or 'EXEC'.

message 'OPENING SITE' type 'I'.

perform goto_url.

when 'BACK'.

leave to screen '0'.

when 'CANCEL' or 'EXIT'.

leave program.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

----


  • Form add_button_group

----


  • Adds a button group to the toolbar

----


form add_button_group.

define m_add_button.

call method cl_gui_toolbar=>fill_buttons_data_table

exporting

fcode = &1

icon = &2

butn_type = cntb_btype_button

text = &3

quickinfo = &4

changing

data_table = gt_button_group.

end-of-definition.

m_add_button 'BACK' icon_arrow_left '' 'Go back'.

m_add_button 'FORWARD' icon_arrow_right '' 'Go forward'.

m_add_button 'STOP' icon_breakpoint '' 'Stop'.

m_add_button 'REFRESH' icon_refresh '' 'Refresh'.

m_add_button 'HOME' '' 'Home' 'Home'.

m_add_button 'EXIT' icon_close '' 'Close program'.

  • Add button group to toolbar

call method go_toolbar->add_button_group

exporting

data_table = gt_button_group.

endform. " ADD_BUTTON_GROUP

----


  • Form goto_url

----


  • Calls method SHOW_URL to navigate to an URL

----


form goto_url.

check not g_screen100_url_text is initial.

call method go_htmlviewer->show_url

exporting

url = g_screen100_url_text.

endform. " GOTO_URL

Read only

0 Likes
526

hi, thanks for answering. in your solution you're suggesting I create a toolbar container in the same subscreen. this is not what I meant. what I need is a way to control the subscreen behavior using the events of the program I'm calling it from. ie. the toolbar must not be in the subscreen but in the main screen of the calling program.