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: 

Cannot refresh instance of CL_GUI_HTML_VIEWER

johnm16
Participant
0 Kudos

Hi Folks,

I'm missing something obvious here, hoping someone can tell me what I'm doing wrong.

I have a report that processes a series of invoice numbers in a loop.

For each one, the Smartform output is captured in an OTF table, converted to PDF format, then displayed using class CL_GUI_HTML_VIEWER within a custom container. That works perfectly for the first invoice.

After displaying the invoice, I am FREEing the HTML viewer and custom container objects.

But the appearance of the PDF never changes: it keeps re-displaying the first one.

Clearly the HTML viewer isn't being refreshed with the new data. This seems a bit odd, as for each iteration, the HTML viewer is being destroyed and completely re-instantiated. And yes, I have checked that the OTF table is different every time.

This is the code sequence:

    CREATE OBJECT gr_container
      EXPORTING
        container_name = 'INVOICE_CC'.

    CREATE OBJECT gr_html_viewer
      EXPORTING
        parent = gr_container.

    CALL METHOD gr_html_viewer->load_data
      EXPORTING
        type         = 'APPLICATION'
        subtype      = 'PDF'
      IMPORTING
        assigned_url = lv_url
      CHANGING
        data_table   = lt_pdfdata.

    CALL METHOD cl_gui_cfw=>flush.

    CALL METHOD gr_html_viewer->show_data
      EXPORTING
        url = lv_url.

Then, after displaying each invoice, this:

  FREE: gr_html_viewer, gr_container.
I have played around with the DO_REFRESH method, but I'm not certain where to place it (I think I've tried every position). No luck there.Thank you for reading this: all constructive suggestions welcomed.CheersJohn M.
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

The ABAP statement FREE is not to be confused with the method FREE of the controls in the Control Framework.

Only the latter can destroy the control in the frontend.

gr_html_viewer->free( ).
FREE gr_html_viewer.
3 REPLIES 3

Sandra_Rossi
Active Contributor

The ABAP statement FREE is not to be confused with the method FREE of the controls in the Control Framework.

Only the latter can destroy the control in the frontend.

gr_html_viewer->free( ).
FREE gr_html_viewer.

Hi Sandra,

I take your point about my old school code, and thank you for the pointer re. freeing objects.

It works, and I'm a happy bunny.

Cheers

John

Sandra_Rossi
Active Contributor

The static forms of CALL METHOD are obsolete. Same for CREATE OBJECT.

Use e.g.

gr_html_viewer = NEW #( parent = gr_container ).

gr_html_viewer->load_data( ... ).