‎2010 Jan 20 7:00 AM
HI ,
I have a String(lenth40) = 'ABCDEFGH'
and i want to split it like this AB,CD,EF,GH.
any clue.
please help.
regards,
Sanjeev
‎2010 Jan 20 7:23 AM
Hi, try this:
DATA: text(40) VALUE 'ABCDEFGH',
tab TYPE trtexts.
CALL FUNCTION 'TR_SPLIT_TEXT'
EXPORTING
iv_text = text
iv_len = 2
IMPORTING
et_lines = tab.
Then LOOP AT tab and get the elements.
Cheers,
Bart
‎2010 Jan 20 7:06 AM
Hi Sanjeev,
Create 5 variables of your required data type.
Use offset and keep 4 alphabets in each variable like +0(4).
Use concatenate statement and separate it by using Comma (,).
Manas M.
‎2010 Jan 20 7:07 AM
‎2010 Jan 20 7:15 AM
HI ,
ithe len. is 40 char and cant create so many variable..
any thing else we can do with it ?
thanks
sanjeev
‎2010 Jan 20 7:20 AM
Hello
You do not need create variables.
This FM return table OUT_LINES.
Just loop on this table and concatenate values into your string separated by comma.
‎2010 Jan 20 7:27 AM
‎2010 Jan 20 7:33 AM
‎2010 Jan 20 7:09 AM
Hi
split the string ,store it in different variables and then concatenate all the variables with "," and store it in a variable.
Thanks
Subha
‎2010 Jan 20 7:11 AM
‎2010 Jan 20 7:11 AM
Hi,
Below is the logic.
TYPES: BEGIN OF t_tab,
val(2) TYPE c,
END OF t_tab.
DATA: l_off TYPE i ,
l_len TYPE i,
l_string TYPE string,
itab TYPE TABLE OF t_tab,
wa TYPE t_tab.
l_string = 'ABCDEFGHIJK'.
l_len = strlen( l_string ).
DO.
IF l_len GT 2.
MOVE l_string+l_off(2) TO wa-val.
APPEND wa TO itab.
ADD 2 TO l_off.
l_len = l_len - 2.
ELSE.
MOVE l_string+l_off(1) TO wa-val.
APPEND wa TO itab.
EXIT.
ENDIF.
ENDDO.
itab has the required data. If you want it to variables then you have to use those many variables instead of itab..
Thanks,
Vinod.
‎2010 Jan 20 7:15 AM
Hi
You can use FM RKD_WORD_WRAP and then concatenate the spiltted variables.
Example -
Import parameters Value
TEXTLINE ABCDEFGH
DELIMITER ,
OUTPUTLEN 2
Export parameters Value
OUT_LINE1 AB
OUT_LINE2 CD
OUT_LINE3 EF
Tables Value
OUT_LINES 0 Entries
Result: 4 Entries
‎2010 Jan 20 7:23 AM
Hi, try this:
DATA: text(40) VALUE 'ABCDEFGH',
tab TYPE trtexts.
CALL FUNCTION 'TR_SPLIT_TEXT'
EXPORTING
iv_text = text
iv_len = 2
IMPORTING
et_lines = tab.
Then LOOP AT tab and get the elements.
Cheers,
Bart