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: 

data varible of type P with length 11

Former Member
0 Kudos

is it possible to create a variable of type packed decimal with size 11.

ex: var(6) type p decimals 2 will create var with lenght 12.

My requirment is to print a value of size 11 with 2 decimal points.

4 REPLIES 4

Former Member
0 Kudos

Hello,

Check this



DATA f(len). 


Additions: 
As in variant 1 



Effect 
Creates field f with the length len. 
You can only use this variant with type C, N, P, and X fields. Fields with other types can only be created in their default length (see table under "Effects" of variant 1). 


In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Wrong length specified in declaration. 

The maximum permitted length of a field depends on its type: 

Type  Permitted length 
C     1 - 65535 
N     1 - 65535 
P     1 - 16 
X     1 - 65535 


Note 
Each byte can store one character, or two decimal or hexadecimal digits. In a P field, one half-byte is reserved for the plus or minus sign. Consequently, a P field with length 3 can contain up to 5 digits, while an X field with length 3 can contain 6. Both have the output length 6. 

SO u can declare like this.

data: var(11) type p decimal 2.

If useful reward.

Vasanth

former_member191977
Contributor
0 Kudos

why don't u declare as var(11) type p decimals 2

award points if it helps.

Former Member
0 Kudos

I defined a field var1 of type p(6) with decimals 2.

ex: var1 contains 123456.23

I need to move this value into another character field or any field of length 11,

but the value should be right justified and should contain 2 decimals places and it should contain leading zeroes.

or is it to possible to define a variable of type p with length 11. ( it should accomdate 11 digits including 2 decimals.

ex:12345678.11

0 Kudos

try this..

report  zpdata                                 .
data: var1(6) type p decimals 2 value '123456.23',
      var2(11),
      var3(11) value '00000000000'.
write var1 to var2.
replace ',' in var2 with space.
write var2 to var2 right-justified.
overlay var2 with var3.
write: / var1.
write: / var2 right-justified.

~Suresh