Skip to Content
0

Two Custom Containers with HTML in the same dynpro

Apr 28, 2017 at 10:09 AM

135

avatar image

Hi all.

I have two custom containers in my dynpro. One named CC_YES the other named CC_NO.

I want to display both at the same time with different HTML code.

But, I dont know why, I can show only one at the same time.

If I comment the code of one HTML container the other is displayed and viceversa, but with both at the same time doesnt work.

Do you know what can be the problem? is it necessary to add something in my HTML code?

This is a simplified code to see the problem:

REPORT ztest_html.

START-OF-SELECTION.

DATA:
html TYPE string.
DATA:
lo_container_yes TYPE REF TO cl_gui_custom_container,
lo_container_no TYPE REF TO cl_gui_custom_container.



CALL SCREEN 2000.

*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_2000 OUTPUT.

SET PF-STATUS 'STATUS'.

CHECK lo_container_yes IS INITIAL.
*
html = '<HTML><body style="background-color:#ff0000;margin-top:0px;overflow:hidden;"><p>yes</p></BODY></HTML>'.
CREATE OBJECT lo_container_yes
EXPORTING
container_name = 'CC_YES'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc NE 0.
RETURN.
ENDIF.

cl_abap_browser=>show_html(
html_string = html
context_menu = abap_true
modal = abap_false
container = lo_container_yes
check_html = abap_false ).


html = '<HTML><body style="background-color:#ff0000;margin-top:0px;overflow:hidden;"><p>No</p></BODY></HTML>'.
CREATE OBJECT lo_container_no
EXPORTING
container_name = 'CC_NO'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc NE 0.
RETURN.
ENDIF.

cl_abap_browser=>show_html(
html_string = html
context_menu = abap_true
modal = abap_false
container = lo_container_no
check_html = abap_false ).

ENDMODULE.

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_2000 INPUT.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0 .
ENDIF.
ENDMODULE.

1.jpg (52.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Richard Harper Apr 28, 2017 at 10:29 AM
1

How about instantiated 2 cl_gui_html_viewers in each container rather than using static methods.

Rich

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Ok, I've never used these classes... I've just copied some standard demo.

You are right, with cl_gui_html_viewer works fine.

0

CL_ABAP_BROWSER is a wrapper for cl_gui_html_viewer for simple use cases only. It belongs to the infrastructure of the ABAP keyword documentation and was originally planned for the needs of that package only. For advanced use cases, you have to use the CFW classes itself.

0
@Oliver, unfortunately, you can only use cl_abap_browser once in the same session, as it's based on a singleton pattern (unique cl_gui_html_viewer control). So, do as Richard suggested.
1