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

string operation

Anindya
Explorer
0 Likes
684

Hi All,

I have a character variable whose length is more than 72 characters.

I need to fill one internal table with that character variable but each line of the internal table will contain only 72 characters and the next 72 characters(if any ) will go to the next line and similarly for all the lines in the internal table.

What is the best possible logic to implement this???

i did something like this,

data:

lwa_text TYPE zz_odb_text,

li_text TYPE zi_odb_text,

DO lh_var TIMES.

lwa_text = lh_text + lt_count ( 72 ).

APPEND lwa_text TO li_text.

CLEAR lwa_text.

lt_count = lt_count + 73.

ENDDO.

but this is not working.......

Thanks in advance,

Anindya

1 ACCEPTED SOLUTION
Read only

Subhankar
Active Contributor
0 Likes
636

Hi....

Use the FM RKD_WORD_WRAP.

It will solve your prblem..

4 REPLIES 4
Read only

Subhankar
Active Contributor
0 Likes
637

Hi....

Use the FM RKD_WORD_WRAP.

It will solve your prblem..

Read only

andreas_mann3
Active Contributor
0 Likes
636

try fm RKD_WORD_WRAP:

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING

textline = lwa_text

delimiter = ' '

outputlen = 72

TABLES

out_lines = li_text

EXCEPTIONS

outputlen_too_large = 1

OTHERS = 2.

A.

Read only

Former Member
0 Likes
636

Hi,

try this,,

DATA: BEGIN OF itab OCCURS 0,

val(80) TYPE c,

END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

val(72) TYPE c,

END OF itab1.

DATA: count TYPE i.

itab-val ='asdfasdfadfasdadfaf'.

CONCATENATE itab-val itab-val itab-val itab-val

INTO itab-val.

DO 2 TIMES.

APPEND itab.

ENDDO.

clear: itab-val+0(13).

condense itab-val.

DO 2 TIMES.

APPEND itab.

ENDDO.

LOOP AT itab.

count = STRLEN( itab-val ).

count = count / 72.

DO count TIMES.

itab1 = itab-val+0(72).

APPEND itab1.

CLEAR itab1.

CLEAR: itab-val+0(72).

condense itab-val.

ENDDO.

IF itab-val IS NOT INITIAL.

itab1 = itab-val+0(72).

APPEND itab1.

ENDIF.

ENDLOOP.

LOOP AT itab1.

WRITE:/ itab1-val.

ENDLOOP.

regards,

Venkatesh

Read only

former_member585060
Active Contributor
0 Likes
636

Hi,

Try this logic

TYPES : BEGIN OF ty_itab,
          text(72),
         END OF ty_itab.

DATA : wa_text(500),
        n TYPE i,
        m TYPE i,   " No of loops
        c TYPE i.   " Count

DATA : it_itab TYPE TABLE OF ty_itab,
        wa_itab TYPE ty_itab.

wa_text = 'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww'.
n = STRLEN( wa_text ).

m = n / 72.    " to get no of loops

c = 0.
DO m TIMES.
  wa_itab-text = wa_text+c(72).
  APPEND wa_itab TO it_itab.
  c = c + 72.
ENDDO.


BREAK-POINT.