‎2008 Oct 30 3:43 AM
Hi Abapers,
Am placing a text box which we can enter a long text max of 200 chars.
for this i used the class CL_GUI_TEXTEDITOR
with the help of the class i placed a text box.
so my requirement is when i entered some text that should updated this text in to my Ztable which is having a field of 200 char.
even i have to updated the existing text or Create a text.
my problem is it is having some 4 - 5 methods for the reading the text from the text editor.
even i referred the standard
Ex: RSDEMO_DRAP_DROP_EDIT_TREE
but in this prog. there is no functionality for Save.
so Pls could any one suggest or ( sample code ) me which method i have to consider for both for updating the text or creating the text even that has to reflect into my ztable..!
Thanks & Regards,
Rajeshk
‎2008 Oct 30 4:43 AM
Hi Rajesh,
In the below sample code i have saved 255 characters.
You create a table in which you create 2 fields slno(primary key) and text(char of length 255)
Here is the code.
TOP Declarations
TABLES: ZTEST.
TYPES: BEGIN OF ST_ZTEST,
SLNO TYPE ZTEST-SLNO,
text type ZTEST-text,
END OF ST_ZTEST.
DATA: IT_TEXT TYPE TABLE OF ST_ZTEST, " INTERNAL TABLE IS ST_TEXT
WA_TEXT TYPE ST_ZTEST, " WORK AREAS
WA_ZTEXT TYPE ZTEST.
DATA: LINE_LENGTH TYPE I VALUE 254,
EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
TEXT TYPE STRING.
PBO Declarations.
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS 'ZMENU'.
SET TITLEBAR 'ZTEXT_TITLE'.
IF TEXT_EDITOR IS INITIAL.
CREATE OBJECT EDITOR_CONTAINER
EXPORTING
CONTAINER_NAME = 'TEXTEDITOR' name which you give in screen painter for text editor
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT TEXT_EDITOR
EXPORTING
PARENT = EDITOR_CONTAINER
WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
WORDWRAP_POSITION = LINE_LENGTH
WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.
*HIDE TOOLBAR AND STATUSBAR
CALL METHOD TEXT_EDITOR->SET_TOOLBAR_MODE
EXPORTING
TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FLASE.
CALL METHOD TEXT_EDITOR->SET_STATUSBAR_MODE
EXPORTING
STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FLASE.
ENDIF.
ENDMODULE.
PAI Declarations
MODULE USER_COMMAND_1000 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'SAVE'.
WA_TEXT-SLNO = ZTEST-SLNO.
CALL METHOD TEXT_EDITOR->GET_TEXTSTREAM
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TEXT = TEXT
IS_MODIFIED =
EXCEPTIONS
ERROR_CNTL_CALL_METHOD = 1
NOT_SUPPORTED_BY_GUI = 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.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
WA_TEXT-TEXT = TEXT.
ENDCASE.
MOVE-CORRESPONDING WA_TEXT TO WA_ZTEXT.
INSERT INTO ZTEST VALUES WA_ZTEXT.
call method TEXT_EDITOR->SET_STATUS_TEXT
exporting
STATUS_TEXT = TEXT-311.
call method TEXT_EDITOR->SET_TEXTSTREAM
exporting
TEXT = ''
exceptions
ERROR_CNTL_CALL_METHOD = 1
NOT_SUPPORTED_BY_GUI = 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.
IF SY-SUBRC = 0.
MESSAGE I000.
ENDIF.
ENDMODULE.
Cheers!!
VEnk@
Edited by: Venkat Reddy on Oct 30, 2008 10:14 AM
‎2008 Oct 30 3:55 AM
CALL METHOD ref_text->get_text_as_r3table
EXPORTING
ONLY_WHEN_MODIFIED = 'X'
IMPORTING
table = it_text
IS_MODIFIED =
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Check table it_text. It will have the lines from text editor. You can format this and save in ur Z table.
Regards
Sathar
‎2008 Oct 30 4:01 AM
check the demo program
SAPTEXTEDIT_DEMO_1
there is a series of programs, check once.
‎2008 Oct 30 4:26 AM
hi,
you can try this function Module....
CATSXT_SIMPLE_TEXT_EDITOR
Arunima
‎2008 Oct 30 4:43 AM
Hi Rajesh,
In the below sample code i have saved 255 characters.
You create a table in which you create 2 fields slno(primary key) and text(char of length 255)
Here is the code.
TOP Declarations
TABLES: ZTEST.
TYPES: BEGIN OF ST_ZTEST,
SLNO TYPE ZTEST-SLNO,
text type ZTEST-text,
END OF ST_ZTEST.
DATA: IT_TEXT TYPE TABLE OF ST_ZTEST, " INTERNAL TABLE IS ST_TEXT
WA_TEXT TYPE ST_ZTEST, " WORK AREAS
WA_ZTEXT TYPE ZTEST.
DATA: LINE_LENGTH TYPE I VALUE 254,
EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
TEXT TYPE STRING.
PBO Declarations.
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS 'ZMENU'.
SET TITLEBAR 'ZTEXT_TITLE'.
IF TEXT_EDITOR IS INITIAL.
CREATE OBJECT EDITOR_CONTAINER
EXPORTING
CONTAINER_NAME = 'TEXTEDITOR' name which you give in screen painter for text editor
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT TEXT_EDITOR
EXPORTING
PARENT = EDITOR_CONTAINER
WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
WORDWRAP_POSITION = LINE_LENGTH
WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.
*HIDE TOOLBAR AND STATUSBAR
CALL METHOD TEXT_EDITOR->SET_TOOLBAR_MODE
EXPORTING
TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FLASE.
CALL METHOD TEXT_EDITOR->SET_STATUSBAR_MODE
EXPORTING
STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FLASE.
ENDIF.
ENDMODULE.
PAI Declarations
MODULE USER_COMMAND_1000 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'SAVE'.
WA_TEXT-SLNO = ZTEST-SLNO.
CALL METHOD TEXT_EDITOR->GET_TEXTSTREAM
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TEXT = TEXT
IS_MODIFIED =
EXCEPTIONS
ERROR_CNTL_CALL_METHOD = 1
NOT_SUPPORTED_BY_GUI = 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.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
WA_TEXT-TEXT = TEXT.
ENDCASE.
MOVE-CORRESPONDING WA_TEXT TO WA_ZTEXT.
INSERT INTO ZTEST VALUES WA_ZTEXT.
call method TEXT_EDITOR->SET_STATUS_TEXT
exporting
STATUS_TEXT = TEXT-311.
call method TEXT_EDITOR->SET_TEXTSTREAM
exporting
TEXT = ''
exceptions
ERROR_CNTL_CALL_METHOD = 1
NOT_SUPPORTED_BY_GUI = 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.
IF SY-SUBRC = 0.
MESSAGE I000.
ENDIF.
ENDMODULE.
Cheers!!
VEnk@
Edited by: Venkat Reddy on Oct 30, 2008 10:14 AM
‎2008 Oct 30 8:00 AM
THanks for all the replies ...!
when am using ur code its coping only the last text editor texts.
its over riding the first ones text.
am using two fields.
i placed two text editors .
one is for comment(200) & the other is for Action(200).
these two fields to as to update in the same Database table.
how can i Read the text one after the other one.
and i have to move the 2 texts to to corresponding fields.
Pls help me.....
‎2008 Oct 30 8:11 AM
Try to understand my code and understand the logic, then you can easily write the code for your requirement.
If the data is overwriting then might be there are some same declarations anyways post your code we will see.
Cheers!!
VEnk@