Application Development 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: 

String problem

Former Member
0 Kudos

Hello,

How can I turn this string:

20090914

Into

14092009

Regards

Tomas

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi tomas,

1. Simple.

2. Just copy paste in new program.

REPORT abc.

DATA : d1(8) TYPE c.

DATA : d2(8) TYPE c.

d1 = '20090914'.

CONCATENATE d16(2) d14(2) d1(4) INTO d2.

WRITE d2.

regards,

amit m.

11 REPLIES 11

Former Member
0 Kudos

str10(2) = str6(2).

str12(2) = str4(2).

str14(4) = str0(4).

0 Kudos

maybe if it is for output, this may be interesting for display

data : date type d,

output(15).

write date to output.

regards,

Former Member
0 Kudos

concatenate string6(2) string4(2) string+0(4) into new_string.

condense new_string

former_member186077
Active Participant
0 Kudos

suppose ,

S_char = '20090914'.

s_char2

then

concatenate s_char6(2) s_char4(2) s_char+0(4) into s_char2.

Regards ,

Sriranjani.

Former Member
0 Kudos

Hi tomas,

1. Simple.

2. Just copy paste in new program.

REPORT abc.

DATA : d1(8) TYPE c.

DATA : d2(8) TYPE c.

d1 = '20090914'.

CONCATENATE d16(2) d14(2) d1(4) INTO d2.

WRITE d2.

regards,

amit m.

Former Member
0 Kudos

.....

vinod_gunaware2
Active Contributor
0 Kudos

U have to use

shift statement left or right

Shifting a String by a Given Number of Positions

SHIFT <c> [BY <n> PLACES] [<mode>].

This statement shifts the field <c> by <n> positions. If you omit BY <n> PLACES, <n> is interpreted as one. If <n> is 0 or negative, <c> remains unchanged. If <n> exceeds the length of <c>, <c> is filled out with blanks. <n> can be variable.

With the different <mode> options, you can shift the field <c> in the following ways:

<mode> is LEFT:

Shifts the field contents <n> places to the left and adds <n> blanks at the right-hand end of the field (default).

<mode> is RIGHT:

Shift <n> positions to the right and adds <n> blanks at the left-hand end of the field.

<mode> is CIRCULAR:

Shift <n> positions to the left so that <n> characters on the left appear on the right.

DATA: T(10) VALUE 'abcdefghij',

STRING LIKE T.

STRING = T.

WRITE STRING.

SHIFT STRING.

WRITE / STRING.

STRING = T.

SHIFT STRING BY 3 PLACES LEFT.

WRITE / STRING.

STRING = T.

SHIFT STRING BY 3 PLACES RIGHT.

WRITE / STRING.

STRING = T.

SHIFT STRING BY 3 PLACES CIRCULAR.

WRITE / STRING.

Output:

abcdefghij

bcdefghij

defghij

abcdefg

defghijabc

or u can use var

var = Concatenation var+ 0(10) ,....

regard

vinod

Former Member
0 Kudos

REPORT YCHATEST .

data : date1(8) value '20090914',

date2(8).

concatenate date16(2) date14(2) date1+0(4) into date2.

write : date2.

Former Member
0 Kudos

Hi Thomas

data: v_sel(8) type c value '20090914'.

concatenate v_sel+6(2)

v_sel+4(2)

v_sel+0(4)

into v_sel.

write: v_sel.

Thanks

Eswar

0 Kudos

Thanks for all response

Points are coming up.

// Tomas

Former Member
0 Kudos

Hi for printing use the logic.

data: p1(8) value '20090914',

p2 type d.

p2 = p1.

write:/ p2.

or

write:/ p16(2),p14(2),p1+0(4).

if this suits, reward with points.

satish