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: 

Reading long text for more records at a time

Former Member
0 Kudos

Hi all,

We have a requirement for which that data like textid textname textobject and language must be taken in to an internal table and for each record in the internal table i have to read the long text inorder to compare the long text for the given search text.

If i use Read_text inside the loop and endloop it works but it may not be appropriate in performance point of view.

Is there any function module which can read long texts for more records at a time.

The long text data in STXL will be in raw data format right? is there any way to convert raw data to normal so that by hitting the STXL i can read the long text data for more than one record at a time.

Thanks in advance

sanju.

3 REPLIES 3

Former Member
0 Kudos

HI Sanju,

Below is a code snippet which describes reading a long text frm the screen and appending it into the internal table.This code is actually to read the text from the screen and inserting a record into STXl and STXH.

From your query what i understood is that you are storing the long text from the screen into a internal table and so you not want to use the read_text FM due to performance issue.

Since tdline(tline table) is 132 char long format i use this small logic to read the screen data and append it to my internal table.

*Data Declarations

DATA: lv_strlen TYPE i,

lv_create TYPE boolean,

lv_desc TYPE string.

DATA: ls_text TYPE tline,

ls_basic_text TYPE stxh.

DATA: lt_text TYPE ztty_tline_tab.

CONSTANTS:

lc_tdid TYPE thead-tdid VALUE 'Z001',

lc_tdobject TYPE thead-tdobject VALUE 'Z_ALERTS'.

*Appending the text to the internal table.

lv_strlen = STRLEN( iv_alert_text-alert_text ).

lv_desc = iv_alert_text-alert_text.

IF lv_strlen < 132.

ls_text-tdformat = '*'.

ls_text-tdline = lv_desc.

APPEND ls_text TO lt_text.

ELSE.

*logic to wrap text

DO.

ls_text-tdformat = '*'.

IF STRLEN( lv_desc ) < 132.

ls_text-tdformat = '*'.

ls_text-tdline = lv_desc.

APPEND ls_text TO lt_text.

EXIT.

ENDIF.

IF lv_desc+132(1) <> ' '.

CONCATENATE lv_desc(131) '-' INTO ls_text-tdline.

lv_desc = lv_desc+131.

ELSE.

ls_text-tdformat = '*'.

ls_text-tdline = lv_desc(132).

lv_desc = lv_desc+132.

ENDIF.

APPEND ls_text TO lt_text.

ENDDO.

ENDIF.

Please award graciously if found helpful.Please do ask me if i have not answered you properly.

Thank you.

Message was edited by:

P M Harish

former_member632991
Active Contributor
0 Kudos

Hi,

it will be better to use FM read_text in loop then to write ur own code

because that FM will not be taking a lot of time as it is SAP standard fn.

Try within loop and check .

Regards,

Sonika

Former Member
0 Kudos

Hi,

You have to use this fun module READ_TEXT in the loop of the data records(material records, PO records, SO records etc).

because for example for PO: every item Text the OBJECTNAME is the concatenation of the PONUMBER and the ITEM number.

You have to concatenate and to use that as OBJECTNAME.

So only within the loop you can use this. And as such it doesn't take much time.

we have used like that in so many programs.

reward points if useful

regards,

Anji