Application Development and Automation 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 only

Read Text from Text Editor Object

KN-Nampoothiry
Active Participant
0 Likes
3,974

Hi,

I am using the object cl_gui_textedit to get data from user. To read the data i am using the method 'get_text_as_stream' but i am unable to determine wat variable will be able to receive the data so fetched.

Its a pointer of type standard table inside the method.

I just wanna have 200 words out of the Text edit.

So wat is the var type to be assigned to Field symbol for the same to get the data.

Regards

1 ACCEPTED SOLUTION
Read only

KN-Nampoothiry
Active Participant
0 Likes
2,053

Hi,

I had used the GET_TEXT_AS_R3TABLE and it was working satisfactorily .

The req. was to understand the stream functionality and to avoid a loop/read on table.

Also as in my requirement there was a word limit of 200. I wanted to use this so i can take the output directly to a var of char200 without actually looping at the table.

The variable declaration was very helpful and new to me.Thnx Vivek.

Anyways if anyne knows why carriage return is represented as ## in the stream .

do reply. Or is it that the carriage return/line feed is ## .

Regards

9 REPLIES 9
Read only

Former Member
0 Likes
2,053

Hi,

The text of the object will come as records in the table type parameter. Declare an internal table of character type say of length 200.

DATA : itab TYPE STANDARD TABLE OF char200. Take this length as the maximum possible length of the record.

Get the data into this internal table and then read it to get your data.

Thanks and Best Regards,

Vikas Bittera.

Read only

Clemenss
Active Contributor
0 Likes
2,053

Hi Narayanan,

as fasr as I remember you have to SAVE the text then the editor is closed and it is in the internal table you passed before.

Regards,

Clemens

Read only

former_member194669
Active Contributor
0 Likes
2,053

Hi,

Why don't you try this way.


constants: c_line_length type i value 200.

types: begin of t_texttab_line,
       line(c_line_length) type c,
       end of t_texttab_line.

data : wa_texttab type t_texttab_line.
data : g_texttab type table of t_texttab_line.

If you are using module pool call the editor in PB0.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
module status_1300 output.
  if g_editor is initial.
    g_repid = sy-repid.

    create object g_editor_container
        exporting
            container_name = 'TEXTEDITOR'
        exceptions
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    if sy-subrc ne 0.
    endif.

    create object g_editor
      exporting
         parent = g_editor_container
         wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
         wordwrap_to_linebreak_mode = cl_gui_textedit=>true
      exceptions
          others = 1.
    if sy-subrc ne 0.
    endif.
  endif.

endmodule.                    "status_1300 OUTPUT

Then for retrieve the value


* retrieve table from control
  call method g_editor->get_text_as_r3table
    importing
      table  = g_texttab
    exceptions
      others = 1.

* Free the container
  if not g_editor is initial.
    call method g_editor->free
      exceptions
        others = 1.
    if sy-subrc ne 0.
    endif.
    free g_editor.
  endif.

May this will help you

a®

Read only

KN-Nampoothiry
Active Participant
0 Likes
2,053

Hi,

That is perfect and solved. but some # is getting introduced in it when user hits enter.

Is there any ways to avoid it. Anyways suggestions are very useful.

Thanx a lot.

Please suggest if any ways to avoid the 2 hash '##' that comes in place of Enter key by user.

Regards.

Read only

0 Likes
2,053

Hi,

if you are using the method GET_TEXT_AS_R3TABLE ,this problem will be erased.In GET_TEXT_AS_STREAM the table is returned with line feed and carriage return.Thats y that is coming.In r3table there will be no problems like that.The procedures are same as stream only.

reward if useful.

Read only

KN-Nampoothiry
Active Participant
0 Likes
2,054

Hi,

I had used the GET_TEXT_AS_R3TABLE and it was working satisfactorily .

The req. was to understand the stream functionality and to avoid a loop/read on table.

Also as in my requirement there was a word limit of 200. I wanted to use this so i can take the output directly to a var of char200 without actually looping at the table.

The variable declaration was very helpful and new to me.Thnx Vivek.

Anyways if anyne knows why carriage return is represented as ## in the stream .

do reply. Or is it that the carriage return/line feed is ## .

Regards

Read only

0 Likes
2,053

Hi Narayanan ,

1. is the representation for non-printable non-diaplayable characters. See hex representation in debugger.

You way do this

data:

cr_lf type string.

concaténate

cl_abap_char_utilities=>CR

cl_abap_char_utilities=>LF

into cr_lf.

replace all occurences of cr_lf in stream with ' '.

Regards,

Clemens

Read only

0 Likes
2,053

hi,

while using stream method,the text is stored as a stream with line feeds stored as ##.To work with stream u can use the FM CONVERT_STREAM_TO_ITF_TEXT after calling the method.See the demo program SAPSCRIPT_DEMO_NOTE_EDITOR.

Read only

KN-Nampoothiry
Active Participant
0 Likes
2,053

Hi,

Thnkx for help.It was really useful & knowledgeable.

Thnkx Clemens & TT.

Regards

Edited by: Narayanan Nampoothiry K on Aug 1, 2008 10:49 AM