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
 

 

Help in sort compare for Packed decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Help in sort compare for Packed decimal
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    Post subject: Reply to: Help in sort compare for Packed decimal
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    Post subject:
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

Site Director


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

PostPosted: Fri May 22, 2009 9:38 pm    Post subject:
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 Moderator


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

PostPosted: Fri May 22, 2009 10:03 pm    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

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

http://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    Post subject:
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 Moderator


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

PostPosted: Mon May 25, 2009 6:28 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue May 26, 2009 10:56 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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