View previous topic :: View next topic
|
Author |
Message |
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
In DSNTIAUL, I am trying to unload a float value. When i open the SYSREC file I see values in packed format. I want to know is there any why I can convert the FLOAT values to a readable format while unloading data from the table? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
A visit to the film director's couch? Launching fly, hook and line into the water to try to catch a fish?
Or some other sort of "casting"? |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
I tried using Cast function --
When I try to cast it to DECIMAL --> Decimal sign was getting lost.
Also when I am trying to cast it as DECIMAL(10,3) then the decimal part was retained but hardcoding 10,3 will not work for all the cases. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
COBOL equivalent for FLOAT is COMP-2 . |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
For COMP-2 (long Floating Point) fields, if it is redefined as a PIC X(08) and moved to WS-PACKED-X (1:8) it should successfully unpack and be readable in WS-DISPLAY-X (1:16).
The same would apply to COMP-1 (short Floating Point), if redefined as PIC X(04) and moved to WS-PACKED-X (1:4).
In an UNPK instruction (MOVE WS-PACKED-V9 TO WS-DISPLAY-V9), each 4-Bit value unpacks with a high-order 'F' zone.
In the link-solution posted, (after the MOVE statement), WS-DISPLAY-X is always left-justified with low-order ZEROS.
Give it a try (although, no guarantees)....
Bill |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
char(floatcol) will return the scientific notation : 1.57658E-2
it depends on what you call "readable" |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Thanks GuyC... I tried this already... But i want to display it as 0.0157658 |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi All,
I tried the below code....
Code: |
SELECT
DECIMAL(SUBSTR(CHAR(1.023E02),1,LOCATE('E',CHAR(1.023E02))-1),31,18)*POWER(10,INTEGER(SUBSTR(CHAR(1.023E02),LOCATE('E',CHAR(1.023E02))+1,LENGTH(STRIP(CHAR(1.023E02))))))
FROM SYSIBM.SYSDUMMY1 ;
|
Is there any better way to do this? Also will there be any data problem if I use this? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
that is exactly the same as casting it to DECIMAL(31,18)
and it will have the same (or worse) problem with numbers outside 1E-15 or 1E+12 |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Thanks GuyC |
|
Back to top |
|
|
|