‎2009 Aug 27 2:06 PM
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.
‎2009 Aug 27 3:32 PM
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
‎2009 Aug 28 7:12 AM
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.
‎2009 Aug 28 7:20 AM
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....
‎2009 Aug 28 7:56 AM
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
‎2009 Aug 28 7:24 AM
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
‎2009 Aug 28 7:43 AM
Hi,
You can also use this Function Module: RKD_WORD_WRAP.
Regards,
Swarna Munukoti