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

Passing line text in a string

Former Member
0 Likes
1,419

Hi Experts,

Please advice how to pass text in a multiple lines so to a string so that every next line data only comes after 72 characters from the first irrespective of the characters of data existing in previous line..

for ex. My Name is Ankur ==> Line 1

What is your Name? ==> Line 2

is passed in a string in such a way that the Line 2 text only comes after 72 characters of first line whether or not it has that many characters in its text.

I am looping the internal table whch holds multiple line text.

Thanks,

Ankur

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,201

you can try a logic something similar to this. here it considers 16 chaarcters


DATA:BEGIN OF wa,
     line(72),
     END OF wa.
DATA:it TYPE TABLE OF char72.
DATA:lv_string TYPE string.
DATA:len TYPE i,
     l_off TYPE i,
     r_off TYPE i,
     lam type i.
lv_string = '123123jbjskdhvkkxzncjkn1234123jhjkhzkdvczjcklzxjcklxjzclkzxjcklj13j12kl3j1kljlk12j3kjlk2j3'.
l_off = 0.
r_off = 16.
len = STRLEN( lv_string ) - 1.
DO.
    lam = l_off + 16.
    if lam >= len.
    lam = len - l_off.
    wa-line = lv_string+l_off(lam).
    APPEND wa TO it.
    CLEAR wa.
    EXIT.
  ENDIF.
  wa-line = lv_string+l_off(16).
  l_off = l_off + 16.
 APPEND wa TO it.
  CLEAR wa.
ENDDO.

Hi Experts,

Please advice how to pass text in a multiple lines so to a string so that every next line data only comes after 72 characters from the first irrespective of the characters of data existing in previous line..

for ex. My Name is Ankur ==> Line 1

What is your Name? ==> Line 2

is passed in a string in such a way that the Line 2 text only comes after 72 characters of first line whether or not it has that many characters in its text.

I am looping the internal table whch holds multiple line text.

Thanks,

Ankur

5 REPLIES 5
Read only

Former Member
0 Likes
1,201

Please ignore this!

Regards,

raghu

Edited by: Raghavendra nilekani on Aug 25, 2010 1:13 PM

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,201

you can find the strlen and if string length is greater than 72 , write text to new line .

Read only

Former Member
0 Likes
1,201

you can use function module "TEXT_SPLIT"

Regards,

Lalit Mohan Gupta

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,202

you can try a logic something similar to this. here it considers 16 chaarcters


DATA:BEGIN OF wa,
     line(72),
     END OF wa.
DATA:it TYPE TABLE OF char72.
DATA:lv_string TYPE string.
DATA:len TYPE i,
     l_off TYPE i,
     r_off TYPE i,
     lam type i.
lv_string = '123123jbjskdhvkkxzncjkn1234123jhjkhzkdvczjcklzxjcklxjzclkzxjcklj13j12kl3j1kljlk12j3kjlk2j3'.
l_off = 0.
r_off = 16.
len = STRLEN( lv_string ) - 1.
DO.
    lam = l_off + 16.
    if lam >= len.
    lam = len - l_off.
    wa-line = lv_string+l_off(lam).
    APPEND wa TO it.
    CLEAR wa.
    EXIT.
  ENDIF.
  wa-line = lv_string+l_off(16).
  l_off = l_off + 16.
 APPEND wa TO it.
  CLEAR wa.
ENDDO.

Read only

0 Likes
1,201

or you can use the function RKD_WORD_WRAP , pass string to TEXTLINE and 132 to OUTPUTLEN.