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

CL_GUI_HTML_VIEWER and external javascripts

Former Member
0 Likes
896

Hi,

is it possible to display HTML document what has a reference to the external file with javascripts (but it could be CSS styles as well ) what were generated by abap program as well.

So I need to generate a file with javascripts. Download it to the workstation and later display a HTML page in HTML viewer what has a reference to generated external file.

Thank you for any help.

Marian

1 REPLY 1
Read only

Former Member
0 Likes
544

Hi ,

I dont really understood the problem what you have but can give as simple sample code. This code reads a .txt file containg a html code and shows the output on html viewer.

&----


*& Report ZHTML_PROG *

*& *

&----


*& *

*& *

&----


REPORT ZHTML_PROG .

data: custom_control type ref to cl_gui_custom_container,

html_control type ref to cl_gui_html_viewer,

html_handle type ref to html_events.

data:it_W3HTML type standard table of W3HTML with header line.

data:HTML type standard table of W3HTML with header line.

DATA: doc_url0(80),

doc_url(80),

alignment type i, " Ausrichtung tree_control

okcode type sy-ucomm.

CONSTANTS: ALIGN_AT_LEFT TYPE I VALUE 1.

CONSTANTS: ALIGN_AT_RIGHT TYPE I VALUE 2.

CONSTANTS: ALIGN_AT_TOP TYPE I VALUE 4.

CONSTANTS: ALIGN_AT_BOTTOM TYPE I VALUE 8.

CONSTANTS: ALIGN_CENTERED TYPE I VALUE 16.

start-of-selection.

call screen 9006.

end-of-selection.

&----


*& Form call_context_menu

&----


  • text

----


  • -->P_ACTION text

----


FORM call_context_menu USING P_ACTION.

ENDFORM. " call_context_menu

&----


*& Module display_html OUTPUT

&----


  • text

----


MODULE display_html OUTPUT.

set pf-status '9006'.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'D:\281143\Sandy_signature\html.TXT'

  • FILETYPE = 'ASC'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = it_W3HTML[]

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • FILE_OPEN_ERROR = 2

  • FILE_READ_ERROR = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT CUSTOM_CONTROL

EXPORTING

CONTAINER_NAME = 'CONTAINER'

.

CREATE OBJECT HTML_CONTROL

EXPORTING

  • SHELLSTYLE =

PARENT = CUSTOM_CONTROL

  • LIFETIME = LIFETIME_DEFAULT

  • SAPHTMLP =

  • UIFLAG =

  • NAME =

  • SAPHTTP =

  • QUERY_TABLE_DISABLED =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_INSTALL_ERROR = 2

  • DP_INSTALL_ERROR = 3

  • DP_ERROR = 4

  • others = 5

.

alignment = align_at_left + align_at_right + align_at_top +

align_at_bottom.

CALL METHOD html_control->set_alignment

EXPORTING

alignment = alignment.

CALL METHOD HTML_CONTROL->LOAD_DATA

EXPORTING

  • URL =

TYPE = 'text'

SUBTYPE = 'html'

  • SIZE = 0

  • ENCODING =

  • CHARSET =

IMPORTING

ASSIGNED_URL = doc_url0

CHANGING

DATA_TABLE = it_W3HTML[]

  • EXCEPTIONS

  • DP_INVALID_PARAMETER = 1

  • DP_ERROR_GENERAL = 2

  • CNTL_ERROR = 3

  • others = 4

.

APPEND:

'<html><frameset>' TO html.

CONCATENATE

'<frame name=Frame0 src="'

doc_url0

'" scrolling=auto >'

INTO html.

APPEND html .

APPEND:

'</frameset></html>' TO html.

  • create final link to welcome-screen;

CALL METHOD html_control->load_data

EXPORTING

type = 'text'

subtype = 'html'

IMPORTING

assigned_url = doc_url

CHANGING

data_table = html[]

EXCEPTIONS

dp_invalid_parameter = 1

dp_error_general = 2

OTHERS = 3.

IF sy-subrc = 0.

ENDIF.

CALL METHOD html_control->show_data

EXPORTING

url = doc_url0.

ENDMODULE. " display_html OUTPUT

&----


*& Module USER_COMMAND_9006 INPUT

&----


  • text

----


MODULE USER_COMMAND_9006 INPUT.

if okcode = 'BACK'.

leave program.

endif.

ENDMODULE. " USER_COMMAND_9006 INPUT