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 - Read Checkbox value after user changes in screen

Former Member
0 Likes
1,641

I am displaying multiple checkboxes (based on my internal table fields, I am displaying 20+ checkboxes in screen) along with other input fields using CL_GUI_HTML_VIEWER in Modulepool screen. I am also using SAPEVENT to read the screen values. While I am able to read other input field values (PAI values) using GETDATA and QUERY_TABLE, but checkbox values are not retrieved in them. How to read the user changes of checkboxes (PAI changes) from my HTML page.

I referred standard demo programs, but checkboxes are handled outside of html container and not inside html page. Mostly they have only Input field or buttons, which in my case is working fine.

part of my code:

data: gr_browser   TYPE REF TO cl_gui_html_viewer,
      g_evt_receiver TYPE REF TO cl_myevent_handler.

***Below code in PBO

  CLEAR wa_event.
  wa_event-eventid = gr_browser->m_id_navigate_complete.
  wa_event-appl_event = 'X'.
  APPEND wa_event TO gt_event_tab.

  CALL METHOD gr_browser->set_registered_events
    EXPORTING
      events = gt_event_tab.

  CREATE OBJECT g_evt_receiver.

  SET HANDLER g_evt_receiver->on_sapevent "on_sapevent - I am handling PAI changes.
              FOR gr_browser.

*** Below code in TOP Include
**Local class  

CLASS cl_myevent_handler DEFINITION.
  PUBLIC SECTION.
    METHODS: on_sapevent
                  FOR EVENT sapevent OF cl_gui_html_viewer
      IMPORTING action frame getdata postdata query_table.
ENDCLASS.

CLASS cl_myevent_handler IMPLEMENTATION.
  METHOD on_sapevent.
     edaction       = action.
    edframe        = frame.
    edgetdata      = getdata.
    postdata_tab   = postdata.    
    edquery_table  = query_table.    
  ENDMETHOD.
ENDCLASS.

Thanks

I am displaying multiple checkboxes (based on my internal table fields, I am displaying 20+ checkboxes in screen) along with other input fields using CL_GUI_HTML_VIEWER in Modulepool screen. I am also using SAPEVENT to read the screen values. While I am able to read other input field values (PAI values) using GETDATA and QUERY_TABLE, but checkbox values are not retrieved in them. How to read the user changes of checkboxes (PAI changes) from my HTML page.

I referred standard demo programs, but checkboxes are handled outside of html container and not inside html page. Mostly they have only Input field or buttons, which in my case is working fine.

part of my code:

data: gr_browser   TYPE REF TO cl_gui_html_viewer,
      g_evt_receiver TYPE REF TO cl_myevent_handler.

***Below code in PBO

  CLEAR wa_event.
  wa_event-eventid = gr_browser->m_id_navigate_complete.
  wa_event-appl_event = 'X'.
  APPEND wa_event TO gt_event_tab.

  CALL METHOD gr_browser->set_registered_events
    EXPORTING
      events = gt_event_tab.

  CREATE OBJECT g_evt_receiver.

  SET HANDLER g_evt_receiver->on_sapevent "on_sapevent - I am handling PAI changes.
              FOR gr_browser.

*** Below code in TOP Include
**Local class  

CLASS cl_myevent_handler DEFINITION.
  PUBLIC SECTION.
    METHODS: on_sapevent
                  FOR EVENT sapevent OF cl_gui_html_viewer
      IMPORTING action frame getdata postdata query_table.
ENDCLASS.

CLASS cl_myevent_handler IMPLEMENTATION.
  METHOD on_sapevent.
     edaction       = action.
    edframe        = frame.
    edgetdata      = getdata.
    postdata_tab   = postdata.    
    edquery_table  = query_table.    
  ENDMETHOD.
ENDCLASS.

Thanks
1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,020

In HTML, a checkbox is not very different from any other input field.

You probably have a bug in your HTML or ABAP code.

There's no issue with this standalone code:

CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    METHODS at_selection_screen_output.
    METHODS at_selection_screen_exit.
    METHODS on_sapevent FOR EVENT sapevent OF cl_gui_html_viewer
          IMPORTING action frame getdata postdata query_table.
  PRIVATE SECTION.
    DATA o_html TYPE REF TO cl_gui_html_viewer.
ENDCLASS.

CLASS lcl_app IMPLEMENTATION.

  METHOD at_selection_screen_output.
    DATA: l_url TYPE cnht_url.

    IF o_html IS NOT BOUND.

      CONCATENATE '<body>'
      '<form id="form" method="POST" action="SAPEVENT:submit">'
      '<p>Text : <input name="text" type="text" length="10"></p>'
      '<p>Checkbox : <input name="checkbox" type="checkbox"></p>'
      '<p><button type= "submit">ABAP call</button></p>'
      '</form>'
      '</body>'
      INTO DATA(l_text).

      o_html = new #( parent = cl_gui_container=>screen0 ).
      SET HANDLER on_sapevent FOR o_html.
      o_html->set_registered_events( events = value #( ( eventid = o_html->m_id_sapevent ) ) ).
      DATA(lt_text) = cl_bcs_convert=>string_to_soli( l_text ).
      o_html->load_data(
        EXPORTING type = 'text' subtype = 'html' size = strlen( l_text )
        IMPORTING assigned_url = l_url
        CHANGING  data_table = lt_text ).
      o_html->show_url( EXPORTING url = l_url ).
    ENDIF.
  ENDMETHOD.

  METHOD at_selection_screen_exit.
    IF o_html IS BOUND.
      o_html->free( ).
      FREE o_html.
    ENDIF.
  ENDMETHOD.

  METHOD on_sapevent.
    CONCATENATE LINES OF postdata INTO data(l_post_data) RESPECTING BLANKS.
    MESSAGE l_post_data TYPE 'I'.
  ENDMETHOD.

ENDCLASS.

PARAMETERS dummy.
DATA go_app TYPE REF TO lcl_app.

LOAD-OF-PROGRAM.
  CREATE OBJECT go_app.

AT SELECTION-SCREEN OUTPUT.
  go_app->at_selection_screen_output( ).

AT SELECTION-SCREEN ON EXIT-COMMAND.
  go_app->at_selection_screen_exit( ).