09-12-2014 5:55 AM
Hello,
I understand that this question has been put up here many times, I also found out that the answer has been given by many experts here, but nevertheless, I would like to put it up now for further clarification.
The issue I am facing:
One of the Z programs we use internally makes use of the standard FM READ_TEXT, and we see that for certain " text lines" which we pass, the READ_TEXT function module indeed 'reads' the lines and populated the table as expected.
But, on the other hand, for certain lines - we also notice that these lines are NOT READ by this function module even though the data has been entered/ they are stored in STXL table.
Is there a constraint on the minimum number of characters/ or a constraint on the lines which this FM expects? ( Please refer this thread
http://scn.sap.com/thread/1469855 )
Is it an unusual behavior observed by everyone/ or do we find this behavior in some SAP document which I can refer?
I would really appreciate some pointers on this issue.
Thanks!
09-12-2014 6:56 AM
Hi, Alice!
Havent't seen such behaviour.
May not it be the issue with "complicated" TDNAME? E.g., it consists of several fields and you miss the leading zeros for the document number, someting like that?
Have you tried to manually run FM in SE37? Does it return the text?
09-12-2014 8:09 AM
Nope. I don't see any complex behavior in the input.
I gave the leading zeroes as well.
I tried using SE37 to run this separately as well. It gives me an output of a blank table - 1 row - but 1 EMPTY row.
09-12-2014 8:14 AM
All,
There is an IMPORT statement in READ_TEXTLINES which happens to reside inside the READ_TEXT function module, wherein it imports the data to the table from STLX.
I can see that the table now has "1" entry when I was debugging. But the table is empty. And, hence the output of READ_TEXT is also empty.
09-12-2014 8:34 AM
So does this mean your question is answered? If not please can you explain more clearly also maybe with a screenshot of your STLX entry and the READ_TEXT result etc.
09-12-2014 8:39 AM
And have you tried to have a look at the text in old editor? Copypaste it from notepad and save again?
09-12-2014 8:16 AM
Why don't you debug what READ:_LINE is doing in your case of "one empty line" ?
READ_TEXT is age-old and used since R/3 existed. I doubt that there is a generic error. Eventually, IMPORT.. FROM DATABASE STXL... is used to fetch the line data. And a character conversion of the text data MAY occur, if the data in STXL was stored in a different codepage (compared to the system codepage).
Regards,.
Alex
09-12-2014 8:48 AM
How did you perform your check, READ_TEXT is a well known/tested FM. The IMPORT FROM DATABASE statement wont be executed if data is already in memory ("local catalog" in documentation, look for import/export catalog from/to memory id 'SAPLSTXD'.) depending on usage of LOCAL_CAT in your call.
Regards,
Raymond
09-12-2014 5:52 PM
Hi,
How are the texts stored before being read - programmatically, in the same programs, perhaps? If that's the case, the last relatively fresh OSS Note concerning READ_TEXT that may be somewhat applicable is 1667408 - READ_TEXT does not return any records.
I would not give any credibility whatsoever to assertions about 40 or less (or whatever other magic number of characters being a problem), which are not substantiated in any way (a link to a reputable source, or a program and text to reproduce the problem). I tried 3 minutes ago to read 8, 40, 41 character ST TEXT text and of course they read just fine.
cheers
Janis
09-16-2014 9:59 AM
Hi Alice,
Kindly use below code to retrieve data from particular text.
DATA: l_c_ltxt TYPE tdid VALUE 'F01',
l_c_mdtxt TYPE tdobject VALUE 'EKKO',
l_v_tname TYPE tdname VALUE 'something',
V_VEN_LANG type sy-langu VALUE 'EN'.
DATA: i_tline type table of tline,
w_tline like line of i_tline.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = l_c_ltxt
language = V_VEN_LANG "sy-langu
name = l_v_tname
object = l_c_mdtxt
TABLES
lines = i_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
if i_tline[] is not initial.
read i_tline into w_tline index 1.
......................
endif.
09-16-2014 11:27 AM
No, Alice and others - if you value your time (and the time of others who will have to work with your code) never ever use code that does not check return code of the FM call and does not process the exceptions. Just don't do it - don't be sloppy, don't be lazy - you and your employer will pay in hours or even days spent looking for wierd behaviours in unpredictable programs. The maximum 5 minutes it takes to properly process exceptions will pale in comparison to the time needed to debug and fix program behaving unpredictably (continuing to run blissfully when they should have stopped because of error). In the rare case where you do think the logic must continue despite exceptions - document it using appropritate comment.
cheers
Janis
09-16-2014 12:21 PM
On which object type do you execute the FM, there are some objects which carry also a short text and may carry a long text managed with SAVE/READ_TEXT, but the long text is not saved in database if equal to short text,
For example it was the case for Orders/Operations with a short text length of 40
(NB: This behavior is coded in the relative transactions, not in text manager FM)
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = l_id
language = l_language
name = l_name
object = l_object
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc EQ 0.
LOOP AT lt_lines INTO l_line.
IF record-ltext IS INITIAL.
record-ltext = l_line-tdline.
ELSE.
CONCATENATE record-ltext l_line-tdline
INTO record-ltext SEPARATED BY space.
ENDIF.
ENDLOOP.
ELSEIF sy-subrc EQ 4.
record-ltext = record-ktext.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
Raymond