View previous topic :: View next topic |
Author |
Message |
shuko Beginner
Joined: 08 Nov 2005 Posts: 73 Topics: 20
|
Posted: Fri Mar 30, 2007 2:27 am Post subject: COMP-2 to Integer without losing decimal places and signs |
|
|
I have a FB file with lrecl=2562 and I have a COMP-2 value in position 2403
in this file.How can I copy this file to a new file, but now by converting the COMP-2 to an Integer without losing decimal places and signs.
Thank you for any help |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Mar 30, 2007 4:01 am Post subject: |
|
|
an integer is a WHOLE number i.e. no decimals so you will lose your decimals. however you can convert by multiplying by 10 or 100 or 1000... eg 1.23 * 100 = 123 _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Fri Mar 30, 2007 11:19 am Post subject: |
|
|
comp2 is an 8-byte FL (hexadecimal floating point) value. DFSORT can convert an FL value to a signed integer, but you will lose the decimal places. See:
www.ibm.com/servers/storage/support/software/sort/mvs/peug/
for details on converting FL values to integer values. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
samlwho Beginner
Joined: 08 Feb 2007 Posts: 21 Topics: 2
|
Posted: Fri Mar 30, 2007 2:22 pm Post subject: |
|
|
Shoko,
If my understanding of COMP-2 is correct then this should do what you need. Due to the unpacking of the $ field your output file will be larger.
M18 looks like this: SI,III,III,III,IIT.TT
Leading zeroes will be suppressed, positive numbers will not have a sign while negative numbers will have a leading negative sign and the decimal will be displayed for all amounts.
Hope this helps.
Code: | //SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=1,
OUTREC=(0001:0001,2402, *1ST PART OF FILE
2403:2403,0008,PD,M18, *UNPACK & KEEP SIGN + DECIMAL
2424:2411,0152, *2ND PART OF FILE
2576:C' ')
//SORTIN DD DSN=INPUT.FILE,DISP=SHR
//SORTOF1 DD DSN=OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=2576
|
|
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
|
Back to top |
|
|
samlwho Beginner
Joined: 08 Feb 2007 Posts: 21 Topics: 2
|
Posted: Fri Mar 30, 2007 4:09 pm Post subject: |
|
|
Thanks for the link Frank.
Question.
Knowing 705.50 (Comp-3) looks like this in Hex:
What does the same number FL (Comp-2) look like in Hex? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
samlwho Beginner
Joined: 08 Feb 2007 Posts: 21 Topics: 2
|
Posted: Fri Mar 30, 2007 4:30 pm Post subject: |
|
|
Thanks for the knowledge. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Fri Mar 30, 2007 4:35 pm Post subject: |
|
|
And if you run that hexadecimal value through this DFSORT statement:
Code: |
INREC BUILD=(1,8,FL,M11)
|
The output will be:
Code: |
00000000000000000705
|
Note that the decimal places (.50) are lost since only the integer value is displayed. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
|
|