‎2007 Mar 15 6:02 PM
Hi all,
I have a requirement, as i want to split into seperate fields where the ',,' or ',,,,'
ex: Due Date,,Amount,,,,Invoive no,,Status,,Timing
want to split as 5 fields.
can you anyone help me
Thanks
‎2007 Mar 15 6:06 PM
Hi,
With as example
Data: l_str type string value 'Due Date or Amount',
l_var1 type string,
l_var2 type string.
split l_str at 'or' into l_var1 l_var2 in character mode .
If you have unknown number of variables then you can use a internal tables as well. I would suggest that you take the F1 help on the SPLIT command to learn more.
‎2007 Mar 15 6:18 PM
You can split it into a table, since all values between ,, and ,,,,, are blank, they are simply not added to the internal table.
report zrich_0001 .
data: istr type table of string.
data: xstr type string.
data: str type string.
str = 'Due Date,,Amount,,,,Invoive no,,Status,,Timing'.
split str at ',' into table istr.
loop at istr into xstr.
write:/ xstr.
endloop.
Regards,
Rich Heilman
‎2007 Mar 15 6:20 PM
You can use the internal table like this:
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What a drag it is getting old`.
SPLIT text AT space INTO: str1 str2 str3,
TABLE itab.
‎2007 Mar 15 6:22 PM
Hi!!
Try out the following code:
data :
string(40) type c,
part1(20) type c,
part2(20) type c,
part3(20) type c,
part4(20) type c,
part5(20) type c,
spli(4) value ',,,,'.
string = 'Due Date,,Amount,,,,Invoive no,,Status,,Timing'.
SPLIT STRING AT SPLI INTO PART1
PART2
PART3
PART4
PART5.
WRITE 😕 PART1,
/ PART2,
/ PART3,
/ PART4,
/ PART5.
Plzz award points if this was useful.
Regards,
Swapna.