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: 

regarding the printing of numeric value

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

the above specified one is not working.

it is giving the output as

B=0000000020

0 Kudos

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

0 Kudos

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?

0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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