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: 

ABAP : HTML_VIEWER REFRESH PROBLEM

0 Kudos

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.
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

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.
4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Sandra_Rossi
Active Contributor
0 Kudos

About FREE, of course, I'm talking about the method, not the ABAP statement.

You must not call the method FREE before you render the control the first time, otherwise it's not displayed at all. You must call the method FREE on the previous control right before you render a new control at the second time and next times.

Sandra_Rossi
Active Contributor
0 Kudos

Sorry about my initial answer, I deleted it because I didn't see that you create your control only the first time.

Sandra_Rossi
Active Contributor

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.