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

separating lines

Former Member
0 Likes
2,111

I am using GET_TEXT_AS_R3TABLE from cl_gui_textedit class, and i obtein some lines in a table with ## marking the line jump, but i don´t know how to do it, because if i try to split at '##' it doesn´t do it, have i to convert one by one characters to ascii code or is there any way to do it?,

Thanks in advance.

example:

xxxxxxxx##ccc##vv####

i want:

xxxxxxxx##

ccc##

vv####

20 REPLIES 20
Read only

Former Member
0 Likes
2,016

Hi carl,

1. when we use this method,

we don't get any ##,

we stragith away get the 3 lines

2.

CALL METHOD editor->get_text_as_r3table

  • EXPORTING

  • ONLY_WHEN_MODIFIED = FALSE

IMPORTING

table = a

  • IS_MODIFIED =

EXCEPTIONS

  • ERROR_DP = 1

  • ERROR_CNTL_CALL_METHOD = 2

  • ERROR_DP_CREATE = 3

  • POTENTIAL_DATA_LOSS = 4

OTHERS = 5

regards,

amit m.

Read only

0 Likes
2,016

I have tried to use this method, but my problem is that sometimes i have one line that have more than 120 characters, because they can write pharagraphs without enter, so with this another method, how can i know that one line is a new line or not?

Thanks in advance

Read only

Former Member
0 Likes
2,016
report ychatest.

data : str(45) value 'xxxxxxxx##ccc##vv####'.

data: BEGIN OF ITAB occurs 0,
        WORD(20),
      END   OF ITAB.


split str at '#' into table itab.

loop at itab.
   write : / itab-word.
endloop.

output is 
xxxxxxxx
ccc
vv
Read only

0 Likes
2,016
data : text(100) value 'yourtext with hashes'.
data: begin of it_text occurs 0,
        char(20),
      end of  it_text.

split text at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into table it_text.
loop at it_text. 
  write : / it_text-char.
endloop.
Read only

0 Likes
2,016

Hi sekhar, the problem is that i think that it doesn´t works because they are special character, not a simple #,

thanks in advance

Read only

0 Likes
2,016

Try this ....

data : text(100) value 'yourtext with hashes'.data: begin of it_text occurs 0,
        char(20), 
     end of  it_text.
split text at CL_ABAP_CHAR_UTILITIES=>CR_LF into table it_text.
loop at it_text.
   write : / it_text-char.
endloop.

Regards

Vijay

Read only

Former Member
0 Likes
2,016

Hi again,

1. Carriage and LINE FEED.

2. those two characters ##

actually must be

Carriage, and Line Feed.

3. To split them use like this.

data : a(100) type c.

data: BEGIN OF ITAB occurs 0,

WORD(20),

END OF ITAB.

split a at <b>CL_ABAP_CHAR_UTILITIES=>CR_LF</b> into table itab.

regards,

amit m.

Read only

0 Likes
2,016

Sorry, but the CL_ABAP_CHAR_UTILITIES=>CR_LF gives me a syntax error, is there any declaration else needed?

Thaks in advance

Read only

0 Likes
2,016

Hi again,

1. just check out in SE24,

whether this class is there or not.

CL_ABAP_CHAR_UTILITIES

2. U can try like this also.

report abc.

<b>data : m type ref to CL_ABAP_CHAR_UTILITIES.</b>

data : a(100) type c.

data: BEGIN OF ITAB occurs 0,

WORD(20),

END OF ITAB.

<b>split a at m->CR_LF into table itab.</b>

regards,

amit m.

Read only

0 Likes
2,016

I don´t have this class in my sap version 4.6C, or at least it doesn´t appear in se24

Read only

0 Likes
2,016

what error you got, and check it in SE24 for that class.

class cl_abap_char_utilities definition load.

then use split...etc.

regards

Vijay

Read only

0 Likes
2,016

Hi again, The program doesn´t works too, is there any other solution please?

Thanks in advance

