MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COMP-2 to Integer without losing decimal places and signs

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
shuko
Beginner


Joined: 08 Nov 2005
Posts: 73
Topics: 20

PostPosted: Fri Mar 30, 2007 2:27 am    Post subject: COMP-2 to Integer without losing decimal places and signs Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Mar 30, 2007 4:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Mar 30, 2007 11:19 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
samlwho
Beginner


Joined: 08 Feb 2007
Posts: 21
Topics: 2

PostPosted: Fri Mar 30, 2007 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Mar 30, 2007 2:38 pm    Post subject: Reply with quote

Quote:
If my understanding of COMP-2 is correct


Your understanding of COMP-2 is NOT correct. COMP-2 is NOT PD - COMP-3 is PD. As I said, COMP-2 is FL.

For a table showing COBOL formats vs DFSORT formats, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/C.3?SHELF=ICE1SH20&DT=20060615185603
_________________
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
View user's profile Send private message Send e-mail Visit poster's website
samlwho
Beginner


Joined: 08 Feb 2007
Posts: 21
Topics: 2

PostPosted: Fri Mar 30, 2007 4:09 pm    Post subject: Reply with quote

Thanks for the link Frank.

Question.

Knowing 705.50 (Comp-3) looks like this in Hex:

Code:

000755
00000C


What does the same number FL (Comp-2) look like in Hex?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Mar 30, 2007 4:26 pm    Post subject: Reply with quote

samlwho,

Comp-1 or comp-2 have the sign in the leftmost bit and the next 7 bits contain the exponent; the remaining 3 or 7 bytes contain the mantissa. COMP-1 and COMP-2 data items are stored in z900 hexadecimal format.

check this link for internal reprenstation of all COMP data

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.3.4.7?DT=20020923143836

705.50 is stored as

Code:

42100000
3C800000


kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
samlwho
Beginner


Joined: 08 Feb 2007
Posts: 21
Topics: 2

PostPosted: Fri Mar 30, 2007 4:30 pm    Post subject: Reply with quote

Thanks for the knowledge.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Mar 30, 2007 4:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group