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 

Reverse a COMP-2 Amount in a file

 
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: Thu Feb 01, 2007 8:21 am    Post subject: Reverse a COMP-2 Amount in a file Reply with quote

I have an FB file with LRECL= 2562 and Amount 8 bytes in position
2403-2410. My requriement is to copy this file as it is with only the amount
reversed. If the amount is 100 then the output file should have -100
and for -100 the the amount to be 100
The amount starts in position 2403.

[code:1:236fd2fa63]
--+----1----+----2----+----3--
******************************
AMOUNT
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: Thu Feb 01, 2007 12:52 pm    Post subject: Reply with quote

COMP-2 is an 8-byte floating point value. Are you asking if you can reverse the sign of a COMP-2 value to create another COMP-2 value?

If so, the sign of a COMP-2 value is indicated by its first bit (bit 0) - 0 for positive or 1 for negative. So to reverse the sign, you need to flip the first bit. If it's 1, change it to 0. If it's 0, change it to 1. Here's a DFSORT job that does that:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(2403,1,BI,EQ,B'0.......'),
     OVERLAY=(2403:2403,1,BI,ADD,+128,TO=BI,LENGTH=1)),
    IFTHEN=(WHEN=NONE,
     OVERLAY=(2403:2403,1,BI,SUB,+128,TO=BI,LENGTH=1))
/*

_________________
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
shuko
Beginner


Joined: 08 Nov 2005
Posts: 73
Topics: 20

PostPosted: Fri Feb 02, 2007 4:58 am    Post subject: Reply with quote

Thank you Frank. Exactly what I needed.
This raises another question. Is it possible to convert this Amount in a readable form with the + or - sign just to compare the original files before conversion and after?
Output is FB file with LRECL= 2562 and Amount starting position 2403
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 Feb 02, 2007 11:01 am    Post subject: Reply with quote

Here's a DFSORT job that will display the FL values as integer values (note that you will lose the decimal places but this should be good enough for your purpose).

You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's FL display function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/


Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file
//SHOW DD SYSOUT=*
//TOOLIN   DD    *
  DISPLAY FROM(IN) LIST(SHOW) ON(2403,8,FL) PLUS
/*

_________________
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
shuko
Beginner


Joined: 08 Nov 2005
Posts: 73
Topics: 20

PostPosted: Fri Feb 02, 2007 12:49 pm    Post subject: Reply with quote

Thank you,once again Frank. Just perfect.
Back to top
View user's profile Send private message
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