MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syncsort Omit Records and Convert PD Date to Readble Format

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
gildan2020
Beginner


Joined: 07 Dec 2006
Posts: 17
Topics: 8

PostPosted: Thu May 07, 2015 5:50 am    Post subject: Syncsort Omit Records and Convert PD Date to Readble Format Reply with quote

Hi,

I have the following date field in packed decimal. The format is MMYY.

Input (assume it is in packed decimal)
Code:

1015
1214
1019
1215
0510
1217


How do I omit dates that are before May 2015 (0515)?
After that, I would like to convert it to zoned decimal.

Output (zoned decimal)
Code:

1015
1019
1215
1217


Can this be done in one sort step?

thanks.
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Thu May 07, 2015 6:59 am    Post subject: Reply with quote

You can use format PD0 to look at "parts" of a packed-decimal field. This format ignore the high-order and low-order four bits of a field.

So, for X'01015F' you can look at the last two bytes as PD0 and you've isolated the year, and the first two bytes of PD0 and you've isolated the month.

To use PD0 in an INCLUDE/OMIT COND= with a constant, you have to specify the constant in hexadecimal.

Code:

  OPTION COPY
  OMIT COND=(2,2,PD0,LT,X'15',   
            OR,
             1,2,PD0,LT,X'05')


The first "leg" gets rid of all old years, the second all months earlier than May.

This works with DFSORT, not sure about yours. If not, the easiest thing would be to use OUTFIL INCLUDE=/OMIT= on a ZD value you create in INREC.

Code:
  INREC BUILD=(1,3,PD,TO=ZD,LENGTH=4)


Or just use an EDIT.
Back to top
View user's profile Send private message
t-bonham@scc.net
Supermod


Joined: 18 Oct 2012
Posts: 30
Topics: 0
Location: Minneapolis, MN

PostPosted: Thu May 07, 2015 8:44 pm    Post subject: Reply with quote

Wow!

It's only been 15 years or so, and some designers have forgotten about the problems of storing years as a 2-digit field. The ability of some humans to fail to learn from experience is unlimited.
Back to top
View user's profile Send private message Send e-mail AIM Address
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Fri May 08, 2015 8:20 am    Post subject: Reply with quote

The shop I worked at in the late 80s was storing a year and month (YYMM) in a 2-byte binary field on one of its files. Better to bite the bullet now than have problems down the road. Smile
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Fri May 08, 2015 8:42 am    Post subject: Reply with quote

I'm less concerned about the two-digit year than I am about the foolishness of storing the month before the year. That way you can simply test for equal, but nothing else. Putting the year first, you can test for less than and greater than, as well as equal.

And yes, attention should be paid to the full year. Program can't possibly live that long to be a problem? If "cloned" regularly (and the clones then cloned in turn), it'll easily get to the next century... even if it's shed its original skin several times.
Back to top
View user's profile Send private message
t-bonham@scc.net
Supermod


Joined: 18 Oct 2012
Posts: 30
Topics: 0
Location: Minneapolis, MN

PostPosted: Fri May 08, 2015 6:02 pm    Post subject: Reply with quote

Also, they are taking twice as much space as needed -- wasting half of it.

You can easily store a MMDDYY date in just 2 bytes -- 4 bits for month, 5 bits for day, and year in the remaining 7 bits. I worked with a system that did this. Could probably find the couple dozen lines of COBOL code that decoded this into a real date -- mostly multiplies & divides by powers of 2 and moves. And this was part of the key for this ISAM tape file. But they really saved storage space on that date.

Of course, there was about 20 bytes of FILLER at the end of the record ...

That was an interesting system to maintain.
Back to top
View user's profile Send private message Send e-mail AIM Address
gildan2020
Beginner


Joined: 07 Dec 2006
Posts: 17
Topics: 8

PostPosted: Mon May 11, 2015 4:29 am    Post subject: Reply with quote

William Collins wrote:
You can use format PD0 to look at "parts" of a packed-decimal field. This format ignore the high-order and low-order four bits of a field.

So, for X'01015F' you can look at the last two bytes as PD0 and you've isolated the year, and the first two bytes of PD0 and you've isolated the month.

To use PD0 in an INCLUDE/OMIT COND= with a constant, you have to specify the constant in hexadecimal.

Code:

  OPTION COPY
  OMIT COND=(2,2,PD0,LT,X'15',   
            OR,
             1,2,PD0,LT,X'05')


The first "leg" gets rid of all old years, the second all months earlier than May.

This works with DFSORT, not sure about yours. If not, the easiest thing would be to use OUTFIL INCLUDE=/OMIT= on a ZD value you create in INREC.

Code:
  INREC BUILD=(1,3,PD,TO=ZD,LENGTH=4)


Or just use an EDIT.

sorry for the late response. i will test it out and let you know if any issues.
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Mon May 11, 2015 1:27 pm    Post subject: Reply with quote

Have you looked at the following?

CENTWIN=1956
45,02,Y2C
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group