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 the data from READ_TEXT FM into single string.

Former Member
0 Kudos

Dear Friends,

I am having a Internal table with field text length 200 CH,

And I am looping this itab to get the long text with using READ_TEXT FM, Now I am having the 5 rows of Descr in another itab2 which we got from this FM.

Now I want to modify the looping Itab with this text in single line.

Exp : data from read_text FM.

Itab2 first 40 Chars ( First row ) = some text 1.

Itab2 first 40 Chars ( Second row ) = some text 2.

Itab2 first 40 Chars ( third row ) = some text 3.

Itab2 first 40 Chars ( fourth row ) = some text 4.

Itab2 first 40 Chars ( Fifth row ) = some text 5.

This data should go into my main Itab which is I am looping like:

Itab-text = some text 1 some text 2 some text 3 some text 4 some text 5.

Itab-text is 200 Chrs length field and first 40 chars is Itab2 First row and second 40 Chars Itab2 second row ....... like the same.

How to do this...

Thanks,

Sridhar

5 REPLIES 5

Former Member
0 Kudos

Hi,

u can use offset...

eg:

itab-text+0(40) = text1.

itab-text+41(80) = text2.

itab-text+81(120) = text3.

itab-text+121(160) = text4.

itab-text+161(200) = text5.

Rgds,

Pavan

Former Member
0 Kudos

hai , reddy

u can concatenate the rows in to a single line

regards

afzal

Former Member
0 Kudos

Hey Sridhar,

Follow this example of READ_TEXT functions reading tables PBIM - Independent requirements for material.

REPORT ZTEXT .

TABLES: PBIM.

* stxh, stxl, stxb - trans tables for text
* ttxit - text on text-ids
* ttxot - Short texts on text objects
* Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
                S_WERKS FOR PBIM-WERKS.

DATA: BEGIN OF HTEXT.
        INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.

DATA: BEGIN OF LTEXT OCCURS 50.
        INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.

DATA: BEGIN OF DTEXT OCCURS 50.
DATA:   MATNR LIKE PBIM-MATNR.
        INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.

DATA: TNAME LIKE THEAD-TDNAME.

SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
  MOVE PBIM-BDZEI TO TNAME.
  CALL FUNCTION 'READ_TEXT'
       EXPORTING
*           CLIENT                  = SY-MANDT
          ID                      = 'PB'
          LANGUAGE                = 'E'
          NAME                    = TNAME
          OBJECT                  = 'PBPT'
*         ARCHIVE_HANDLE          = 0
     IMPORTING
          HEADER                  = HTEXT
     TABLES
          LINES                   = LTEXT
     EXCEPTIONS
          ID                      = 1
          LANGUAGE                = 2
          NAME                    = 3
          NOT_FOUND               = 4
          OBJECT                  = 5
          REFERENCE_CHECK         = 6
          WRONG_ACCESS_TO_ARCHIVE = 7
          OTHERS                  = 8.
  LOOP AT LTEXT.
    IF LTEXT-TDLINE NE ''.
      MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
      MOVE PBIM-MATNR TO DTEXT-MATNR.
      APPEND DTEXT.
    ENDIF.
  ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
  WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.

If it is smartform or script you can include the text object directly with out using READ_TEXT FM.

Former Member
0 Kudos

Hi,

U can do like this.

take a new variable or free itab-text.

Loop at Itab2.

concatenate itab-text itab2-text into itab-text.

endloop.

So that every time u loop text will be appended to itab text and finally u will get as u wanted to

itab-text = sometext1sometext2.....

Regards,

V S PhaniRam G.

Former Member
0 Kudos

Hi.. i can do this by using offset and concatination like below.

and for modifing an internal table u have to read that internal table instead if looping.

so create one temporary internal table (TEMP) of type ITAB. then write code like below.

loop at ITAB.

TEMP-field1 = ITAB-field1.

.

.

.

concatinate text1 text2 text3 text4 text5

into TEMP-text.

append TEMP.

endloop.

clear ITAB.

free ITAB.

refresh ITAB.

ITAB[] = TEMP[].

clear TEMP.

free TEMP.

refresh TEMP.

hope this will work.

Regards,

KP.