2009 Jan 27 12:23 PM
Hi Experts,
I have created a Text Editor in module Pool Program. But my requirement is to read data from an Internal Table & populate those records to that Text Editor.
Can you please suggest me how to do that?
Thanks & Regards,
Biswajit
2009 Jan 27 12:56 PM
Pretty straight forward.
DATA container TYPE REF TO cl_gui_custom_container.
DATA editor TYPE REF TO cl_gui_textedit.
DATA textline(80).
DATA text_130 LIKE STANDARD TABLE OF textline.
PBO module routine
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = 'TEXT_CTRL'. " Custom Container on Screen
CREATE OBJECT editor
EXPORTING parent = container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = 80
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
ENDIF.
IF ok_0010 = 'DISP' OR ok_0010 = 'DELE'
OR ( ok_0010 = 'CHAN' AND tax_edit EQ 'Y' ).
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '1'.
ELSE.
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '0'.
ENDIF.
* call method editor->set_text_as_stream
CALL METHOD editor->set_text_as_r3table
EXPORTING table = text_130. " Internal Table
To retrieve it
REFRESH text_130.
CALL METHOD editor->get_text_as_r3table
IMPORTING table = text_130. " Again, Internal Table name
Edited by: Paul Chapman on Jan 27, 2009 7:58 AM
Pretty straight forward.
DATA container TYPE REF TO cl_gui_custom_container.
DATA editor TYPE REF TO cl_gui_textedit.
DATA textline(80).
DATA text_130 LIKE STANDARD TABLE OF textline.
PBO module routine
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = 'TEXT_CTRL'. " Custom Container on Screen
CREATE OBJECT editor
EXPORTING parent = container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = 80
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
ENDIF.
IF ok_0010 = 'DISP' OR ok_0010 = 'DELE'
OR ( ok_0010 = 'CHAN' AND tax_edit EQ 'Y' ).
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '1'.
ELSE.
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '0'.
ENDIF.
* call method editor->set_text_as_stream
CALL METHOD editor->set_text_as_r3table
EXPORTING table = text_130. " Internal Table
To retrieve it
REFRESH text_130.
CALL METHOD editor->get_text_as_r3table
IMPORTING table = text_130. " Again, Internal Table name
Edited by: Paul Chapman on Jan 27, 2009 7:58 AM
2009 Jan 27 12:56 PM
Pretty straight forward.
DATA container TYPE REF TO cl_gui_custom_container.
DATA editor TYPE REF TO cl_gui_textedit.
DATA textline(80).
DATA text_130 LIKE STANDARD TABLE OF textline.
PBO module routine
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = 'TEXT_CTRL'. " Custom Container on Screen
CREATE OBJECT editor
EXPORTING parent = container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = 80
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
ENDIF.
IF ok_0010 = 'DISP' OR ok_0010 = 'DELE'
OR ( ok_0010 = 'CHAN' AND tax_edit EQ 'Y' ).
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '1'.
ELSE.
CALL METHOD editor->set_readonly_mode
EXPORTING readonly_mode = '0'.
ENDIF.
* call method editor->set_text_as_stream
CALL METHOD editor->set_text_as_r3table
EXPORTING table = text_130. " Internal Table
To retrieve it
REFRESH text_130.
CALL METHOD editor->get_text_as_r3table
IMPORTING table = text_130. " Again, Internal Table name
Edited by: Paul Chapman on Jan 27, 2009 7:58 AM
2009 Jan 27 1:06 PM
This is another example using the set_text_as_stream vs r3table.
I used it for huge (30000 byte) Letters.
TYPES: BEGIN OF scr_text_line2,
line(30000) TYPE c,
END OF scr_text_line2.
DATA:
wa_wk_letter TYPE scr_text_line2,
g_editor5 TYPE REF TO cl_gui_textedit,
g_custom_container5 TYPE REF TO cl_gui_custom_container.
In the PBO Routine
* Textedit control
PERFORM initialize_text_editor_0525.
PERFORM set_text_in_editor_0525.
The FORMS
*&---------------------------------------------------------------------*
*& Form initialize_text_editor_0525
*&---------------------------------------------------------------------*
FORM initialize_text_editor_0525.
CHECK g_editor5 IS INITIAL.
repid = sy-repid.
CREATE OBJECT g_custom_container5
EXPORTING
container_name = '0551_SCR_CONTAINER'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT g_editor5
EXPORTING
parent = g_custom_container5
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
CALL METHOD g_editor5->set_statusbar_mode
EXPORTING
statusbar_mode = 0.
CALL METHOD g_editor5->set_toolbar_mode
EXPORTING
toolbar_mode = 0.
ENDFORM. " initialize_text_editor_0525
*&---------------------------------------------------------------------*
*& Form set_text_in_editor_0525
*&---------------------------------------------------------------------*
FORM set_text_in_editor_0525.
CALL METHOD g_editor5->set_text_as_stream
EXPORTING
text = it_wk_letter
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE i015 WITH
repid 'Error in set_text_as_stream'.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'set_text_as_stream: Error in FLUSH'.
ENDIF.
ENDFORM. " set_text_in_editor_0525
PBO Module
MODULE text_editor_retrieve_0525.
*&---------------------------------------------------------------------*
*& Module text_editor_retrieve_0525 INPUT
*&---------------------------------------------------------------------*
MODULE text_editor_retrieve_0525 INPUT.
CALL METHOD g_editor5->get_text_as_stream
* EXPORTING
* ONLY_WHEN_MODIFIED = FALSE
IMPORTING
text = it_wk_letter
* IS_MODIFIED =
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE i015 WITH
repid 'Error in get_text_as_stream'.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'get_text_as_stream: Error in FLUSH'.
ENDIF.
ENDMODULE. " text_editor_retrieve_0525 INPUT
Edited by: Paul Chapman on Jan 27, 2009 8:07 AM
2009 Jan 27 1:15 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |