Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

READ_TEXT function module behavior

former_member245174
Participant
0 Kudos

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!

11 REPLIES 11

nikolayevstigneev
Contributor
0 Kudos

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?

0 Kudos

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.

former_member245174
Participant
0 Kudos

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.

0 Kudos

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.

0 Kudos

And have you tried to have a look at the text in old editor? Copypaste it from notepad and save again?

alexander_bolloni
Contributor
0 Kudos

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


raymond_giuseppi
Active Contributor
0 Kudos

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

Private_Member_7726
Active Contributor
0 Kudos

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

Former Member
0 Kudos


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.

0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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