‎2010 Jul 30 11:04 AM
Hi,
I have a requirement like
S2551034900000,"1","0,00" should become S2551034900000 1 0,00
If i use split at comma the "0,00" has become 0 00 but i want it as single value 0,00.
Is it possible.
Thanks
‎2010 Jul 30 11:21 AM
Hi check the below code
text = `2551034900000,"1","0,00"`.
Just use three var str1, str2, str3.
SPLIT text AT ',' INTO: str1 str2 str3.
Str2 and str3 will have the double quotes.You can remove that by REPLACE command.
Edited by: Senthil Kumar on Jul 30, 2010 3:51 PM
‎2010 Jul 30 11:28 AM
well you cant tell the split statement that it should ignore split criterias which are between hyphens, which would be the soltuion.
you either got to do it manually with string operations and then notice the case where you split 0,00 (seems only case where sign BEFORE split sign and AFTER is numerical) and dont do it for this case.
another much more efficient way would be to ask the dudes from which you get those strings or flat file, from which your string is one line i suppose, to generate it with other seperators than comma. preferably ;.
then you can doa split at ; and all is fine.
‎2010 Jul 30 11:33 AM
Hi ,
Use
REPLACE ALL OCCURRENCES of ',"' In str WITH space.
REPLACE ALL OCCURRENCES of '"' In str WITH space.
hope it wil work
‎2010 Jul 30 11:42 AM
Hi Venkat.
I am new to SAP, but I tried, and I think I am getting (desired?)result.
DATA: LV_VAR1 TYPE STRING,
LV_STR1 TYPE STRING,
LV_STR2 TYPE STRING,
LV_STR3 TYPE STRING,
LV_RES TYPE STRING.
LV_VAR1 = 'S2551034900000,"1","0,00"'.
WRITE :/ LV_VAR1.
SPLIT LV_VAR1 AT ',' INTO LV_STR1 LV_STR2 LV_STR3.
WRITE:/ 'STR1' , LV_STR1.
WRITE:/ 'STR2' , LV_STR2.
WRITE:/ 'STR3' , LV_STR3.
REPLACE '"' WITH ' ' INTO LV_STR2.
WRITE:/ 'STR2' , LV_STR2.
REPLACE '"' WITH ' ' INTO LV_STR2.
WRITE:/ 'STR2' , LV_STR2.
REPLACE '"' WITH ' ' INTO LV_STR3.
WRITE:/ 'STR3' , LV_STR3.
REPLACE '"' WITH ' ' INTO LV_STR3.
WRITE:/ 'STR3' , LV_STR3.
CONCATENATE LV_STR1 LV_STR2 LV_STR3 INTO LV_RES.
WRITE:/ 'Result :' , LV_RES.
Hope it'll help you.
Thanks and regards,
Sachin Bhatt.
‎2010 Jul 30 12:02 PM
Hi
My requirement is "0,00" should treat a single value. it should not split into to two string.
"S2551034900000","1","0,00" should become S2551034900000 1 0,00
Thanks
‎2010 Jul 30 12:36 PM
Hello,
use this
DATA: l_str TYPE string.
l_str = '"S2551034900000","1","0,00"'.
TYPES: BEGIN OF itab_type,
word(20),
END OF itab_type.
DATA: itab TYPE STANDARD TABLE OF itab_type.
SPLIT l_str AT '"' INTO TABLE itab.
DELETE itab WHERE word EQ ','.
‎2010 Jul 30 1:29 PM
Hi,
Is my answer didnt work for you?
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
text TYPE string.
text = `2551034900000,"1","0,00"`.
SPLIT text AT ',' INTO: str1 str2 str3.
WRITE : str1,str2,str3.
Am getting the output as 2551034900000 "1" "0,00"
You can remove the double quote(") by using REPLACE commands.
Try it in SE38 and check the output
Edited by: Senthil Kumar on Jul 30, 2010 5:59 PM
‎2010 Jul 30 1:36 PM
Hello,
Use the foollowing code.It worked.
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
text TYPE string.
text = `2551034900000,"1","0,00"`.
*SPLIT text AT ',' INTO: str1 str2 str3.
replace all occurrences of '"' in text with '' .
WRITE : text.
Thanks.
Ramya.