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

problem with SPLIT

Former Member
0 Likes
553

Hi,

im trying to use split and im having problems with it.

record : 12345|aaaa|12345.00-|12345.00|

im using SPLIT record at '|' into A B C D. These are of type char.everything is fine except for the field which has a negative sign.im getting zeros.

your help would be appreciated.

Thanks,

kranthi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
514

HI

GOOD

TRY TO USE THIS LOGIC IN YOUR REPORT

DATA: STRING(60),

P1(20) VALUE '++++++++++++++++++++',

P2(20) VALUE '++++++++++++++++++++',

P3(20) VALUE '++++++++++++++++++++',

P4(20) VALUE '++++++++++++++++++++',

DEL(3) VALUE '***'.

STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.

WRITE STRING.

SPLIT STRING AT DEL INTO P1 P2 P3 P4.

WRITE / P1.

WRITE / P2.

WRITE / P3.

WRITE / P4.

THANKS

MRUTYUN

4 REPLIES 4
Read only

former_member186741
Active Contributor
0 Likes
514

Hi,

are you sure the '|' is actually that? It may be some other hex value represented as '|'. You could try the following:

SPLIT record at CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB

into A B C D.

Otherwise, how are your fields record,a,b,c and d defined?

this code seems to work (though of course the final field has the '|' still):

data: a(10),b(10),c(10),d(10).

data record(40)

value '12345|aaaa|12345.00-|12345.00|'.

SPLIT record at '|' into A B C D.

write:/ a,b,c,d.

Read only

Former Member
0 Likes
514

Hi,

The below code will work for you...


Report test.
data: value1 type string value '12345|aaaa|12345.00-|12345.00|',
      a type string,
      b type string,
      c type string,
      d type string,
      e type string.

SPLIT value1 at '|' into A B C D E.

write:/ a,
      / b,
      / c,
      / d,
      / e.

Regards,

Anjali

Read only

Former Member
0 Likes
514

Hey Kranthi,

just copy and paste . Then run . You will get the correct output.

data : record(30) type c value '12345|aaaa|12345.00-|12345.00|'.

data : a type str,

b type str,

c type str,

d type str.

split record at '|' into a b c d.

d = d+0(8).

write : / a,/ b,

/ c,

/ d.

Regards,

Kunal.

Read only

Former Member
0 Likes
515

HI

GOOD

TRY TO USE THIS LOGIC IN YOUR REPORT

DATA: STRING(60),

P1(20) VALUE '++++++++++++++++++++',

P2(20) VALUE '++++++++++++++++++++',

P3(20) VALUE '++++++++++++++++++++',

P4(20) VALUE '++++++++++++++++++++',

DEL(3) VALUE '***'.

STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.

WRITE STRING.

SPLIT STRING AT DEL INTO P1 P2 P3 P4.

WRITE / P1.

WRITE / P2.

WRITE / P3.

WRITE / P4.

THANKS

MRUTYUN