Skip to Content

ABAP : HTML_VIEWER REFRESH PROBLEM

Dear Experts ,

I have html window in custom container ,

I can show my first data but cannot show data even though html code has changed .

I wrote the code in PBO .

Thanks .


MODULE STATUS_0100 OUTPUT.

 SET PF-STATUS 'MENU_0100'.

 SET TITLEBAR 'TITLE_0100'.



MARA-MATNR = GV_MATNR .

MAKT-MAKTX = GV_MAKTX .

CLEAR GV_MATNR .

CLEAR GV_MAKTX .

CLEAR BARCODE .











IF REF_CONT IS  INITIAL .



  CREATE OBJECT REF_CONT

    EXPORTING

      CONTAINER_NAME    = 'CUST1'

    EXCEPTIONS

        cntl_error                  = 1

        cntl_system_error           = 2

        create_error                = 3

        lifetime_error              = 4

        lifetime_dynpro_dynpro_link = 5

        OTHERS                      = 6.

    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 REF_HTML

      EXPORTING

        PARENT    = REF_CONT

      EXCEPTIONS

        cntl_error         = 1

        cntl_install_error = 2

        dp_install_error   = 3

        dp_error           = 4

        OTHERS             = 5.

    IF SY-subrc <> 0.

      MESSAGE ID SY-msgid TYPE SY-msgty NUMBER SY-msgno

                 WITH SY-msgv1 SY-msgv2 SY-msgv3 SY-msgv4.

    ENDIF.

ENDIF .







GV_CHAR = GV_CHAR + 1 .

DATA frame(255).



CLEAR  E_DATA .

CLEAR  TS_DATA .

CONCATENATE '<html><body><p style="font-family:verdana;font-size:1000%;color:black ">'

              GV_CHAR '</p></body><html>' INTO E_DATA.

  APPEND e_data TO ts_data.



CALL METHOD REF_HTML->LOAD_DATA

  EXPORTING

    TYPE    = 'text'

    SUBTYPE = 'html'

  IMPORTING

    ASSIGNED_URL = W_URL

  CHANGING

    DATA_TABLE   = TS_DATA

   EXCEPTIONS

      dp_invalid_parameter = 1

      dp_error_general     = 2

      cntl_error           = 3

      OTHERS               = 4.

  IF SY-subrc <> 0.



  ENDIF.



CALL METHOD REF_HTML->SHOW_URL

  EXPORTING

    URL     = W_URL



  EXCEPTIONS

      cntl_error             = 1

      cnht_error_not_allowed = 2

      cnht_error_parameter   = 3

      dp_error_general       = 4

      OTHERS                 = 5.

  IF SY-subrc <> 0.



  ENDIF.







REF_HTML->DO_REFRESH( ).

MODIFY SCREEN.

ENDMODULE.
html.jpg (18.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Nov 08, 2019 at 09:46 AM

    Never use the method DO_REFRESH. I'm not even sure what is the use case. In your case, it tells the control to re-render its current HTML, which is not the last HTML you have sent because there was no UPDATE_VIEW/FLUSH yet (I added CL_GUI_CFW=>UPDATE_VIEW( ) before calling DO_REFRESH and it then renders your HTML).

    Reloading the data is sufficient. Minimal reproducible example (press the OK button to refresh):

    PARAMETERS dummy.
    
    DATA ref_html TYPE REF TO cl_gui_html_viewer.
    
    AT SELECTION-SCREEN OUTPUT.
      IF ref_html IS INITIAL .
        CREATE OBJECT ref_html
          EXPORTING
            parent = cl_gui_container=>screen0.
      ENDIF .
      DATA: e_data  TYPE soli, ts_data TYPE soli_tab, w_url TYPE text255.
      e_data-line = |<html><body><p style="font-family:verdana;font-size:1000%;|
                 && |color:black ">{ sy-uzeit }</p></body><html>|.
      APPEND e_data TO ts_data.
      CALL METHOD ref_html->load_data
        EXPORTING
          type         = 'text'
          subtype      = 'html'
        IMPORTING
          assigned_url = w_url
        CHANGING
          data_table   = ts_data.
      ref_html->show_url( w_url ).
    
    AT SELECTION-SCREEN.
      TABLES sscrfields.
      IF sscrfields-ucomm = 'ONLI'. sscrfields-ucomm = ''. ENDIF.
    Add a comment
    10|10000 characters needed characters exceeded