2013 Aug 07 1:54 PM
I want to change html data at runtime, without reloading the transaction.
data int the table ts_data is dynamic and it change based on use input.
below code display the data but not change based on user input. only the first display stay at transaction end.
Pl. help.
CREATE OBJECT ref_cont
EXPORTING
container_name = 'CONT'
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.
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.
ENDIF.
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->set_ui_flag( ref_html->uiflag_no3dborder ).
I want to change html data at runtime, without reloading the transaction.
data int the table ts_data is dynamic and it change based on use input.
below code display the data but not change based on user input. only the first display stay at transaction end.
Pl. help.
CREATE OBJECT ref_cont
EXPORTING
container_name = 'CONT'
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.
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.
ENDIF.
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->set_ui_flag( ref_html->uiflag_no3dborder ).
2013 Aug 07 2:29 PM
Hi ,
Did use do_refresh method of html viewer?
Regards,
Sreenivas.
2013 Aug 09 7:38 AM
dear Sreenivasa,
No effect with do_refresh method.
The method load_data generate same url after data change in ts_data.
2013 Aug 07 4:19 PM
2013 Aug 09 7:39 AM
Dear Eitan,
This demo like a browser if we change the url it effect. but the method load_data generate same url after data change in ts_data.
2013 Aug 09 8:47 AM
Hi,
You are right.
So we change the url.....
DATA: url TYPE sdok_url VALUE .
CONCATENATE sy-uzeit '.htm' INTO url .
DATA: it_soli_1 TYPE soli_tab .
PERFORM get_html_data_1
CHANGING
it_soli_1 .
CALL METHOD ob_gui_html_viewer->load_data
EXPORTING
url = url
IMPORTING
assigned_url = url
CHANGING
data_table = it_soli_1[].
CALL METHOD ob_gui_html_viewer->show_url
EXPORTING
url = url.
CALL METHOD cl_gui_html_viewer=>set_focus
EXPORTING
control = ob_gui_html_viewer
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
I add the whole show.
2013 Aug 09 8:36 AM
Does the following piece of code get executed every time PAI is triggered?
CREATE OBJECT ref_cont
EXPORTING
container_name = 'CONT'
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.
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.
ENDIF.
If yes, then try putting the above code in the following block
IF ref_cont IS NOT BOUND.
"The create object code
ENDIF.
"The load and refresh code
2013 Aug 09 11:22 AM
2013 Aug 09 4:12 PM
Probably the full code might help you understand.
REPORT zhtml_example.
DATA: ref_cont TYPE REF TO cl_gui_custom_container,
ref_html TYPE REF TO cl_gui_html_viewer,
ts_data TYPE TABLE OF char255.
CALL SCREEN 100.
FORM display_html.
DATA: w_url TYPE char255.
IF ref_cont IS NOT BOUND.
APPEND '<html><body>hello world<br />' TO ts_data.
CREATE OBJECT ref_cont
EXPORTING
container_name = 'CONT'
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.
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.
ENDIF.
ELSE.
APPEND 'hello world<br />' TO ts_data.
ENDIF.
CALL METHOD ref_html->load_data
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->set_ui_flag( ref_html->uiflag_no3dborder ).
ENDFORM.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'S0100'.
PERFORM display_html.
ENDMODULE.
MODULE user_command_0100 INPUT.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.Additional Information on the code:
1. Create screen 100 and place a custom container named CONT
2. Create two modules. (The status_0100 is in PBO and the other one in PAI)
3. Create a status and set BACK as the function code for back button.
4. Every time you click on the Continue button beside the command box the HTML content will get updated.
2013 Aug 09 8:56 AM
Thank you all,
I got the answer myself.
at the change of data call the below method before create object ref_html.
IF ref_html IS NOT INITIAL.
CALL METHOD ref_html->free.
clear ref_html.
ENDIF.
2013 Aug 09 9:08 AM
Hi,
I think that this is not the best solution .
In my opinion if recreating an object can be avoided then avoid it.
And this is what I did in my program.
regards.
2016 Jun 29 6:44 PM
Hi Experts,
i know that is an old topic, but i believe that i found the solution.
I solved this problem testing whether object already exist, like this:
if ref_html is initial.
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.
ENDIF.
endif.
I believe that happens because when we call the "CREATE OBJECT", SAP creates another reference link for that object, losing the original one (that created in the first call) then when we call "SHOW_URL" the new object (that is not shown in the screen) that makes the call.
Testing whether object was already instantiated prevents SAP system of creating a new object in memory, losing the orignal reference.
Please try this.
This theory worked fine for me.