10-23-2007 7:15 AM
Hi all
I gt this TextEditControl. The user can enter many line of record in the TextEditControl. The line of records will be insert in the database. How to retrieve the line of data out from the TextEditControl.
10-23-2007 7:17 AM
Hi
You have to use READ_TEXT fun module by passing the OBJECT,ID,OBJECTNAME and LANGUAGE as parameters
See the table STXH for these parameters
from text editor menu
GOTO->HEADER
you will see all those 4 parameters
Regards
Anji
10-23-2007 7:19 AM
Sorry i stil v new to abap. Is there any code or step to retrive the data out line by line?
10-23-2007 7:24 AM
Hi
As I said Take the 4 paramaters from the menu GOTO_>HEADER and see for these 4 parameters and see the doc of this fun module and use it
READ_TEXT
READ_TEXT provides a text for the application program in the specified work areas.
The function module reads the desired text from the text file, the text memory, or the archive. You must fully specify the text using OBJECT, NAME, ID, and LANGUAGE. An internal work area can hold only one text; therefore, generic specifications are not allowed with these options.
After successful reading, the system places header information and text lines into the work areas specified with HEADER and LINES.
If a reference text is used, SAPscript automatically processes the reference chain and provides the text lines found in the text at the end of the chain. If an error occurs, the system leaves the function module and triggers the exception REFERENCE_CHECK.
Function call:
CALL FUNCTION 'READ_TEXT'
EXPORTING CLIENT = SY-MANDT
OBJECT = ?...
NAME = ?...
ID = ?...
LANGUAGE = ?...
ARCHIVE_HANDLE = 0
IMPORTING HEADER =
TABLES LINES = ?...
EXCEPTIONS ID =
LANGUAGE =
NAME =
NOT_FOUND =
OBJECT =
REFERENCE_CHECK =
WRONG_ACCESS_TO_ARCHIVE =
Export parameters:
CLIENT
Specify the client under which the text is stored. If you omit this parameter, the system uses the current client as default.
Reference field: SY-MANDT
Default value: SY-MANDT
OBJECT
Enter the name of the text object to which the text is allocated. Table TTXOB contains the valid objects.
Reference field: THEAD-TDOBJECT
NAME
Enter the name of the text module. The name may be up to 70 characters long. Its internal structure depends on the text object used.
Reference field: THEAD-TDNAME
ID
Enter the text ID of the text module. Table TTXID contains the valid text IDs, depending on the text object.
Reference field: THEAD-TDID
LANGUAGE
Enter the language key of the text module. The system accepts only languages that are defined in table T002.
Reference field: THEAD-TDSPRAS
ARCHIVE_HANDLE
If you want to read the text from the archive, you must enter a handle here. The system uses it to access the archive. You can create the handle using the function module ACHIVE_OPEN_FOR_READ.
The value '0' indicates that you do not want to read the text from the archive.
Reference field: SY-TABIX
Default value: 0
Import parameters:
HEADER
If the system finds the desired text, it returns the text header in this parameter.
Structure: THEAD
Table parameters:
LINES
The table contains all text lines that belong to the text read.
Structure: TLINE
Exceptions:
ID
The text ID specified in the parameter ID does not exist in table TTXID. It must be defined there together with the object of the text module.
LANGUAGE
The parameter LANGUAGE contains a language key that does not exist in table T002.
NAME
The parameter NAME contains the name of a text module that does not correspond to the SAPscript conventions.
Possible errors:
The field contains only blanks.
The field contains the invalid characters * or ,.
OBJECT
The parameter OBJECT contains the name of a text object that does not exist in table TTXOB.
NOT_FOUND
The system did not find the specified text module.
REFERENCE_CHECK
The text module to be read has no text lines of its own but refers to the lines of another text module. This reference chain can include several levels. For the current text, the chain is interrupted, that is, one of the text modules referred to in the chain no longer exists.
WRONG_ACCESS_ TO_ARCHIVE
The exception WRONG_ACCESS_TO_ARCHIVE is triggered if an archive is accessed using an incorrect or non-existing archive handle or an incorrect mode (that is, read if the archive is open for writing or vice versa).
Regards
Anji
10-23-2007 7:22 AM
hi,
check this sample code
TABLES VBRK.
DATA : ITEXT LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA : TEXTNAME LIKE STXH-TDNAME.
DATA : BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBRK-VBELN,
LRTEXT LIKE TLINE-TDLINE,
END OF ITAB.
SELECT-OPTIONS : VBELN FOR VBRK-VBELN.
SELECT SINGLE VBELN FROM VBRK INTO ITAB WHERE VBELN IN VBELN.
TEXTNAME = ITAB-VBELN.
PERFORM READ_TEXT TABLES ITEXT USING 'I002' 'VBBK' TEXTNAME.
READ TABLE ITEXT INDEX 1.
IF SY-SUBRC EQ 0.
ITAB-LRTEXT = ITEXT-TDLINE.
ENDIF.
WRITE ITAB-LRTEXT.
FORM READ_TEXT TABLES ITEXT STRUCTURE TLINE
USING P_ID P_OBJ P_NAME.
REFRESH ITEXT.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = P_ID
LANGUAGE = SY-LANGU
NAME = P_NAME
OBJECT = P_OBJ
TABLES
LINES = ITEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
ENDFORM. " READ_TEXT
regards
siva
10-23-2007 7:27 AM
Hi,
which text are you refereing to, is it text in sales order, purch order etc..
If yes then proceed as below.
1)click on the text ->GOto->header->
make not of object,textid .
2)pass these values to READ_TEXT parameters .
for more details check out http://www.sapdev.co.uk/fmodules/fms_readtext.htm
Regards,
Raghavendra
10-23-2007 7:34 AM
hi
good
REPORT sapmz_hf_controls1 .
CONSTANTS:
line_length TYPE i VALUE 254.
DATA: ok_code LIKE sy-ucomm.
DATA:
Create reference to the custom container
custom_container TYPE REF TO cl_gui_custom_container,
Create reference to the TextEdit control
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
START-OF-SELECTION.
SET SCREEN '100'.
----
MODULE USER_COMMAND_0100 INPUT *
----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
The TextEdit control should only be initialized the first time the
PBO module executes
IF editor IS INITIAL.
repid = sy-repid.
Create obejct for custom container
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Create obejct for the TextEditor control
CREATE OBJECT editor
EXPORTING
wordwrap_mode =
cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = custom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCITEXTEDIT/BCCITEXTEDIT.pdf
http://www.erpgenie.com/abap/controls/textedit.htm
reward point if helpful.
thanks
mrutyun^
10-23-2007 7:42 AM
Below is my code. Can you help me to add in the code where i can capture line by line in the texteditcontrol. so that i can know each line n i can do a insert in the database. When i click SAVE, i able to gt the data each line.
REPORT ZGARY_TEXT.
Declarations *****************************************************
CLASS event_handler DEFINITION.
PUBLIC SECTION.
METHODS: handle_f1 FOR EVENT f1 OF cl_gui_textedit
IMPORTING sender,
handle_f4 FOR EVENT f4 OF cl_gui_textedit
IMPORTING sender.
ENDCLASS.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm.
DATA: init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit.
DATA: event_tab TYPE cntl_simple_events,
event TYPE cntl_simple_event.
DATA: line(256) TYPE c,
text_tab LIKE STANDARD TABLE OF line,
field LIKE line.
DATA handle TYPE REF TO event_handler.
TABLES ZSTUDGARY.
Reporting Events ***************************************************
START-OF-SELECTION.
line = '444444'.
APPEND line TO text_tab.
line = '555555'.
APPEND line TO text_tab.
line = '666666'.
APPEND line TO text_tab.
CALL SCREEN 100.
Dialog Modules *****************************************************
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
IF init is initial.
init = 'X'.
CREATE OBJECT: container EXPORTING container_name = 'TEXTEDIT',
editor EXPORTING parent = container,
handle.
event-eventid = cl_gui_textedit=>event_f1.
event-appl_event = ' '. "system event
APPEND event TO event_tab.
event-eventid = cl_gui_textedit=>event_f4.
event-appl_event = 'X'. "application event
APPEND event TO event_tab.
CALL METHOD: editor->set_registered_events
EXPORTING events = event_tab.
SET HANDLER handle->handle_f1
handle->handle_f4 FOR editor.
ENDIF.
CALL METHOD editor->set_text_as_stream EXPORTING text = text_tab.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'INSERT'.
CALL METHOD editor->get_text_as_stream IMPORTING text = text_tab.
WHEN 'F1'.
MESSAGE i888(sabapdocu) WITH text-001.
WHEN OTHERS.
MESSAGE i888(sabapdocu) WITH text-002.
CALL METHOD cl_gui_cfw=>dispatch. "for application events
MESSAGE i888(sabapdocu) WITH text-003.
ENDCASE.
case sy-ucomm.
<b>when 'SAVE'.
<b>// code to be added to retrieve each line</b>
endcase.</b>
SET SCREEN 100.
ENDMODULE.
Class Implementations **********************************************
CLASS event_handler IMPLEMENTATION.
METHOD handle_f1.
DATA row TYPE i.
MESSAGE i888(sabapdocu) WITH text-004.
CALL METHOD sender->get_selection_pos
IMPORTING from_line = row.
CALL METHOD sender->get_line_text
EXPORTING line_number = row
IMPORTING text = field.
CALL METHOD cl_gui_cfw=>set_new_ok_code "raise PAI for
EXPORTING new_code = 'F1'. "system events
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD.
METHOD handle_f4.
DATA row TYPE i.
MESSAGE i888(sabapdocu) WITH text-005.
CALL METHOD sender->get_selection_pos
IMPORTING from_line = row.
CALL METHOD sender->get_line_text
EXPORTING line_number = row
IMPORTING text = field.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD.
ENDCLASS.