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

Split probelm

Former Member
0 Likes
825

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

8 REPLIES 8
Read only

Former Member
0 Likes
794

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

Read only

Former Member
0 Likes
794

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.

Read only

0 Likes
794

Hi ,

Use

REPLACE ALL OCCURRENCES of ',"' In str WITH space.

REPLACE ALL OCCURRENCES of '"' In str WITH space.

hope it wil work

Read only

Former Member
0 Likes
794

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.

Read only

Former Member
0 Likes
794

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

Read only

0 Likes
794

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 ','.

Read only

0 Likes
794

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

Read only

Former Member
0 Likes
794

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.