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

Conversion for Long text fields

Former Member
0 Likes
1,377

Hi,

I am doing data mapping.I have a rule like,if the length of a text is more,then split at 132,

move the text(till 132) to the target field and rest again split at 132 move to next line of the target field and so on...

I have declared my target field as :

tdline TYPE tdline.

Can anyone suggest on this.Thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
1,218

Hi,

Try something like this,


DATA: NEWLINE(4) TYPE X VALUE '0D0A'.

len = strlen( l_text ).          "---------> Length of the long text

if len > 132.
CONCATENATE l_text+0(132) l_text+132(132)  into tdline seperated by NEWLINE.
endif.

Regards,

Vikranth

Read only

0 Likes
1,218

Hi Vikranth,

This code will work till the length 264 of the text...suppose I do not know the maximum length,then how to split.Please help.

Read only

0 Likes
1,218

Use FM TR_SPLIT_TEXT to split the text at desired length & it will return internal table. Then u can loop on internal table for further processing.

CALL FUNCTION 'TR_SPLIT_TEXT'
        EXPORTING
          IV_TEXT  = Text 
          IV_LEN   = 132
        IMPORTING
          ET_LINES = IT_TRTEXTS.

Hope this helps....

Read only

0 Likes
1,218

Hi,

Well check this



DATA: NEWLINE(4) TYPE X VALUE '0D0A',
      l_text(200) type c,
      tdline type tdline,
      len type i,
      it_text type trtexts,
      wa like line of it_text,
      v_ind type i value '3'.

data: begin of it_text1 occurs 0,
      f1 type string,
      end of it_text1..

data: wa1 like it_text1.
l_text = 'aaaaaaaaaasdfaskjdfhkjasdkjdfhkjashuiwioeuroiwueroiwuei'.

CALL FUNCTION 'TR_SPLIT_TEXT'
        EXPORTING
          IV_TEXT  = l_text
          IV_LEN   = 5
        IMPORTING
          ET_LINES = IT_TEXT.

loop at it_text into wa.
move wa to it_text1-f1.
append it_text1.
endloop.

loop at it_text1.
if sy-tabix = '1'.
read table it_text1 into wa1 index 2.
concatenate it_text1-f1 wa1-f1 into tdline separated by NEWLINE.
clear wa1.
elseif not sy-tabix = '2'.
read table it_text1 into wa1 index v_ind.
concatenate tdline wa1-f1 into tdline separated by NEWLINE  .
endif.
v_ind = v_ind + 1.
endloop.
write: tdline.

Change the length in 'TR_SPLIT_TEXT' as per ur requirement.

Regards,

Vik

Read only

Former Member
0 Likes
1,218

DATA: text type string,

urtext type tdline,

len type char3.

text = urtext.

len = strlen( text ). "----


> Length of the long text

if len > 132.

CONCATENATE l_text0(132) l_text132(132) into tdline seperated by NEWLINE.

endif.

then above code works.

Edited by: AMIT KUMAR on Aug 28, 2009 8:24 AM

Read only

former_member217544
Active Contributor
0 Likes
1,218

Hi,

You can also use this Function Module: RKD_WORD_WRAP.

Regards,

Swarna Munukoti