View previous topic :: View next topic
|
Author |
Message |
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
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 |
|
|
senjay
Active User
Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
thanks senjay, i tried the same..was hoping to get a simpler solution here
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
i want 01234.123 to compare equal to 1234.1231,, in Jcl can u help Frank? |
|
Back to top |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
also will inrec execue befor/after include? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
thnks frank |
|
Back to top |
|
|
|