Application Development and Automation 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: 
Read only

Packed decimals

Former Member
0 Likes
1,775

Hi all,

The program uses packed decimals to declare a field WRBTR(G_WRBTR(7) TYPE P Decimals 2) but inside the program while computing it is accecpting 9 characters with 2 decimals.When I try to manipulate with 12 digits in debugging mode then it is going for dump.

Could you please clarify how it is working?

Thanks in advance.

HI,

In Char length with One can store the 2 intergers.

6 REPLIES 6
Read only

bpawanchand
Active Contributor
0 Likes
1,201

The logic is very simple

for E;g

DATA :
   w_p(9) TYPE p DECIMALS 2.


w_p = '0123456789012345.12'.


WRITE :
  / w_p.

formula is 9 * 2 = 18 total

18-2 = 16 Number of digits before the decimal part begins

Read only

Former Member
0 Likes
1,201

HI,

In Char length with One can store the 2 intergers.

Read only

0 Likes
1,201

Avinash then what can be the output of the below snippet it is giving only One

DATA :
   w_p TYPE c.


w_p = '12'.


WRITE :
  / w_p.

Read only

0 Likes
1,201

Avinash then what can be the output of the below snippet, the o/p is one

DATA :
   w_p TYPE c.


w_p = '12'.


WRITE :
  / w_p.

Read only

former_member585060
Active Contributor
0 Likes
1,201

Hi,

WRBTR domain is WERT7 which is a CURR data type with No of Char 13 and decimals 2

So thats why it must be taking values upto 9 digits also.

7 is only internal length for that domain.

Just check the domain of that field and any ref field assigned to it.

Correct me if i am wrong.

Regards

Bala Krishna

Read only

Clemenss
Active Contributor
0 Likes
1,201

Hi Murugaperumal,

you may take a look at the special way ABAP is handling currency values: In dictionary database you are forced to link the curreny field (data type CURR) to a curreny key field (data type CUKY). CUKY carries the currency as USD, EUR and so on. This determines also the handlling of currencies with less than 2 (japanese yen, no decimals) or more than 2 decimals (i.e. EUR4 used in retail prices to cope with big quantities).

If the linkes currency key field is present, it will be considered for all input/output operations.

And then, a second useful information: Packed Decimals are a concept developed when storing space was expensive: 2 digits are stored in one byte because only 4 bits are used for each character. You will not notice that except in the data definition: A length of 7 bytes means it can store 13 digits and a sign (+/-).

The Packed Decimal consept is still used in databases becauses it can save a lot of space and the store values can still be easily read because the packing/unpacking is simple and is done on a very low (hardware) level.

Regards,

Clemens