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: 

How to display a HTML page using ABAP program.

Former Member
0 Kudos
5,472

Hi all,

I know that this is easy and possible too but I haven't worked on this kind yet. I need to display a screen/ABAP program like TCODE PPMDT, where an HTML page is to be displayed and on the click of the HTML links provided, I need to navigate to someother transaction codes.

Cheers,

Sam

1 ACCEPTED SOLUTION

Former Member
0 Kudos
777

Hi,

See this sample code

REPORT ZTESTHTML .

DATA: ok_code LIKE sy-ucomm,

myurl(132).

data: custom_container type ref to cl_gui_custom_container,

myhtml type ref to CL_GUI_HTML_VIEWER,

repid like sy-repid.

DATA events TYPE cntl_simple_events.

DATA wa_events TYPE cntl_simple_event.

----


  • CLASS lcl_event_receiver DEFINITION

----


  • ........ *

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

CLASS-METHODS NC_Handler

FOR EVENT NAVIGATE_COMPLETE OF CL_GUI_HTML_VIEWER

IMPORTING URL.

ENDCLASS.

----


  • CLASS lcl_event_receiver IMPLEMENTATION

----


  • ........ *

----


CLASS lcl_event_receiver IMPLEMENTATION.

METHOD NC_Handler.

myurl = URL.

ENDMETHOD.

ENDCLASS.

start-of-selection.

set screen 100.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'BACK'.

CALL METHOD myhtml->go_back

EXCEPTIONS cntl_error = 1.

if sy-subrc ne 0.

endif.

WHEN 'FORW'.

CALL METHOD myhtml->go_forward

EXCEPTIONS cntl_error = 1.

if sy-subrc ne 0.

endif.

WHEN 'STOP'.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'REFR'.

CALL METHOD myhtml->SHOW_URL

EXPORTING

URL = myurl

IN_PLACE = 'X'

FRAME = ''

EXCEPTIONS

CNTL_ERROR = 1

CNHT_ERROR_NOT_ALLOWED = 2

CNHT_ERROR_PARAMETER = 3

DP_ERROR_GENERAL = 4.

WHEN 'OTHERS'.

CALL METHOD CL_GUI_CFW=>DISPATCH.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MENU'.

if myhtml is initial.

CREATE OBJECT custom_container

EXPORTING

CONTAINER_NAME = 'CONTAINER1'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

CREATE OBJECT myhtml

EXPORTING

PARENT = custom_container

EXCEPTIONS

CNTL_ERROR = 1

CNTL_INSTALL_ERROR = 2

DP_INSTALL_ERROR = 3

DP_ERROR = 4.

wa_events-eventid = CL_GUI_HTML_VIEWER=>M_ID_NAVIGATE_COMPLETE .

wa_events-appl_event = 'X'.

APPEND wa_events TO events.

CALL METHOD myhtml->set_registered_events( events = events ).

SET HANDLER lcl_event_receiver=>NC_Handler FOR myhtml.

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS cntl_system_error = 1

cntl_error = 2.

endif.

ENDMODULE. " STATUS_0100 OUTPUT

Svetlin

6 REPLIES 6

Former Member
0 Kudos
777

Hi,

Check out the demo program <b>SAPHTML_EVENTS_DEMO</b>

See this thread

If u want a top-of-page in ALV grid, u can create a HTML page using <b>cl_dd_document</b> method.

Hope this helps.

Former Member
0 Kudos
777

You can see the SAPHTML_DEMO1

0 Kudos
777

check out transaction <b>DWDM</b> for all control based program examples.

Regards

Raja

Former Member
0 Kudos
777

Hi,

Check this link

http://www.sapgenie.com/abap/controls/htmlviewer.htm

Hope this helps u.

Thanks&Regards,

Ruthra.R

Former Member
0 Kudos
778

Hi,

See this sample code

REPORT ZTESTHTML .

DATA: ok_code LIKE sy-ucomm,

myurl(132).

data: custom_container type ref to cl_gui_custom_container,

myhtml type ref to CL_GUI_HTML_VIEWER,

repid like sy-repid.

DATA events TYPE cntl_simple_events.

DATA wa_events TYPE cntl_simple_event.

----


  • CLASS lcl_event_receiver DEFINITION

----


  • ........ *

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

CLASS-METHODS NC_Handler

FOR EVENT NAVIGATE_COMPLETE OF CL_GUI_HTML_VIEWER

IMPORTING URL.

ENDCLASS.

----


  • CLASS lcl_event_receiver IMPLEMENTATION

----


  • ........ *

----


CLASS lcl_event_receiver IMPLEMENTATION.

METHOD NC_Handler.

myurl = URL.

ENDMETHOD.

ENDCLASS.

start-of-selection.

set screen 100.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'BACK'.

CALL METHOD myhtml->go_back

EXCEPTIONS cntl_error = 1.

if sy-subrc ne 0.

endif.

WHEN 'FORW'.

CALL METHOD myhtml->go_forward

EXCEPTIONS cntl_error = 1.

if sy-subrc ne 0.

endif.

WHEN 'STOP'.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'REFR'.

CALL METHOD myhtml->SHOW_URL

EXPORTING

URL = myurl

IN_PLACE = 'X'

FRAME = ''

EXCEPTIONS

CNTL_ERROR = 1

CNHT_ERROR_NOT_ALLOWED = 2

CNHT_ERROR_PARAMETER = 3

DP_ERROR_GENERAL = 4.

WHEN 'OTHERS'.

CALL METHOD CL_GUI_CFW=>DISPATCH.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MENU'.

if myhtml is initial.

CREATE OBJECT custom_container

EXPORTING

CONTAINER_NAME = 'CONTAINER1'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

CREATE OBJECT myhtml

EXPORTING

PARENT = custom_container

EXCEPTIONS

CNTL_ERROR = 1

CNTL_INSTALL_ERROR = 2

DP_INSTALL_ERROR = 3

DP_ERROR = 4.

wa_events-eventid = CL_GUI_HTML_VIEWER=>M_ID_NAVIGATE_COMPLETE .

wa_events-appl_event = 'X'.

APPEND wa_events TO events.

CALL METHOD myhtml->set_registered_events( events = events ).

SET HANDLER lcl_event_receiver=>NC_Handler FOR myhtml.

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS cntl_system_error = 1

cntl_error = 2.

endif.

ENDMODULE. " STATUS_0100 OUTPUT

Svetlin

Former Member
0 Kudos
777

Hi all,

Thanks to everyone for your valuable suggestions. I can now go ahead creating a new screen for myself.

Cheers,

Sam