The report needs dynpro 2000 with a custom container 'CC' for the HTML control.
REPORT zjso_html_in_dynpro_event.
CLASS lcl_html DEFINITION.
PUBLIC SECTION.
CLASS-DATA: mo_cc TYPE REF TO cl_gui_custom_container.
CLASS-DATA: mo_html TYPE REF TO cl_gui_html_viewer.
CLASS-METHODS: pbo, user_command, leave_screen.
CLASS-METHODS on_sapevent FOR EVENT sapevent OF cl_gui_html_viewer
IMPORTING action frame getdata postdata query_table.
ENDCLASS.
START-OF-SELECTION.
CALL SCREEN 2000.
*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
SET TITLEBAR '2000'.
lcl_html=>pbo( ).
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_2000 INPUT.
lcl_html=>user_command( ).
ENDMODULE.
CLASS lcl_html IMPLEMENTATION.
METHOD pbo.
DATA lv_url TYPE text1024.
DATA lt_html TYPE STANDARD TABLE OF text1024 WITH DEFAULT KEY.
DATA lt_event TYPE cntl_simple_events.
CHECK mo_cc IS NOT BOUND.
lt_html = VALUE #(
( |<!DOCTYPE html><head>| )
( | <meta charset="utf-8">| )
( | <title>HTML in Dynpro</title>| )
( | <style>| )
( ' body { font-family:segoe ui, arial, helvetica; }' )
( | </style>| )
( |<script>| )
( |function onClick(source) \{| )
( | window.location.href = 'SAPEVENT:'+source.innerHTML;| )
( |\}| )
( |</script>| )
( |</head>| )
( |<body>| )
( | <p>Hello, world!</p>| )
( | <a href="SAPEVENT:Hyperlink">Request SAP AS</a>| )
( | <div onclick="onClick(this)" style="width: 120px; height: 120px; margin: 8px; background-color:#ef0000">red</div>| )
( | <div onclick="onClick(this)" style="width: 120px; height: 120px; margin: 8px; background-color:#ffdd00">yellow</div>| )
( | <div onclick="onClick(this)" style="width: 120px; height: 120px; margin: 8px; background-color:#00ee00">green</div>| )
( |</body></html>| )
).
mo_cc = NEW #( 'CC' ).
mo_html = NEW #( mo_cc ).
" setup event handler for SAPEVENT from HTML control
INSERT VALUE #( eventid = mo_html->m_id_sapevent appl_event = abap_true ) INTO TABLE lt_event.
mo_html->set_registered_events( lt_event ).
SET HANDLER on_sapevent FOR mo_html.
" populate HTML control with HTML page
mo_html->load_data(
IMPORTING assigned_url = lv_url
CHANGING data_table = lt_html
).
mo_html->show_url( lv_url ).
ENDMETHOD.
METHOD user_command.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT'. leave_screen( ). LEAVE TO SCREEN 0.
WHEN 'BACK' OR 'EXIT'. leave_screen( ). LEAVE PROGRAM.
ENDCASE.
ENDMETHOD.
METHOD leave_screen.
IF mo_cc IS BOUND.
mo_cc->free( ).
ENDIF.
ENDMETHOD.
METHOD on_sapevent.
MESSAGE |onClick = { action }| TYPE 'I'.
" check contents of { postdata } and { query_table } in debugger
ENDMETHOD.
ENDCLASS.
Subscribe to:
Post Comments (Atom)
SAP ABAP: Determine Timezone for Plant
DATA: lt_tzone TYPE STANDARD TABLE OF tznzone WITH DEFAULT KEY, l_tzone TYPE tznzone. " get time zone for plant ...
-
Sometimes the backend doesn't return the selected rows of an SALV. For my case get_metadata( ) was the solution: go_salv-> get_met...
-
GUIDs or UUIDs can be created with the class cl_system_uuid . try . data (lv_uuid) = cl_system_uuid => if_system_uuid_static...
-
AA PR-AUF(E) Prozessauftrag (eröffnet) AB PR-AUF(F) Prozessauftrag (freigegeben) AC FE...
No comments:
Post a Comment