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

Help in sort compare for Packed decimal


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Fri May 22, 2009 6:12 pm
Reply with quote

how to compare two comp3 field with dif length

Eg 9(5)v(3) and 9(4)v(4)

if the data is 90.000 and 9.0000 its coming as matchd record for comparison in sort using Include cond(1,5,pd,eq,6,5,pd)
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri May 22, 2009 6:33 pm
Reply with quote

Hi,

I can think of two step solution.

a) Bring both 9(5)v(3) and 9(4)v(4) to readable format of same length using the required EDIT MASK pattern of DFSORT. For ex, If your file LRECL is 80, Keep these readable format values from 81st position.
b) Then have your comparison based on these two values. While writing it in the output file, OUTREC to your original file length, which is 80 in this ex.

May be someone else or Frank can provide a simpler solution.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Fri May 22, 2009 6:36 pm
Reply with quote

thanks senjay, i tried the same..was hoping to get a simpler solution here
icon_smile.gif
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: Fri May 22, 2009 9:38 pm
Reply with quote

Hello,

Both fields have exactly the same value. . .

Keep in mind that the decimal points are implied, not actual. There is no "scaling" in a packed-decimal field - it is just some digits and a sign.

"Extra" work is needed to compare them.
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 May 22, 2009 10:03 pm
Reply with quote

Quote:
how to compare two comp3 field with dif length


It depends on what you want to do about the mismatch in the integer and decimal part. For example, I assume you would want 01234.123 to compare equal to 1234.1230 and 11234.123 to compare not equal to 01234.123, but would you want 01234.123 to compare equal to 1234.1231 or 1234.1239?

It's basically a matter of "normalizing" one number so it can be compared to the other number. You could use multiplication by 10 or division by 10 to do that, depending on how you want to do the comparisons.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Sat May 23, 2009 7:26 pm
Reply with quote

i want 01234.123 to compare equal to 1234.1231,, in Jcl can u help Frank?
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Sat May 23, 2009 7:26 pm
Reply with quote

also will inrec execue befor/after include?
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: Sun May 24, 2009 6:01 am
Reply with quote

Looking at my question again and your answer, I guess I wasn't clear enough. I still don't know if you want to truncate the last digit of the 4 decimal place number or round it up/down. So let me try again - answer all questions below:

1) Do you want 01234.123 to compare equal to 1234.1231?
2) Do you want 01234.123 to compare equal to 1234.1235?
3) Do you want 01234.123 to compare equal to 1234.1239?
4) Do you want 01234.124 to compare equal to 1234.1235?
5) Do you want 01234.124 to compare equal to 1234.1239?

Also, what is the RECFM and LRECL of your input file?

Quote:
also will inrec execue befor/after include?


An INCLUDE statement is executed before an INREC statement.
An INREC statement is executed before an OUTFIL statement which can have an INCLUDE operand.

See the following for DFSORT order of processing:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA30/FIGSTMTSEQ?SHELF=&DT=20080528171007&CASE=&ScrollTOP=FIGSTMTSEQ#FIGSTMTSEQ
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Sun May 24, 2009 2:07 pm
Reply with quote

frank i get u,.. i want to round off the second number and then compare..not truncate and compare..so 01234.124 shul not be = 1234.1235 and 01234.123 shuld be equal to 1234.1231.. also both the variable that i have are comp3 with sign


ur help is greatly appreciated
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: Mon May 25, 2009 6:28 am
Reply with quote

You didn't answer all of my questions as I asked you to. I don't know what you mean by "round off". Do you want 0.5 to be rounded up or down?

Again:

1) Do you want 01234.123 to compare equal to 1234.1231?
2) Do you want 01234.123 to compare equal to 1234.1235?
3) Do you want 01234.123 to compare equal to 1234.1239?
4) Do you want 01234.124 to compare equal to 1234.1235?
5) Do you want 01234.124 to compare equal to 1234.1239?

And since you say your values can be positive or negative:

6) Do you want -01234.123 to compare equal to -1234.1235?
7) Do you want -01234.124 to compare equal to -1234.1235?

Please answer all 7 questions so there won't be any ambiguity.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Mon May 25, 2009 1:24 pm
Reply with quote

Ok , i meant rounded up ie 0.56 is considered as 0.6

1) Do you want 01234.123 to compare equal to 1234.1231? EQUAL
2) Do you want 01234.123 to compare equal to 1234.1235? NOT EQUAL
3) Do you want 01234.123 to compare equal to 1234.1239? NOT EQUAL
4) Do you want 01234.124 to compare equal to 1234.1235? EQUAL
5) Do you want 01234.124 to compare equal to 1234.1239? EQUAL

And since you say your values can be positive or negative:

6) Do you want -01234.123 to compare equal to -1234.1235? NOT EQUAL
7) Do you want -01234.124 to compare equal to -1234.1235? EQUAL
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 May 26, 2009 10:56 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for. You never mentioned the RECFM and LRECL of your input file, so I assumed it's RECFM=FB and LRECL=80. The job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(6,5,PD,GE,+0),
    OVERLAY=(81:(6,5,PD,ADD,+5),DIV,+10,TO=PD,LENGTH=5)),
   IFTHEN=(WHEN=NONE,
    OVERLAY=(81:(6,5,PD,ADD,-5),DIV,+10,TO=PD,LENGTH=5))
  OUTFIL INCLUDE=(1,5,PD,EQ,81,5,PD),BUILD=(1,80)
/*
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed May 27, 2009 6:36 pm
Reply with quote

thnks frank
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top