Read only

0 Likes
2,016

Hi Carl,

then you need take help of hexadecimal values . using them only you can split.

Regards

Vijay

Read only

0 Likes
2,016

Carl, what release are you working with and can you please post your code. I told have this problem in my system. It does not show the ## signs in my text.

Regards,

Rich Heilman

Read only

0 Likes
2,016

Take the following example program. Here, I am not seeing any ## when entering text and writing it out to the list.



report zrich_0001 .

data:
      dockingleft  type ref to cl_gui_docking_container,
      text_editor    type ref to cl_gui_textedit,
      repid type syrepid.

data: textlines type table of tline-tdline,
      wa_text type tline-tdline.

parameters: p_check.

at selection-screen output.

  repid = sy-repid.

  create object dockingleft
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = dockingleft->dock_at_left
                        extension = 1070.

  create object text_editor
              exporting
                   parent     = dockingleft.

start-of-selection.

  call method text_editor->get_text_as_r3table
     importing
           table              = textlines
     exceptions
           others             = 1.

  loop at textlines into wa_text.
    write:/ wa_text.
  endloop.

Regards,

Rich Heilman

Read only

0 Likes
2,016

Hi Rich,

i am in 4.6C, but i think that i have obtain the solution with the ascii characters, the # returns a 0D.

My code:

CALL METHOD o_editor->GET_TEXT_AS_STREAM

IMPORTING

TEXT = it_memo[]

IS_MODIFIED = modificat.

data: begin of it_text occurs 0,

char(120),

end of it_text.

data: a(120), b(120).

if modificat = 1.

loop at it_memo.

data texto(1).

data texto2(2).

data contador type i value 0.

do 120 times.

contador = contador + 1.

clear texto.

if contador = 1.

texto = it_memo-linea(1).

else.

clear contador2.

texto = it_memo-linea+contador(1).

endif.

CALL FUNCTION 'URL_ASCII_CODE_GET'

EXPORTING

TRANS_CHAR = texto

IMPORTING

CHAR_CODE = texto2.

enddo.

Thanks in advance for everybody

Read only

0 Likes
2,016

Here is your problem.


<b>CALL METHOD o_editor->GET_TEXT_AS_STREAM</b>

Don't retrieve as a stream, retrieve it as a table like I've done in the example code above using the method

<b>get_text_as_r3table</b>.

Problem will be solved. No need to split the text.

Regards,

Rich Heilman

Read only

0 Likes
2,016

Hi Rich, my problem was that i have pharagraphs and i wanted to know if i have make a jump line or not, but with ascii characters i have resolved the problem,

Thank you very much

Read only

0 Likes
2,016

Since you are in 46c, you can use SPLIT at a hex value as follows. This is not allowed in higher versions, but in 46c, it is allowed.

data: v_tab type x value '09'.

split mytext at v_tab into a b c......

Use the corresponding hex equivalents for line feed, soft line feed, new line etc.

Here is the complete list of<a href="http://www.laynetworks.com/ASCII%20to%20hex%20value%20chart.htm">hex conversions</a>.

Read only

Former Member
0 Likes
2,016
try this .. i had assumed that ur text consists of only characters(lower case) and no numericals

REPORT ychatest.

DATA : str(45) VALUE 'xxxxxxxx##ccc##vv####',
       strlength TYPE i,
       i1 TYPE i VALUE 0,
       j1 TYPE i VALUE 1,
       char(1).

DATA: BEGIN OF itab OCCURS 0,
        word(20),
      END   OF itab.

TRANSLATE str TO UPPER CASE.
strlength = STRLEN( str ).

DO strlength TIMES.
  char = str+i1(j1).
  SEARCH sy-abcde FOR char.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
  i1 = i1 + 1.
ENDDO.
TRANSLATE str TO LOWER CASE.

SPLIT str AT char INTO TABLE itab.

LOOP AT itab.
  WRITE : / itab-word.
ENDLOOP.