Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

converting +ve to -ve and vice versa for non zero values
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Aug 03, 2007 11:12 am    Post subject: converting +ve to -ve and vice versa for non zero values
Reply with quote

Hi,

I need to convert the positve value in a field to negative value and vice versa for non zero values. when i used SIGNS, it is getting affected for zero values also. kindly help.
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Aug 03, 2007 2:44 pm    Post subject:
Reply with quote

Senthil,
Here is the step you wanted -

Code:
//SOMESTEP  EXEC PGM=SORT                             
//SYSOUT DD SYSOUT=*                                   
//SYSPRINT DD SYSOUT=*                                 
//SORTIN DD *                                         
-100                                                   
300                                                   
0                                                     
-1000                                                 
2000                                                   
/*                                                     
//SORTOUT DD SYSOUT=*                                 
//SYSIN DD *                                           
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=(1,5,SFF,NE,0),                   
        OVERLAY=(1,5,SFF,MUL,-1,LENGTH=5,M25))         
/*                                                     


OP

Code:
  100     
 -300     
0         
 1000     
-2000   


If necessary, change the mask M25 according to your requirement.
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Aug 03, 2007 3:28 pm    Post subject: Re: converting +ve to -ve and vice versa for non zero values
Reply with quote

Thanks. But is there any enhancement in SIGNS to do this?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Aug 03, 2007 8:09 pm    Post subject:
Reply with quote

Senthil,

It's not clear what you're trying to do since you didn't show your control statements or input values. But I suspect what you're looking for is DFSORT's NOSZERO option which will treat numeric zero values as unsigned (+0 and -0 are treated as +0). DFSORT's shipped default of SZERO treats numeric values as signed (+0 or -0).

Code:

   OPTION NOSZERO


If that's not what you need, then explain more clearly what you're trying to do and show your control statements, input values and expected output values.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Mon Nov 14, 2011 9:34 pm    Post subject: Reply to: converting +ve to -ve and vice versa for non zero
Reply with quote

I have oposite request. I have +0 or -0 in unknown position in the file ... I need to convert it to +0 value for all...
File in :
Code:
 ***************************** Top of Data ****************************
 rec1       {         }                                               
 988F0000000C000000000D444444444444444444444444444444444444444444444444
 9531000000000000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
 rec2                            ยต             ^                       
 988F4444444444444444444440000000A0000000000000B44444444444444444444444
 9532000000000000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
 rec3       \       0                                                 
 988F0000000E0000000F44444444444444444444444444444444444444444444444444
 9533000000000000000000000000000000000000000000000000000000000000000000


I was hoping I can do it with :
Code:
//S1   EXEC  PGM=SORT                           
//SYSOUT    DD  SYSOUT=*                       
//SORTIN DD  DISP=OLD,DSN=my dsn in             
//SORTOUT DD DISP=OLD,DSN=my dsn out           
//SYSIN    DD    *                             
  OPTION NOSZERO                               
  SORT FIELDS=COPY                             


but output file is the same as input ... with +0 & -0
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 14, 2011 9:50 pm    Post subject:
Reply with quote

Hello,

Quote:
I have +0 or -0 in unknown position in the file
Of course it is known - something created the file and "knew" where to place the values.

What makes a zoned-decimal number positive or negative is sign of the low order byte. To do this properly, the field length and position should be known. . .

Possibly there is something i misunderstand.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Mon Nov 14, 2011 10:00 pm    Post subject: Reply to: converting +ve to -ve and vice versa for non zero
Reply with quote

ok, let say that the file is mereged file from different sources ... each record has known position for 0, but this position is not the same for all records
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 14, 2011 10:04 pm    Post subject:
Reply with quote

Hello,

Quote:
let say that the file is mereged file from different sources
The data positions were still known. . .

If there are different format records, deal with them.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Mon Nov 14, 2011 10:07 pm    Post subject: Reply to: converting +ve to -ve and vice versa for non zero
Reply with quote

Quote:
To do this properly, the field length and position should be known. . .


is not always true ... if I know the length I can do the conversion in whatever position by:

Code:
 SORT FIELDS=COPY                                                 
 INREC FINDREP=(IN=X'0000000000000D',OUT=X'0000000000000C')       
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 10:12 pm    Post subject: Re: Reply to: converting +ve to -ve and vice versa for non z
Reply with quote

anatol wrote:
I was hoping I can do it with :
Code:
//S1   EXEC  PGM=SORT                           
//SYSOUT    DD  SYSOUT=*                       
//SORTIN DD  DISP=OLD,DSN=my dsn in             
//SORTOUT DD DISP=OLD,DSN=my dsn out           
//SYSIN    DD    *                             
  OPTION NOSZERO                               
  SORT FIELDS=COPY                             


but output file is the same as input ... with +0 & -0

IIRC, OPTION (NO)SZERO affects the way that signed zeroes are handled by DFSORT, but does not alter them. I think that you will have to actually replace, e.g., X'A0' with X'F0'.

(Incidentally, note that your original example has zoned decimal numbers, whereas your second example has packed decimal numbers, a non-trivial difference.)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 14, 2011 10:19 pm    Post subject:
Reply with quote

Hello,

Quote:
is not always true ... if I know the length I can do the conversion in whatever position by:
Huh icon_confused.gif

What does this provide? Nothing that i can tell - but again, i may be misreading something.

You also seem to have a moving (or not well-defined) target and this will make any "solution" suspect. There is no magic "do what i meant" function in the sort. . . You must provide the proper details.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Mon Nov 14, 2011 10:31 pm    Post subject: Reply to: converting +ve to -ve and vice versa for non zero
Reply with quote

ops... you are right... sorry - my fault...better to ask full requirement
I have to compare 2 files . For some reason it may represent 0 in different way ... +0 in one file and -0 in other... When I compare - I have a lot of differencies, but +0 should be = -0 in compare.... I was thinking about sort ... any other ideas?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 14, 2011 11:03 pm    Post subject:
Reply with quote

Hello,

Quote:
ops... you are right... sorry - my fault...better to ask full requirement
Sometimes it takes a few iterations, but eventually, we get there icon_smile.gif

Why do the files have different signs? If one file creation process or the other could be changed so that the same sign is generated, would this not solve your problem with no added processing steps?

If the files were "the same", SUPERC might be used for the compare.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 11:12 pm    Post subject: Re: Reply to: converting +ve to -ve and vice versa for non z
Reply with quote

anatol wrote:
ops... you are right... sorry - my fault...better to ask full requirement
I have to compare 2 files . For some reason it may represent 0 in different way ... +0 in one file and -0 in other... When I compare - I have a lot of differencies, but +0 should be = -0 in compare.... I was thinking about sort ... any other ideas?

Now that does sound like a job for OPTION NOSZERO. From the z/OS V1R12.0 DFSORT Application Programming Guide:
Quote:
NOSZERO
specifies that DFSORT should treat numeric zero values as unsigned. -0 and +0 are treated as the same value, that is, -0 and +0 are both treated as positive values. NOSZERO affects DFSORT processing of numeric values as follows:
  • For collation of SORT and MERGE fields, -0 collates equally with +0.
  • For comparisons of INCLUDE, OMIT and OUTFIL compare fields and constants, -0 compares as equal to +0.
  • For editing and conversions of INREC, OUTREC, and OUTFIL reformatting fields, decimal constants, and the results of arithmetic expressions, -0 and +0 are treated as positive.
  • For minimums and maximums of OUTFIL TRAILERx fields, -0 and +0 are treated as positive.

Note that, as I said above, the data will not be altered, but your sort functions will act as though they had been.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 14, 2011 11:19 pm    Post subject:
Reply with quote

Hello,

To exploit NOSZERO, do the individual fields have to be defined?

One of the goals (if i understood) was NOT to define the individual fields.

Hence, my suggestion to try to get one file or the other to conform to whichever sign . . . This would apply to zoned as well as packed decimal fields.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 11:25 pm    Post subject:
Reply with quote

dick scherrer wrote:
To exploit NOSZERO, do the individual fields have to be defined?

To the best of my understanding OPTION NOSZERO causes +0 = -0, regardless of where those signed zeroes are in the record.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Nov 15, 2011 12:08 am    Post subject:
Reply with quote

Hello,

Quote:
regardless of where those signed zeroes are in the record.
Provided that the fields (wherever they are located) are defined/referenced in some numeric operation - i suspect.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Nov 15, 2011 12:15 am    Post subject:
Reply with quote

When NOSZERO is in effect it applies to any and all fields covered by the NOSZERO option. You cannot specify SZERO for some fields and NOSZERO for other fields in a single run. The option in effect applies to all such fields for the run.

See "z/OS DFSORT Application Programming Guide" for details of the fields to which NOSZERO applies.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Nov 15, 2011 12:21 am    Post subject:
Reply with quote

Hi Frank, may I ask you my initial request ( Mon Nov 14, 2011 9:34 pm in this topic) or suggestion : I need to compare 2 files ... one of them may have +0, when second have -0 ...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Nov 15, 2011 12:33 am    Post subject: Reply to: converting +ve to -ve and vice versa for non zero
Reply with quote

Anatol,

Are the -ve zeros from the "old" program and non-matching +ve zeros from the "new" - in the sense that this is what the program has been changed for?

If not, you need to fix what is creating the -ve zeros.

I'd not be happy with blindly changing -ve zeros to +ve. I'd want to know that all the fields that should have changed have changed, and that other fields have not. Which means not getting around having to define the fields. Otherwise you run the risk of ignoring exactly the sort of thing your comparison is looking for, the unintended change.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us