02-01-2008 7:44 AM
data :A type i,
B type n,
C type d,
D type c.
C = '20071220'.
A = 100.
D = 'a'.
B = '20a'.
write :/'A = ', A, 'B = ', B, 'C = ', C, 'D= ', D.
the output is giving as
B=0
what is the wrong i did here
02-01-2008 8:01 AM
Hi,
Do like this
data :A type i,
B(10) type n,
C type d,
D type c.
C = '20071220'.
A = 100.
D = 'a'.
B = '20a'.
write :/'A = ', A, 'B = ', B, 'C = ', C, 'D= ', D.
Regards,
Satish
02-01-2008 7:54 AM
Check the declaration:
>B type n,
This specifies B is of Data Type N and length 1.
Increase the length to have more visibility.
Say
>B(3) type N,
This will take Numerical characters of the value assigned and display i.e the output will be 020.
If you need it including the alpha characters, you need to use datatype C.
>B(3) type C
Output will be 20a
Regards
Eswar
02-01-2008 8:01 AM
Hi,
Do like this
data :A type i,
B(10) type n,
C type d,
D type c.
C = '20071220'.
A = 100.
D = 'a'.
B = '20a'.
write :/'A = ', A, 'B = ', B, 'C = ', C, 'D= ', D.
Regards,
Satish
02-01-2008 8:05 AM
the above specified one is not working.
it is giving the output as
B=0000000020
02-01-2008 8:10 AM
Check my earlier post where i have specified the details on how the outcome will be for different scenarios.
Whatz the output you are expecting?
~Eswar
02-01-2008 8:13 AM
what my question is can i get the output as
'20a' by specifying as numeric.
if not,then y we are saying as numeric will take both digits and alphabets?
02-01-2008 8:16 AM
Itz your conception that type N takes both Digits and Alphabets.
As explained in your other thread, Type N takes only Digits. These digits are treated as Characters.
Check this from SAP Help:
Type Explanation SL Initial value
C Text (Character) 1 space
N Numeric text 1 '00...0'
D Date (YYYYMMDD) 8 '00000000'
T Time (HHMMSS) 6 '000000'
X Hexadecimal (HeX code) 1 X'00'
I Integer 4 0
P Packed number 8 0
F Floating point number 8 0
STRING Character sequence (string) variable-length empty string
XSTRING Byte sequence (X string)
variable-length empty hexadecimal string
N Numeric text 1 '00...0'
Regards
Eswar
02-01-2008 8:05 AM
in this code u declaring B as n data type , and Type N is a text type, not a numeric data type (although its values are strings of digits) (number string) so u must specify lenth of B as for ex.
B(2) type n,
or any size in place of 2, than interprter can only able to read upto 2 places . otherwise if u don't give any thing by default it will takes it's length 1 and print only last digit of string .
thanks
if u clear reward points.
02-01-2008 8:14 AM
Hi Abhishek,
check the program.
i think that is what i did as u told.
see the sathiesh program.
Edited by: amaranath yerragunta on Feb 1, 2008 9:15 AM