View previous topic :: View next topic |
Author |
Message |
GaneshB Beginner

Joined: 03 Dec 2002 Posts: 17 Topics: 5 Location: Columbus, GA
|
Posted: Sun Feb 29, 2004 4:21 pm Post subject: Explicit sign and decimal point in file |
|
|
Hi All,
My client want to see an explicit minus symbol and decimal point in a file using easytrieve.
This is an amount field of 6 pack 2 is moved to X(10).
For examples.
Code: |
$-555.50 should be shown in a file has -00000055.50.
|
Its urgent and any suggestion will really help me out. _________________ Regards,
Ganesh.B |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Mon Mar 01, 2004 2:04 pm Post subject: |
|
|
Ganesh,
Easytrieve does not let you have a explicit symbol for negative as well as the imbedded decimal point when writting to a file. so you need to seperate them as different fields and move the approriate value.
Let us say your packed decimal value is defined as follows
Now define the following fields in your output field for moving it to 10 byte character field.
Code: |
OUT-NUM-SIGN 001 001 A
OUT-NUM-WHOLE 002 006 N 0
OUT-NUM-DPOINT 008 001 A
OUT-NUM-DECIMAL 009 002 N 0
|
Now define a working storage variable as follows:
Code: |
W-NUM W 008 N 2
W-NUM-WHOLE W-NUM 006 N 0
W-NUM-DECIMAL W-NUM +006 002 N 0
|
Now in your program code the following logic
Code: |
IF IN-NUM < 0
OUT-NUM-SIGN = '-'
ELSE
OUT-NUM-SIGN = '+'
END-IF
W-NUM = IN-NUM
OUT-NUM-WHOLE = W-NUM-WHOLE
OUT-NUM-DPOINT = '.'
OUT-NUM-DECIMAL = W-NUM-DECIMAL
|
This will give you the desired results with sign and embedded decimal point.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
GaneshB Beginner

Joined: 03 Dec 2002 Posts: 17 Topics: 5 Location: Columbus, GA
|
Posted: Tue Mar 02, 2004 10:32 am Post subject: |
|
|
Thanks kolusu!!
I tried the way that you suggested and even I thought the same.But I am getting an Alpha value at the last byte(cozz the minus is imbedded) in my o/p.
For example
If the value of 6 P 2 is moved to X(10)(after conversion as per your suggestion).
Code: |
for value -550.50 as -550.5{ or -555.51 as -555.5A
|
How to get rid of alpha value and special characters?.Is that I have to multiply by 10 or 100's?.
When I use the o/p amount value in another program to perform computation after eliminating Alpha value.Will I get the correct result.
Please advise. _________________ Regards,
Ganesh.B |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Mar 02, 2004 10:47 am Post subject: |
|
|
Ganesh,
It is not the alpha character at the end. Since the field is defined as signed zoned decimal , it show as characters. so change the definition of the decimal field as follows( just remove the zero after N)
Code: |
OUT-NUM-DECIMAL 009 002 N
|
You will get the desired results.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|