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

help with string

Former Member
0 Likes
776

hi,

i wont to add '-' to field of char 7 in the

e.g.

12-2345

ab-cdef

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
753

Hello,

Check this sample code:


DATA: STR1(10) VALUE 'ABCDEF',
      STR2 LIKE STR1.

CONCATENATE STR1+0(2) '-' STR1+2(8) INTO STR2.
WRITE: STR2.

Cheers,

Vasanth

7 REPLIES 7
Read only

Former Member
0 Likes
753

hi use concatenate statement ...

i.e,


concatenate var1 '-' var2 into var3. 

Regards,

Santosh

Read only

0 Likes
753

hi,

thanks

i have it in one field 123456 and i wont 12-3456

abcdef to ab-cdef

regards

Read only

Former Member
0 Likes
753

concatnate var1 var2 into var3 separated by '-'

Read only

Former Member
0 Likes
753

Hi Ricardo,

You can concatenate the strings as follows :

CONCATENATE 'ab' '-' 'cdef' into string SEPARATED BY SPACE.

Hope this helps.

Please reward if helpful.

Regards,

Esha Raj

Read only

Former Member
0 Likes
754

Hello,

Check this sample code:


DATA: STR1(10) VALUE 'ABCDEF',
      STR2 LIKE STR1.

CONCATENATE STR1+0(2) '-' STR1+2(8) INTO STR2.
WRITE: STR2.

Cheers,

Vasanth

Read only

Former Member
0 Likes
753

Hi,

Here your question is not cclear. We can understand your question in 2 ways.

1. DATA : char(7) Value 'abcdef',

char1(7) .

Now you want to add '-' after ab.

concatenate char0(2) '-' char3(7) INTO char1.

2. you ar getting ab fron variable var1 and cdef from var2

concatenate var1 '-' var2 INTO char1.

Read only

Former Member
0 Likes
753

Hi

Check this Small Program ..

Hope it helps..

DATA : a type char7 value '123456' ,

b type char1 value '-' .

DATA : c type char5 ,

d type char5 .

sy-fdpos = 2 .

C = a+0(sy-fdpos).

D = a+sy-fdpos.

CONCATENATE c '-' d INTO a .

WRITE a .

Thanks

Praveen