2023 Dec 14 12:01 PM
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.
2023 Dec 14 12:24 PM
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.
2023 Dec 14 12:24 PM
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.
2023 Dec 14 12:42 PM
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
2023 Dec 14 12:28 PM
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( ... ).