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 Literals

0 Kudos

Hi,

I have a doubt regarding the default type that is associated with Numerical literals. When is the default type P and when is it I.

Thanks in advance.

Regards,

Sham.

1 ACCEPTED SOLUTION

0 Kudos

Hi,

For P the literal value has to be in quotes like this '10.01'.

p = '10.01'.

For I it is normal.

i = 10.

P is for Floating point data where in you want to have DECIMALS as well.

I is for Integer type of DATA.

I size is 4 bytes Where as P size can be 1 to 16 bytes.

And P is generic you need to mention the length using ( ) or using LENGTH like this.

DATA: p_type(10) type P.

SAP Documentation for Numeric Literals if you have not seen this before.

<b>Numeric Literals</b>

Numeric literals consist of continuous sequences of numbers (0 to 9), which can be directly preceded by a plus or minus sign. Numeric literals between -2147483648 and 2147483647 have the predefined ABAP type i. Numeric literals outside of this interval have the predefined ABAP type p with a length of 8 bytes if they are not longer than 15 digits, and with a length of 16 bytes if they are not longer then 31 digits. Numeric literals with more than 31 digits are not possible.

In numeric literals, neither decimal separators nor scientific notation with mantissa and exponent are possible. To be able to represent numbers with fractional portion or numbers in scientific notation as a literal, you must use character literals. When using them at operand positions at which a numeric value is expected, they are converted accordingly. The same applies for numbers with more than 31 digits.

1 REPLY 1

0 Kudos

Hi,

For P the literal value has to be in quotes like this '10.01'.

p = '10.01'.

For I it is normal.

i = 10.

P is for Floating point data where in you want to have DECIMALS as well.

I is for Integer type of DATA.

I size is 4 bytes Where as P size can be 1 to 16 bytes.

And P is generic you need to mention the length using ( ) or using LENGTH like this.

DATA: p_type(10) type P.

SAP Documentation for Numeric Literals if you have not seen this before.

<b>Numeric Literals</b>

Numeric literals consist of continuous sequences of numbers (0 to 9), which can be directly preceded by a plus or minus sign. Numeric literals between -2147483648 and 2147483647 have the predefined ABAP type i. Numeric literals outside of this interval have the predefined ABAP type p with a length of 8 bytes if they are not longer than 15 digits, and with a length of 16 bytes if they are not longer then 31 digits. Numeric literals with more than 31 digits are not possible.

In numeric literals, neither decimal separators nor scientific notation with mantissa and exponent are possible. To be able to represent numbers with fractional portion or numbers in scientific notation as a literal, you must use character literals. When using them at operand positions at which a numeric value is expected, they are converted accordingly. The same applies for numbers with more than 31 digits.