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

Compare PD Values with same storage & diff decimal locat


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Shrinika Rajendran

New User


Joined: 06 Jun 2013
Posts: 25
Location: India

PostPosted: Wed Nov 05, 2014 3:17 pm
Reply with quote

Hi,
For comparing two PD vales that occupy same storage but having decimal point located at different places like below
Code:
01 WS-RECORD.                                   
  05 AMT1                 PIC S9(2)V9(2) COMP-3.
  05 AMT2                 PIC S9(3)V9(1) COMP-3.

Is it only possible to have it expanded using Edit mask and then compare like below?
Code:
SORT FIELDS=COPY                                           
INREC FIELDS=(1,3,PD,EDIT=(STT.TT),SIGNS=(+,-),LENGTH=6,   
              4,3,PD,EDIT=(STTT.T),SIGNS=(+,-),LENGTH=6)   
OUTFIL IFTHEN=(WHEN=(1,6,CH,EQ,7,6,CH),BUILD=(C'EQ',1,12)),
       IFTHEN=(WHEN=(1,6,CH,GT,7,6,CH),BUILD=(C'GT',1,12)),
       IFTHEN=(WHEN=(1,6,CH,LT,7,6,CH),BUILD=(C'LT',1,12)) 

Is this way better than having this done in COBOL?
Please let me know which is efficient for huge volume of data?

Thanks in advance.
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: Wed Nov 05, 2014 4:23 pm
Reply with quote

By "occupy the same storage" do you mean they're the same length, but different number of decimal digits?

You have records that just contain that data?

Have you tested those control cards to see that they get you what you want?

Also.
Back to top
View user's profile Send private message
Shrinika Rajendran

New User


Joined: 06 Jun 2013
Posts: 25
Location: India

PostPosted: Wed Nov 05, 2014 6:00 pm
Reply with quote

Bill,
Yes. Same length data. But different decimal digits.
I get what I want using the control card I have mentioned in my initial post.
I want to know if this is the efficient method of doing this.

Thanks
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: Wed Nov 05, 2014 6:59 pm
Reply with quote

I can't see how the comparison would work.

1230 in the first packed field should be the same as 0123 in the second.

Your EDIT will make that +12.30 and +012.3. Those are the same to the human eye, but when you just do a character compare, they are different.

Try with this, which inserts a 0 after the sign for the first EDIT and appends a zero after the second.

Code:
EDIT=(S0TT.TT),SIGNS=(+,-),LENGTH=7,
EDIT=(STTT.T),SIGNS=(+,-),LENGTH=6,C'0')


You should then see:

+012.30 and +012.30, which should compare as equal.

Or I've missed something.

Can you show some sample input and expected output?

As to performance, SORT IO is going to be faster than COBOL. You seem to want the output human-readable, so doing the edit and then compare is not going to be a bad way to do it. The other way involves "scaling" (multiply the one-decimal-place figure by 10) which, since you need the EDIT anyway, is going to be slower.

If you want to see the original style of EDIT for each field after the compare, just extend your BUILD so that it has 1,1,3,5,8,6 and you should get it.

It is easier for humans to read if you include spaces between the things :-)
Back to top
View user's profile Send private message
Shrinika Rajendran

New User


Joined: 06 Jun 2013
Posts: 25
Location: India

PostPosted: Wed Nov 05, 2014 9:17 pm
Reply with quote

I get about CH comparison. I was wrong about it.
Will padding zeros and make the character comparison work for GT and LT conditions?
I am not sure about this.
Code:
+000000400000000.000000000+000000000000500.000000000

In the case above,
Code:
OMIT=(1,26,CH,GE,27,26,CH)

is not working.
What should be the data type when comparing numeric edited fields?
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: Wed Nov 05, 2014 9:39 pm
Reply with quote

If the lengths (with padding) and alignment (on decimal point) are the same, there should be no problem with any character comparison you like.

I can't tell what is not working, as you haven't described what "works" would be, nor how that data fails to work. I don't know where you got that data from, and why it is different from the amendments I suggested to your original code, not why you want to OMIT at all, not what you want to do.

So you can see, you need to say in detail what you want, with sample input, expected output and output you are getting, along with control cards and RECFM/LRECL of files.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top