‎2007 Aug 31 10:16 AM
Hi,
When i execute the below coding , the output starts from the 8th postion of the list . Can anyone tell me y it starts from the 8th postion & not from the initial postion ?
data : A(10) type C value '200.22',
B(10) TYPE C VALUE '300.22',
C(10) TYPE C VALUE '400.22'.
DATA : N1 TYPE p decimals 2, N2 TYPE p decimals 2, N3 TYPE p decimals 2 .
N1 = A . N2 = B . N3 = C .
WRITE : / N1,
N2,
N3.
‎2007 Aug 31 10:19 AM
Hi vighnesh,
1. By default, numbers are RIGHT-ALIGNED.
(thats why, it starts from 8th position)
2. If u want to print left aligned,
3. do like this.
report abc.
data : A(10) type C value '200.22',
B(10) TYPE C VALUE '300.22',
C(10) TYPE C VALUE '400.22'.
DATA : N1 TYPE p decimals 2, N2 TYPE p decimals 2, N3 TYPE p decimals 2
.
N1 = A . N2 = B . N3 = C .
<b>WRITE : / N1 LEFT-JUSTIFIED,
N2 LEFT-JUSTIFIED ,
N3 LEFT-JUSTIFI</b>
regards,
amit m.
‎2007 Aug 31 10:19 AM
Hi vighnesh,
1. By default, numbers are RIGHT-ALIGNED.
(thats why, it starts from 8th position)
2. If u want to print left aligned,
3. do like this.
report abc.
data : A(10) type C value '200.22',
B(10) TYPE C VALUE '300.22',
C(10) TYPE C VALUE '400.22'.
DATA : N1 TYPE p decimals 2, N2 TYPE p decimals 2, N3 TYPE p decimals 2
.
N1 = A . N2 = B . N3 = C .
<b>WRITE : / N1 LEFT-JUSTIFIED,
N2 LEFT-JUSTIFIED ,
N3 LEFT-JUSTIFI</b>
regards,
amit m.
‎2007 Aug 31 10:20 AM
Hi,
This is because of the output length and the default alighment of variable N1/N2/N3...
Satya.
‎2007 Aug 31 10:30 AM
hi
Here the variable displayed first is N1 , which is of Type P.
By Default all numeric fields (I, P,F) are Right-justified in the Output.
The default length of Type P is 8 Bytes.
In 8 bytes it Can store the Value of 15 digits and the SIGN (-VE)
Thats why it is giving in 8ht position.
<b>reward if Helpful.</b>
‎2007 Aug 31 10:33 AM
Hi Vighnesh,
you had declared the N1 variable type as pack decimals .
datatype pack can hold a max of 16 characters.
it can hold 2 decimal places by default and you had mentioned 2 decimals only.
the last character is empty because it will hold the sign ( + or -)
it starts from the 11 th position not from the 8th position .
value 200.22 has 6 characters and in the output it starts from 11th position.
check the code below.
DATA : a(15) TYPE c VALUE '1234567890200.223',
b(10) TYPE c VALUE '300.223',
c(10) TYPE c VALUE '400.223'.
DATA : n1 TYPE p DECIMALS 2,
n2 TYPE p DECIMALS 2,
n3 TYPE p DECIMALS 2.
START-OF-SELECTION.
n1 = a. n2 = b. n3 = c.
WRITE : n1 INPUT ON,
/ n2 INPUT ON,
/ n3.
reward points if useful.
phani.