02/08/2010

Read the Standard Text in Transaction SO10


*-----------------------------------------------------------------------
* With this program you can save any entered text as a standard text
* and retrieve it, when executing the program, again. You can read
* the standard text in transaction SO10
* Create a screen named 0100 and draw a container called 'TEXTEDIT'
* as big as you wish. You should also create a pf-status 'STATUS-100'
* which has a BACK button and a CANC button.
*-----------------------------------------------------------------------
REPORT ztest no standard page heading.

DATA: init,
okcode LIKE sy-ucomm,
text_header LIKE thead,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
text_table TYPE STANDARD TABLE OF tline.


START-OF-SELECTION.
CALL SCREEN 0100.


*-----------------------------------------------------------------------
* Module STATUS_0100 OUTPUT
*-----------------------------------------------------------------------
MODULE status_0100 OUTPUT.

SET PF-STATUS 'STATUS-100'.

IF init IS INITIAL.
init = 'X'.
CREATE OBJECT: container EXPORTING container_name = 'TEXTEDIT',
editor EXPORTING parent = container.

CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'ST'
language = 'E'
name = 'YTEST1'
object = 'TEXT'
TABLES
lines = text_table
EXCEPTIONS
not_found = 1.

IF sy-subrc = 0.

CALL METHOD editor->set_text_as_stream
EXPORTING
text = text_table.

* Protect text lines
CALL METHOD editor->protect_lines
EXPORTING
from_line = 1
to_line = 200
enable_editing_protected_text = 0.

* Highlight in blue the text
CALL METHOD editor->highlight_lines
EXPORTING
from_line = 1
to_line = 20
highlight_mode = 1.

* Hide status bar
CALL METHOD editor->set_statusbar_mode
EXPORTING
statusbar_mode = 0.

* Hide tool bar
CALL METHOD editor->set_toolbar_mode
EXPORTING
toolbar_mode = 0.

ENDIF.

ENDIF.

ENDMODULE.


*-----------------------------------------------------------------------
* Module USER_COMMAND_0100 INPUT
* The entered text is saved in english (E), under the name 'YTEST1'
* and as standard text 'ST'.
*-----------------------------------------------------------------------
MODULE user_command_0100 INPUT.

CASE okcode.
WHEN 'BACK' OR 'CANC'.
SET SCREEN 0.

WHEN 'SAVE'.
text_header-tdobject = 'TEXT'.
text_header-tdname = 'YTEST1'.
text_header-tdid = 'ST'.
text_header-tdtitle = 'My Title'.
text_header-tdspras = 'E'.
text_header-tdfuser = sy-uname.

CALL METHOD editor->get_text_as_stream
IMPORTING
text = text_table.

CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = text_header
TABLES
lines = text_table.

ENDCASE.

ENDMODULE.

Nenhum comentário:

Postar um comentário