‎2007 Aug 07 9:13 AM
Hello All,
Can i Use READ_TEXT to read multiple rows of text from a Delivery documents TEXT field? If yes please let me know how is that done?
Regards,
Ketki
‎2007 Aug 07 9:15 AM
Hi
Yes u can use check this sample report
*&---------------------------------------------------------------------*
*& Report ZREADTEXTTEST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZREADTEXTTEST .
tables: ekpo,MAKT.
TYPE-POOLS: slis.
DATA: thread LIKE thead.
DATA: l_index LIKE sy-tabix.
DATA: BEGIN OF INT_OUT OCCURS 0,
MATNR LIKE EKPO-MATNR,
MAKTX LIKE MAKT-MAKTX,
TDLINE LIKE TLINE-TDLINE,
WERKS LIKE EKPO-WERKS,
END OF INT_OUT.
DATA: BEGIN OF INT_OUT_new OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
TDLINE LIKE TLINE-TDLINE,
tline like tline occurs 0,
WERKS LIKE EKPO-WERKS,
END OF INT_OUT_new.
DATA: it_tlines LIKE tline OCCURS 10 WITH HEADER LINE.
**************************
****ALV list definintion
*************************
DATA: ws_cat TYPE slis_fieldcat_alv ,
int_cat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_custom_container TYPE REF TO cl_gui_custom_container.
*****************
*selection-screen
*****************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(20) text-001.
**PARAMETERS: S_MATNR LIKE MAKT-MATNR obligatory.
*
SELECT-OPTIONS: S_MATNR FOR MAKT-MATNR .
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 25(20) text-002.
**PARAMETERS:p_ebeln LIKE ekko-ebeln obligatory.
*SELECT-OPTIONS: S_WERKS FOR EKPO-WERKS OBLIGATORY.
*SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_data.
* PERFORM field_catalog.
* PERFORM display_data.
END-OF-SELECTION.
*FORM GET_DATA.
form get_data.
DATA: l_index LIKE sy-tabix.
*SELECT
* a~matnr
* a~werks
* b~maktx FROM ekpo AS a
* INNER JOIN makt AS b
* ON b~matnr = a~matnr
* INTO CORRESPONDING FIELDS OF TABLE int_out
* WHERE
** a~matnr = s_matnr and
* a~werks IN s_werks.
*To Fetch Data From Makt.
SELECT MATNR MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE
int_out WHERE MAKT~MATNR IN S_MATNR.
LOOP AT int_out.
l_index = sy-tabix.
* read table int_out_new with key matnr = int_out-matnr.
int_out_new-matnr = int_out-matnr.
int_out_new-maktx = int_out-maktx.
*
thread-tdname = int_out-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BEST'
language = sy-langu
name = thread-tdname
object = 'MATERIAL'
TABLES
lines = it_tlines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
loop at it_tlines.
IF sy-subrc = 0.
int_out_new-tdline = it_tlines-tdline.
append int_out_new.
clear int_out_new.
clear int_out_new-tdline.
ENDIF.
endloop.
delete adjacent duplicates from INT_OUT .
append int_out_new.
ENDLOOP.
***MATERIAL NO no
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MATNR'.
int_cat-reptext_ddic = 'MATERIAL NO'.
APPEND int_cat .
*material Short Description
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MAKTX'.
int_cat-reptext_ddic = 'MATERIAL SHORT DESCRIPTION'.
APPEND int_cat .
** Material Long Description
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'TDLINE'.
int_cat-reptext_ddic = 'MATERIAL LONG DESCRIPTION'.
int_cat-datatype = 'CHAR'.
int_cat-outputlen = '100'.
APPEND int_cat .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_cat[]
TABLES
t_outtab = int_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.Reward all helpfull answers
Regarsd
Pavan
‎2007 Aug 07 9:43 AM
Hi
see the doc and declare the parameters accordingly and fetch the data into Internal table and display
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).
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Aug 07 9:44 AM
Hi,
Yes you can...You will have to pass the values to that FM go to the header of the text and see the parameter values and pass them to the FM and you will get the text as output. If you go to the text at the top you will have go to under that you will have header if you go into that you will find the parameters related to that.
Regards,
Himanshu
‎2007 Aug 07 9:49 AM
Hi,
You can collect the multiple lines in an internal table of type TLINE.
into READ_TEXT function module you have to pass text name text object etc, all those you can find from a standard TCODE where the text is present by going to HEADER details
reward if a useful answer***
‎2007 Aug 07 10:09 AM
Hi Ketki,
Yes, you can use READ_TEXT to read multiple records from text field.
Example: This one is used to read PO texts.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'F01'
language = 'E'
name = v_po "PO no
object = 'EKKO'
TABLES
lines = int_po_text
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
In your case, go to the tcode, give one doc no. and and then, go to the texts.
Double click the text. It will take you to SAPscript part. Then, in menu use ->Goto ->Header, you will get all the parameters to be passed to the FM like id, name, object, etc. The texts (all lines) will be stored in internal table LINES.
Hope this helps.
Regards,
Arun Mohan
<b>* Reward points if helpful.</b>