IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

converting +ve to -ve and vice versa for non zero values


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1436
Location: Bangalore,India

PostPosted: Fri Aug 03, 2007 2:44 pm
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
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 Developer


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

PostPosted: Fri Aug 03, 2007 8:09 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Mon Nov 14, 2011 9:34 pm
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

Moderator Emeritus


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

PostPosted: Mon Nov 14, 2011 9:50 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Mon Nov 14, 2011 10:00 pm
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

Moderator Emeritus


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

PostPosted: Mon Nov 14, 2011 10:04 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Mon Nov 14, 2011 10:07 pm
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: 1788
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 10:12 pm
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

Moderator Emeritus


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

PostPosted: Mon Nov 14, 2011 10:19 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Mon Nov 14, 2011 10:31 pm
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

Moderator Emeritus


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

PostPosted: Mon Nov 14, 2011 11:03 pm
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: 1788
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 11:12 pm
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

Moderator Emeritus


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

PostPosted: Mon Nov 14, 2011 11:19 pm
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: 1788
Location: Bloomington, IL

PostPosted: Mon Nov 14, 2011 11:25 pm
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

Moderator Emeritus


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

PostPosted: Tue Nov 15, 2011 12:08 am
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 Developer


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

PostPosted: Tue Nov 15, 2011 12:15 am
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Nov 15, 2011 12:21 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 15, 2011 12:33 am
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
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

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

just play around with something like

input

Code:
 ****** ***************************** Top of Data ******************************
 000001                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000C0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 000002                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000D0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 000003                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000F0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 ****** **************************** Bottom of Data ****************************


jcl1
Code:
 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB NOTIFY=&SYSUID,                                         
 000002 //             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H                       
 000003 //*                                                                     
 000004 //ICE     EXEC PGM=SORT                                                 
 000005 //SYSOUT    DD SYSOUT=*                                                 
 000006 //SYSPRINT  DD SYSOUT=*                                                 
 000007 //SORTIN    DD DISP=SHR,DSN=ENRICO.TEST.PS1                             
 000008 //SORTOUT   DD DISP=SHR,DSN=ENRICO.TEST.PS2                             
 000009 //SYSIN     DD *                                                       
 000010   OPTION NOSZERO                                                       
 000011   SORT FIELDS=COPY                                                     
 000012   INCLUDE COND=(1,4,PD,EQ,5,4,PD)                                       
 000013 //                                                                     
 ****** **************************** Bottom of Data ****************************


result
Code:
 ****** ***************************** Top of Data ******************************
 000001                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000C0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 000002                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000D0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 000003                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000F0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 ****** **************************** Bottom of Data ****************************


jcl2
Code:
 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB NOTIFY=&SYSUID,                                         
 000002 //             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H                       
 000003 //*                                                                     
 000004 //ICE     EXEC PGM=SORT                                                 
 000005 //SYSOUT    DD SYSOUT=*                                                 
 000006 //SYSPRINT  DD SYSOUT=*                                                 
 000007 //SORTIN    DD DISP=SHR,DSN=ENRICO.TEST.PS1                             
 000008 //SORTOUT   DD DISP=SHR,DSN=ENRICO.TEST.PS2                             
 000009 //SYSIN     DD *                                                       
 000010   SORT FIELDS=COPY                                                     
 000011   INCLUDE COND=(1,4,PD,EQ,5,4,PD)                                       
 000012 //                                                                     
 ****** **************************** Bottom of Data ****************************

result
Code:
  ****** ***************************** Top of Data ******************************
 000001                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000C0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 000002                                                                         
        000000004444444444444444444444444444444444444444444444444444444444444444
        000C000F0000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
 ****** **************************** Bottom of Data ****************************


the test seems simple enough to understand the NOSZERO vs. the SZERO behavior
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

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

yes, you are right... the 2 files created for test Enterprize PLI migration... one created by PLI MVS, other EPLI ... the logic is the same, the result is : +0 -0 differencies
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

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

Thank you , enrico-sorichetti ... I knew that... but was hope that I can convert -0 to +0 in whatever position.... sorry, guys... I think we should close the discussion - thank you all
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

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

Just to confirm, then, the original is the PL/I MVS with -ve zeros, and the +ve zeros are the Enterprise PL/I?

And you already checked the changes section of the manual or the migration guide to know why this is happening, I assume.

If so, maybe give it a shot with the FINDREP you have, just to get the comparison going to check for any other differences between the datasets.

I'd still prefer to do it field-by-field after that, but that's me :-)

EDIT: Sorry, I was till typing before seeing you closing it down :-)

I don't understand the 'vice versa' or your subject that I've just noticed. That would be wrong, I think. As I undertsand it, results of some calcuations in PL/1 (like Cobol) will no longer produce -ve zero, but instead only +ve zero. It should not be the case (I am open to correction from PL/I people) that -ve zero can be produced in different circumstances than previously.

EDIT2: I've just realised after following Frank's message below that you actually "tailgated" an old topic instead of starting a new one. You were not responsible for the subject, so ignore most of the first EDIT.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

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

anatol,

With all the "comments", I've lost track of what your question is.

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...


The only possibility for changing something in an unknown position is to use FINDREP, e.g. change X'D0' to X'C0' in any byte. But that will only work if the character you're changing is ONLY used for -0 and NOT for anything else. Otherwise, you need to know the position of the field in order to convert it.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting fixed length file to excel... IBM Tools 7
Search our Forums:

Back to Top