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 a string a minus does not work

Former Member
0 Likes
2,870

Hi all




data: DATUMSTRING type string.
       data vonstring type string.
       data bisstring type string.
       BREAK-POINT.
DATUMSTRING = '1.1.14–31.3.14'.
data: delim(1) value '-'.
  split DATUMSTRING at delim into vonstring bisstring.

result:

VONSTRING                                  1.1.14–31.3.14

Why does is not get splitted at the minus?

Thx, Ragards

Mario

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,767

Hi,

In DATUMSTRING = '1.1.14–31.3.14' , you have put two minuses i.e it's not working. Replace '--' with '-'.


Regards,

DPM

13 REPLIES 13
Read only

Former Member
0 Likes
2,767

Hello,

Am getting this results on my side.

REPORT  z_test_ybi_lol.

DATA: datumstring TYPE string.

DATA vonstring TYPE string.

DATA bisstring TYPE string.

BREAK-POINT.

datumstring = '1.1.14-31.3.14'.

DATA: delim(1) VALUE '-'.

SPLIT datumstring AT delim INTO vonstring bisstring.

WRITE / : 'datumstring:', datumstring,

         'vonstring:', vonstring,

         'bisstring:', bisstring.




Explanation is that you are splitting this string 'datumstring'  into two differents variables (vonstring bisstring) upon the delimiter -.


Thanks and kind regards,

Yovish.

Read only

0 Likes
2,767

Hi Yovish,

when I try it in "normal" ABAP then it work.

When I try it in a method, it does not work.

Could that be?

Regards Mario

Read only

0 Likes
2,767

Hi Mario

What do you see in debugging for method..? What is the difference in method?

Please paste your sample code.

Nabheet

Read only

former_member188827
Active Contributor
0 Likes
2,767

The code is working perfectly.

Regards

Read only

GirieshM
Active Contributor
0 Likes
2,767

Hi Mario,


Mario Müller wrote:

DATUMSTRING = '1.1.14–31.3.14'.
data: delim(1) value '-'.

result:

VONSTRING                                 1.1.14–31.3.14


I have executed your code and surprised when it doesnt work but later found that there is difference between

the - (hypen) and the symbol mentioned between the datumstring. Both are not same. I removed the symbol in the datumstring and replaced the hyphen and the code splits the record.

Code:

   REPORT ZTEZT.
data: DATUMSTRING type string.
       data vonstring type string.
       data bisstring type string.
       BREAK-POINT.
DATUMSTRING = '1.1.14-31.3.14'.
data: delim(1) value '-'.
  split DATUMSTRING at delim into vonstring bisstring.
  write:/ vonstring, bisstring.

Declare the symbol "-" as same in the datunstring variable and it works.

With Regards,

Giriesh M

Read only

Former Member
0 Likes
2,767

Hi Mario,

I executed your code its getting splitted.

See in debugging: the below is before split.

After split:

So output is : 1.1.14

Read only

0 Likes
2,767

Could you try it in a method?

It seems not to work in ABAP OO.

Regards

Mario

Read only

0 Likes
2,767

Hi Mario,

Have you checked my previous post.

With Regards,

Giriesh M

Read only

0 Likes
2,767

I did and it works fine there as well.

Read only

0 Likes
2,767

Hi netweaver,

could you pls.send your coding.

I do not see any differences between yours and mine.

Regards

Mario

Read only

Former Member
0 Likes
2,767

hi Mario,

Please look this ...

REPORT ZSAMPLE123456.

DATA: datumstring TYPE string.

DATA vonstring TYPE string.

DATA bisstring TYPE string.

data : char_von type char8,

        char_bi  type char8.

datumstring = '1.1.14-31.3.14'.

DATA: delim(1) VALUE '-'.

SPLIT datumstring AT delim INTO vonstring bisstring.

char_von = datumstring+0(6).

char_bi  = datumstring+7(7).

WRITE / : 'datumstring:', datumstring,

          'vonstring:', vonstring,

          'bisstring:', bisstring,

          'char_von :', char_von,

          'char_bi :', char_bi.

Thanks,

Vijay

Read only

Former Member
0 Likes
2,768

Hi,

In DATUMSTRING = '1.1.14–31.3.14' , you have put two minuses i.e it's not working. Replace '--' with '-'.


Regards,

DPM

Read only

Former Member
0 Likes
2,767

Hi all,

this is sensationell!!!!

I copied 1.1.14–31.3.14 from an excel sheet.

than I replaced - with - manually.


In hex mode:


Nr 1 is excel

Nr 2 is manually changed:


  1. 0031002E0031002E00310034  2013  00330031002E0033002E00310034
  2. 0031002E0031002E00310034  002D  00330031002E0033002E00310034

Took me 3 hours!

Thank you all


Regards

Mario