View previous topic :: View next topic |
Author |
Message |
sasubashri Beginner
Joined: 20 May 2003 Posts: 15 Topics: 7
|
Posted: Thu Dec 18, 2003 12:12 am Post subject: Packed Decimal - Easytrieve |
|
|
--------------------------------------------------------------------------------
I have a requirement wherein I have to convert fields in the output file in to numeric edit field using Easytrive.
The input fields are Packed decimal.
STMT-300-QUANTITY PIC S9(10)V9(05) COMP-3.
In easytrive I defined the input variable as
STMT-300-QUANTITY 41 8 P 5 MASK('9999999999.99999-')
and the ouput variable as
O-QTY 30 15 N 5 MASK('9999999999.99999-').
and assigned
O-QTY = STMT-300-QUANTITY
Here when the input is negative :
For instance input is -6.65200 in packed decimal
I get the output as 00000000066520}. where in I must get it as -6.65200 only.
Can any one help me in this regard. _________________ Thanks,
Subashri. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Thu Dec 18, 2003 6:41 am Post subject: |
|
|
Subashri,
You are indeed getting -6.65200.Zd fields have the sign over punch in the last byte. so } stands for a negative zero. you find the values below.
Code: |
1 - A -1 - J EXAMPLES: NUMBER REPRESENTATION
2 - B -2 - K 10 00000001{
3 - C -3 - L 105 00000010E
4 - D -4 - M 0 00000000{
5 - E -5 - N -234 00000023M
6 - F -6 - O -30 00000003}
7 - G -7 - P
8 - H -8 - Q
9 - I -9 - R
0 - { -0 - }
|
However you cannot have a decimal point unless you redefine the field.
Define a working storage variable like this
Code: |
W-QTY W 015 N 5
W-QTY-WHOLE W-QTY 010 N 0
W-QTY-DEC W-QTY +010 005 N 0
|
Now spilt the output file definition as follows
Code: |
O-QTY-WHOLE N 010 A
O-QTY-IND N+1 001 A
O-QTY-DEC N+2 005 A
O-QTY-SIGN N+3 001 A
|
here N is the start position.
Code: |
IF STMT-300-QUANTITY < 0
O-QTY-SIGN = '-'
ELSE
O-QTY-SIGN = ' '
END-IF
W-QTY = STMT-300-QUANTITY
O-QTY-WHOLE = W-QTY-WHOLE
O-QTY-IND = '.'
OQTY-DEC = W-QTY-DEC
|
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|