10-06-2007 1:12 PM
Hi,
i hv doubt in this code lines.
data: k type i value 17,
n type c value 'a'.
move k to n.
*move n to k.
write k
write n
if i m using "move k to n". i m getting output 17 *, but if i use "move n to k"
i m getting runtimeerror.
could anybody tell me abt this conversion rules. and why i m getting * and runtime error.
points for sure:)
Thanks, Ajay.
10-06-2007 1:18 PM
Conversion table for source type C
Target Conversion
C The target field is filled from left to right. If it is too long, it is filled with blanks from the
right. If it is too short, the contents are truncated at the right-hand end.
D The character field should contain an 8-character date in the format YYYYMMDD .
F The contents of the source field must be a valid representation of a type F field as
described in Literals .
N Only the digits in the source field are copied. The field is right-justified and filled with
trailing zeros.
I or P
The source field must contain the representation of a decimal number, that is, a
sequence of digits with an optional sign and no more than one decimal point. The
source field can contain blanks. If the target field is too short, an overflow may occur.
This may cause the system to terminate the program.
T The character field should contain a 6-character time in HHMMSS format.
X Since the character field should contain a hexadecimal-character string, the only valid
characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. This character string is packed as a
hexadecimal number, transported left-justified, and padded with zeros or truncated on
the right.
Source Type Date
Conversion table for source type D
Target Conversion
C The date is transported left-justified without conversion.
D Transport without conversion.
F The date is converted into a packed number. The packed number is then converted
into a floating point number (see corresponding table).
N The date is converted into a character field. The character field is then converted into
a numeric text field (see corresponding table).
I or P
The date is converted to the number of days since 01.01.0001.
T Not supported. Results in an error message during the syntax check or in a runtime
error.
X The date is converted to the number of days since 01.01.0001 in hexadecimal format.
BC - ABAP Programming SAP AG
Conversion Rules for Elementary Data Types
188 April 2001
Source Type Floating Point Number
Conversion table for source type F
Target Conversion
C The floating point number is converted to the <mantissa>E<exponent> format and
transported to the character field. The value of the mantissa lies between 1 and 10
unless the number is zero. The exponent is always signed. If the target field is too
short, the mantissa is rounded. The length of the character field should be at least 6
bytes.
D The source field is converted into a packed number. The packed number is then
converted into a date field (see corresponding table).
F Transport without conversion.
N The source field is converted into a packed number. The packed number is then
converted into a numeric text field (see corresponding table).
I or P
The floating point number is converted to an integer or fixed point value and, if
necessary, rounded.
T The source field is converted into a packed number. The packed number is then
converted into a time field (see corresponding table).
X The source field is converted into a packed number. The packed number is then
converted into a hexadecimal number (see corresponding table).
Source Type Integer
Type I is always treated in the same way as type P without decimal places. Wherever type P is
mentioned, the same applies to type I fields.
Source Type Numeric Text
Conversion table for source type N
Target Conversion
C The numeric field is treated like a character field. Leading zeros are retained.
D The numeric field is converted into a character field. The character field is then
converted into a date field (see corresponding table).
F The numeric field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The numeric field is transported right-justified and padded with zeros or truncated on
the left.
I and P
The numeric field is interpreted as a number, and transferred to the target field, where
it is right-justified, and adopts a plus sign. If the target field is too short, the program
may be terminated.
T The numeric field is converted into a character field. The character field is then
converted into a time field (see corresponding table).
X The numeric field is converted into a packed number. The packed number is then
converted into a hexadecimal number (see corresponding table).
Source Type Packed Number
If the program attribute Fixed point arithmetic is set, the system rounds type P fields according to
the number of decimal places or fills them out with zeros.
Conversion table for source type P
Target Conversion
C The packed field is transported right-justified to the character field, if required with a
decimal point. The first position is reserved for the sign. Leading zeros appear as
blanks. If the target field is too short, the sign is omitted for positive numbers. If this is
still not sufficient, the field is truncated on the left. ABAP indicates the truncation with
an asterisk (*). If you want the leading zeros to appear in the character field, use
UNPACK instead of MOVE.
D The packed field value represents the number of days since 01.01.0001 and is
converted to a date in YYYYMMDD format.
F The packed field is accepted and transported as a floating point number.
N The packed field is rounded if necessary, unpacked, and then transported rightjustified.
The sign is omitted. If required, the target field is padded with zeros on the
left.
I and P
The packed field is transported right-justified. If the target field is too short, an
overflow occurs.
T The packed field value represents the number of seconds since midnight and is
converted to a time in HHMMSS format.
X The packed field is rounded if necessary and then converted to a hexadecimal
number. Negative numbers are represented by the two's complement. If the target
field is too short, the number is truncated on the left.
Source Type Time
Conversion table for source type T
Target Conversion
C The source field is transported left-justified without conversion.
D Not supported. Results in an error message during the syntax check or in a runtime
error.
F The source field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The date is converted into a character field. The character field is then converted into
a numeric text field (see corresponding table).
I and P
The date is converted to the number of seconds since midnight.
T Transport without conversion.
X The date is converted to the number of seconds since midnight in hexadecimal
format.
Source Type Hexadecimal
Conversion table for source type X
Target Conversion
C The value in the hexadecimal field is converted to a hexadecimal character string,
transported left-justified to the target field, and padded with zeros.
D The source field value represents the number of days since 01.01.0001 and is
converted to a date in YYYYMMDD format.
F The source field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The source field is converted into a packed number. The packed number is then
converted into a numeric text field (see corresponding table).
I and P
The value of the source field is interpreted as a hexadecimal number. It is converted
to a packed decimal number and transported right-justified to the target field. If the
hexadecimal field is longer than 4 bytes, only the last four bytes are converted. If it is
too short, a runtime error may occur.
T The source field value represents the number of seconds since midnight and is
converted to a time in HHMMSS format.
X The value is transported left-justified and filled with X'00' on the right, if necessary.
Message was edited by:
Raghu Reddy
10-06-2007 1:18 PM
Conversion table for source type C
Target Conversion
C The target field is filled from left to right. If it is too long, it is filled with blanks from the
right. If it is too short, the contents are truncated at the right-hand end.
D The character field should contain an 8-character date in the format YYYYMMDD .
F The contents of the source field must be a valid representation of a type F field as
described in Literals .
N Only the digits in the source field are copied. The field is right-justified and filled with
trailing zeros.
I or P
The source field must contain the representation of a decimal number, that is, a
sequence of digits with an optional sign and no more than one decimal point. The
source field can contain blanks. If the target field is too short, an overflow may occur.
This may cause the system to terminate the program.
T The character field should contain a 6-character time in HHMMSS format.
X Since the character field should contain a hexadecimal-character string, the only valid
characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. This character string is packed as a
hexadecimal number, transported left-justified, and padded with zeros or truncated on
the right.
Source Type Date
Conversion table for source type D
Target Conversion
C The date is transported left-justified without conversion.
D Transport without conversion.
F The date is converted into a packed number. The packed number is then converted
into a floating point number (see corresponding table).
N The date is converted into a character field. The character field is then converted into
a numeric text field (see corresponding table).
I or P
The date is converted to the number of days since 01.01.0001.
T Not supported. Results in an error message during the syntax check or in a runtime
error.
X The date is converted to the number of days since 01.01.0001 in hexadecimal format.
BC - ABAP Programming SAP AG
Conversion Rules for Elementary Data Types
188 April 2001
Source Type Floating Point Number
Conversion table for source type F
Target Conversion
C The floating point number is converted to the <mantissa>E<exponent> format and
transported to the character field. The value of the mantissa lies between 1 and 10
unless the number is zero. The exponent is always signed. If the target field is too
short, the mantissa is rounded. The length of the character field should be at least 6
bytes.
D The source field is converted into a packed number. The packed number is then
converted into a date field (see corresponding table).
F Transport without conversion.
N The source field is converted into a packed number. The packed number is then
converted into a numeric text field (see corresponding table).
I or P
The floating point number is converted to an integer or fixed point value and, if
necessary, rounded.
T The source field is converted into a packed number. The packed number is then
converted into a time field (see corresponding table).
X The source field is converted into a packed number. The packed number is then
converted into a hexadecimal number (see corresponding table).
Source Type Integer
Type I is always treated in the same way as type P without decimal places. Wherever type P is
mentioned, the same applies to type I fields.
Source Type Numeric Text
Conversion table for source type N
Target Conversion
C The numeric field is treated like a character field. Leading zeros are retained.
D The numeric field is converted into a character field. The character field is then
converted into a date field (see corresponding table).
F The numeric field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The numeric field is transported right-justified and padded with zeros or truncated on
the left.
I and P
The numeric field is interpreted as a number, and transferred to the target field, where
it is right-justified, and adopts a plus sign. If the target field is too short, the program
may be terminated.
T The numeric field is converted into a character field. The character field is then
converted into a time field (see corresponding table).
X The numeric field is converted into a packed number. The packed number is then
converted into a hexadecimal number (see corresponding table).
Source Type Packed Number
If the program attribute Fixed point arithmetic is set, the system rounds type P fields according to
the number of decimal places or fills them out with zeros.
Conversion table for source type P
Target Conversion
C The packed field is transported right-justified to the character field, if required with a
decimal point. The first position is reserved for the sign. Leading zeros appear as
blanks. If the target field is too short, the sign is omitted for positive numbers. If this is
still not sufficient, the field is truncated on the left. ABAP indicates the truncation with
an asterisk (*). If you want the leading zeros to appear in the character field, use
UNPACK instead of MOVE.
D The packed field value represents the number of days since 01.01.0001 and is
converted to a date in YYYYMMDD format.
F The packed field is accepted and transported as a floating point number.
N The packed field is rounded if necessary, unpacked, and then transported rightjustified.
The sign is omitted. If required, the target field is padded with zeros on the
left.
I and P
The packed field is transported right-justified. If the target field is too short, an
overflow occurs.
T The packed field value represents the number of seconds since midnight and is
converted to a time in HHMMSS format.
X The packed field is rounded if necessary and then converted to a hexadecimal
number. Negative numbers are represented by the two's complement. If the target
field is too short, the number is truncated on the left.
Source Type Time
Conversion table for source type T
Target Conversion
C The source field is transported left-justified without conversion.
D Not supported. Results in an error message during the syntax check or in a runtime
error.
F The source field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The date is converted into a character field. The character field is then converted into
a numeric text field (see corresponding table).
I and P
The date is converted to the number of seconds since midnight.
T Transport without conversion.
X The date is converted to the number of seconds since midnight in hexadecimal
format.
Source Type Hexadecimal
Conversion table for source type X
Target Conversion
C The value in the hexadecimal field is converted to a hexadecimal character string,
transported left-justified to the target field, and padded with zeros.
D The source field value represents the number of days since 01.01.0001 and is
converted to a date in YYYYMMDD format.
F The source field is converted into a packed number. The packed number is then
converted into a floating point number (see corresponding table).
N The source field is converted into a packed number. The packed number is then
converted into a numeric text field (see corresponding table).
I and P
The value of the source field is interpreted as a hexadecimal number. It is converted
to a packed decimal number and transported right-justified to the target field. If the
hexadecimal field is longer than 4 bytes, only the last four bytes are converted. If it is
too short, a runtime error may occur.
T The source field value represents the number of seconds since midnight and is
converted to a time in HHMMSS format.
X The value is transported left-justified and filled with X'00' on the right, if necessary.
Message was edited by:
Raghu Reddy
10-06-2007 1:20 PM
hi
data: k type i value 17,
n(3) type c value 'a'. --> try it like this.
move k to n.
*move n to k.
write k
write n.
it will work fine.
y your getting error menas.
1. u can move one integer variable to character but not to move character to integer.
2. y '*' sympol is comming na u didn't declare the length of the character.
3.if u specify the length of the character na u can move .
4. u can't get 17* . u should get only *. i think so..
5. type concersion error will be occur if u 'move character to integer'.
6. y u r getting menas the default character value is '',so u can't move '' to any integer value.
regards
baskaran
Message was edited by:
baskaran nagamanickam
Message was edited by:
baskaran nagamanickam
10-06-2007 1:28 PM
Thanks for thee reply..but why cant we move character to integer vartiable but can mone viaversa
10-06-2007 1:32 PM
hi
u can move if u specify the legth of the character in character field.
ex.
data: k type i value 17,
n(2) type c. -->spcify the length of the character.
regars
baskaran
10-06-2007 1:40 PM
if we specify the lenght we can move integer to character but not char to int
10-06-2007 9:12 PM
Hi,
U can move TYPE c filds to TYPE i until the TYPE c variable( in ur case n)
contains a numerical value.
TYPE c- '23' -> i : YES.
TYPE c- 'r1' -> i : not possible ,gives runtimedump as 'r1' is not convertable to TYPE i.