02-28-2007 4:51 PM
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.
02-28-2007 4:55 PM
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
02-28-2007 4:55 PM
why don't u declare as var(11) type p decimals 2
award points if it helps.
02-28-2007 5:51 PM
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
02-28-2007 6:17 PM
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