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: 

How many bytes are required to store an integer?

Former Member
0 Kudos

Hello,

I ran this statement: DATA x(2) TYPE i value 234.

I thought the value of x should be 23, because i defined it with the lenght of 2 bytes.

In the sap help i found that the lenght of an integer is 4. But i can define DATA x(5).

I am little confused.

Thanks,

Efren

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Just perform a syntax check (not an activation) and you will get the answer "Length specification not allowed with type "I".", Here the editor allows you an invalid input, only raising a warning. As integer length is always 4 bytes, your (2) or (5) are ignored by compiler. (if you want to give a length use a TYPE "N" where you get one byte per digit, what you were wrongly expecting for integer which are stored in binary)

Regards,

Raymond

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos

Just perform a syntax check (not an activation) and you will get the answer "Length specification not allowed with type "I".", Here the editor allows you an invalid input, only raising a warning. As integer length is always 4 bytes, your (2) or (5) are ignored by compiler. (if you want to give a length use a TYPE "N" where you get one byte per digit, what you were wrongly expecting for integer which are stored in binary)

Regards,

Raymond

0 Kudos

Right.

But when i define DATA x TYPE i value 23231234, the value of x shouldn't be 2323? Because the lenght if 4 no?

Thanks.

0 Kudos

No you confuse between type "I" integer, stored binary mode, and type "N" stored in character mode

23231234 is stored

- "01627B02" in binary/integer - TYPE I

- "23231234" in numc/char non-unicode - TYPE N on a non-Unicode system

- "0031003200330034" in numc/char unicode - TYPE N on a Unicode system

Remarks :

- TYPE N allows a length declaration.

- TYPE I allows a range from -2147483648 to +2147483647 (4294967296 different values 2^32, minus sign)

Regards,

Raymond

Former Member
0 Kudos

Thanks Raymond.