03-02-2006 10:50 AM
Hello,
How can I turn this string:
20090914
Into
14092009
Regards
Tomas
03-02-2006 10:55 AM
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.
03-02-2006 10:52 AM
03-02-2006 10:54 AM
maybe if it is for output, this may be interesting for display
data : date type d,
output(15).
write date to output.
regards,
03-02-2006 10:53 AM
concatenate string6(2) string4(2) string+0(4) into new_string.
condense new_string
03-02-2006 10:55 AM
suppose ,
S_char = '20090914'.
s_char2
then
concatenate s_char6(2) s_char4(2) s_char+0(4) into s_char2.
Regards ,
Sriranjani.
03-02-2006 10:55 AM
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.
03-02-2006 10:55 AM
03-02-2006 10:57 AM
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
03-02-2006 10:57 AM
REPORT YCHATEST .
data : date1(8) value '20090914',
date2(8).
concatenate date16(2) date14(2) date1+0(4) into date2.
write : date2.
03-02-2006 11:01 AM
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
03-02-2006 11:03 AM
03-02-2006 4:32 PM
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