cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with read_text function module

Former Member
0 Kudos

Hello expert,

I am facing problem in display of the internal table's row data returned from read_text function module on web dynpro view in the text view UI element.

  is there any other  option than looping the internal table and geting the data into string .

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi vishal,

Use belo code to get data into string...

Use below code to get text..

->Create text object in SO10

->Do coding like below...

     data:      lt_tline type table of tline,

               ls_tline type tline,

                lv_string type string.

1. use 'READ_TEXT' FM to get text from SO10 which give you TLINE format table (lt_tline).

loop at lt_tline into ls_tline.

      concatenate lv_string ls_tline-tdline into lv_string.

      clear: ls_tline.

endloop.

2. Now lv_string contains full text of SO10.

            3. Bind lv_string to textedit UI element text.

Regards,

Venkat

Former Member
0 Kudos

Thanks for reply but I dont want it to do using loop at  lt_line. because i want to display as formated string where all new lines also should come.

amy_king
Active Contributor
0 Kudos

Hi Vishal,

To preserve newlines from the standard text object in the TextView string you need to loop through the text lines returned by READ_TEXT and pay attention to the TDFORMAT of each line. Try the following.

* -- Read text

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id       = ls_thead-tdid
      language = ls_thead-tdspras
      name     = ls_thead-tdname
      object   = ls_thead-tdobject
    TABLES
      lines    = lt_lines
    EXCEPTIONS
      OTHERS   = 0.

* -- Construct the text string

  LOOP AT lt_lines ASSIGNING <t> WHERE tdformat <> '/*'. " not a comment
    CASE <t>-tdformat.
      WHEN '*'. " is a newline
        CONCATENATE text_string
                    <t>-tdline
                    INTO text_string
                    SEPARATED BY cl_abap_char_utilities=>cr_lf.
      WHEN OTHERS.
        CONCATENATE text_string
                    <t>-tdline
                    INTO text_string
                    SEPARATED BY space.
    ENDCASE.
  ENDLOOP.

Cheers,

Amy