10-19-2011 8:29 AM
Hi all,
I have a dialogbox container cl_gui_dialogbox_container and I need a way to write something inside of it(WRITE 'hello world'), without using alv classes.
Are there some classes to use?
Should i create a dynpro?
can you help me?
Thanks.
Tony
10-19-2011 9:18 AM
Hi Tony,
check sample code, which I have used to create a popup with text without creating a dynpro:
*----------------------------------------------------------------------*
* CLASS lcl_dialogbox_handler DEFINITION
*----------------------------------------------------------------------*
* Definition of dialogbox event handler
*----------------------------------------------------------------------*
CLASS lcl_dialogbox_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
close
FOR EVENT close
OF cl_gui_dialogbox_container.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* Implementation of dialogbox event handler
*---------------------------------------------------------------------*
CLASS lcl_dialogbox_handler IMPLEMENTATION.
METHOD close.
* I will free textedit control and dialogbox
CALL METHOD gr_textedit->free.
FREE gr_textedit.
CALL METHOD gr_dialogbox->free.
FREE gr_dialogbox.
* finally flush
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
ENDMETHOD." close
ENDCLASS. "lcl_dialogbox_handler IMPLEMENTATION
DATA: gr_textedit TYPE REF TO cl_gui_textedit,
gr_dialogbox TYPE REF TO cl_gui_dialogbox_container,
gt_text_data TYPE STANDARD TABLE OF char128.
* I will create a dialogbox for displaying text in textedit
CREATE OBJECT gr_dialogbox
EXPORTING
width = 800
height = 400
top = 50
left = 100
caption = 'Close Window to end Display'. "#EC NOTEXT
* I will create a textedit control to display text
CREATE OBJECT gr_textedit
EXPORTING
parent = gr_dialogbox.
* Handler is necessary for closing popup
SET HANDLER lcl_dialogbox_handler=>close FOR gr_dialogbox.
* I will set text to be displayed
CALL METHOD gr_textedit->set_text_as_r3table
EXPORTING
table = gt_text_data
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* I will make text read-only, changing it is meaningless
gr_textedit->set_readonly_mode( 1 ).
I hope it helps.
Regards
Adrian
10-19-2011 9:18 AM
Hi Tony,
check sample code, which I have used to create a popup with text without creating a dynpro:
*----------------------------------------------------------------------*
* CLASS lcl_dialogbox_handler DEFINITION
*----------------------------------------------------------------------*
* Definition of dialogbox event handler
*----------------------------------------------------------------------*
CLASS lcl_dialogbox_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
close
FOR EVENT close
OF cl_gui_dialogbox_container.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* Implementation of dialogbox event handler
*---------------------------------------------------------------------*
CLASS lcl_dialogbox_handler IMPLEMENTATION.
METHOD close.
* I will free textedit control and dialogbox
CALL METHOD gr_textedit->free.
FREE gr_textedit.
CALL METHOD gr_dialogbox->free.
FREE gr_dialogbox.
* finally flush
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
ENDMETHOD." close
ENDCLASS. "lcl_dialogbox_handler IMPLEMENTATION
DATA: gr_textedit TYPE REF TO cl_gui_textedit,
gr_dialogbox TYPE REF TO cl_gui_dialogbox_container,
gt_text_data TYPE STANDARD TABLE OF char128.
* I will create a dialogbox for displaying text in textedit
CREATE OBJECT gr_dialogbox
EXPORTING
width = 800
height = 400
top = 50
left = 100
caption = 'Close Window to end Display'. "#EC NOTEXT
* I will create a textedit control to display text
CREATE OBJECT gr_textedit
EXPORTING
parent = gr_dialogbox.
* Handler is necessary for closing popup
SET HANDLER lcl_dialogbox_handler=>close FOR gr_dialogbox.
* I will set text to be displayed
CALL METHOD gr_textedit->set_text_as_r3table
EXPORTING
table = gt_text_data
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* I will make text read-only, changing it is meaningless
gr_textedit->set_readonly_mode( 1 ).
I hope it helps.
Regards
Adrian
10-20-2011 10:57 AM
Writing with WRITE inside GUI controls like container is of course not possible. The only way you have is either using text editor as suggested above, or by means of other GUI control which can accept writiting to the output stream. This could be i.e. [Dynamic Documents|http://help.sap.com/saphelp_470/helpdata/en/10/246858055711d4a7410000e83dd863/frameset.htm]. See demo program DD_ADD_TEXT .
Regards
Marcin