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

How to OMIT Records older than the current date


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

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Thu Jan 27, 2022 12:58 pm
Reply with quote

Hello together,
I have the following problem.

During the processing of a file, all records older than the current date - 1 year should be omitted.

The date in the record for comparison is packed (PD) and has the following structure: 0(n)YYDDD
n = 0 = 19 century
n = 1 = 20 century

Data example
Code:

.p.§
0907
073C
----
.r..
0930
090C
----
....
0012
160C
----
...§
0137
112C
----
.q..
0923
082C
----
...<
0004
117C
----
...%
0006
102C
...%
0236
115C
----
...*
0035
103C
----
....
0012
181C
----
....
0121
177C
----
....
0000
102C
----
.r..
0933
092C
----
...<
0124
198C
----


What options do I have to skip the unnecessary records.

I am very interested to see how the solution looks like.

Thanks a lot for the support.

Greetings / Regards
kregen
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 907
Location: Bamberg, Germany

PostPosted: Thu Jan 27, 2022 7:20 pm
Reply with quote

Look up the following in the manual:
Code:
DATE3P-d

you will need to adjust the length of the input field to match the format of DATE3P, then you can easily compare with what's requested.

Let's see what you have tried so far as well, please.
Back to top
View user's profile Send private message
kregen

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Thu Jan 27, 2022 9:12 pm
Reply with quote

HelloJerg,
if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.

how can i convert the input 0(n)YYDDD to YYYYDDD in DFSORT?

Code:
 in other language i use: Field + 1900000 = YYYYDDD


is this possible with DFSORT?

regards
kregen
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Thu Jan 27, 2022 10:58 pm
Reply with quote

kregen wrote:
HelloJerg,
if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.

how can i convert the input 0(n)YYDDD to YYYYDDD in DFSORT?

Code:
 in other language i use: Field + 1900000 = YYYYDDD


is this possible with DFSORT?

regards
kregen

How do you plan to deal with the dates of XXI century? icon_exclaim.gif

Please, read any SORT manual about:
- CENTWIN parameter
- date conversion parameters - Y2P, Y2T, Y2W, ... (+50 more)
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Fri Jan 28, 2022 12:22 am
Reply with quote

FYI:
In SORT the arithmetics with packed decimal are performed (if the field is a correct packed decimal value of four bytes) in the following manner:

Suppose your date is stored in the field as X'00yydddC' = +yyddd
Code:
 ...pos,4,PD,ADD,+1900000,LENGTH=4,...
The result would be X'19yydddC', or X'2yyydddC'

Subtraction of one year can be done as follows:
Code:
 ...pos,4,PD,SUB,+1000,LENGTH=4,...
But you must take care of leap year's changed day numbers yourself!

Everything about arithmetic operations is described in details in any SORT manual. It would be a good idea to refer to it.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Fri Jan 28, 2022 3:08 am
Reply with quote

I forgot one important parameter in both cases, to get result in packed decimal as well:
Code:
 ...pos,4,PD,ADD,+1900000,TO=PD,LENGTH=4,...

Code:
 ...pos,4,PD,SUB,+1000,TO=PD,LENGTH=4,...
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Fri Jan 28, 2022 3:54 am
Reply with quote

kregen wrote:
if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.


A sort of a smart alec question...

Code:
 INREC OVERLAY=(81:1,4,PD,ADD,+1900000,TO=PD,LENGTH=4)
 SORT FIELDS=COPY
 OUTFIL OMIT=(81,4,PD,LT,&DATE3P-365),
        BUILD=(1,80)
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 907
Location: Bamberg, Germany

PostPosted: Sun Jan 30, 2022 10:50 pm
Reply with quote

sergeyken wrote:
Code:
 INREC OVERLAY=(81:1,4,PD,ADD,+1900000,TO=PD,LENGTH=4)
 SORT FIELDS=COPY
 OUTFIL OMIT=(81,4,PD,LT,&DATE3P-365),
        BUILD=(1,80)

Kind of this was my first attempt, however your replies made me look up the manual (again). Request can be fulfilled a bit more simple, but basically I would like to see at least one attempt to solve the issue by the TS first.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Mon Jan 31, 2022 12:37 am
Reply with quote

Arithmetic conversion of the non-standard date value, and date comparison with any current-date function need to be done separately in two different statements (or IFTHEN= which is the same). This is the major limitation of SORT, other updates are less important.
Back to top
View user's profile Send private message
kregen

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Mon Jan 31, 2022 12:38 pm
Reply with quote

hello together,
thanks to all for the good support.

Regards
Kai
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 907
Location: Bamberg, Germany

PostPosted: Mon Jan 31, 2022 1:58 pm
Reply with quote

Please show what you have tried. I do have two more updates for this case to discuss.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Mon Jan 31, 2022 7:33 pm
Reply with quote

The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility.

Any date value calculated from the current &DATExxx in SORT has one of standard formats, such as X'yyyydddC'

Those two cannot be compared, like "oranges to apples".
Arithmetic is needed (as PD format),
either X'0cyydddC'+1900000
or X'yyyydddC'-1900000

Arithmetic operation cannot be incorporated neither into INCLUDE/OMIT condition, nor into SYMNAMES dictionary; a separate statement is needed, with extra intermediate field.

So, I did not find a more simple solution, though the order of operations can be changed.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 907
Location: Bamberg, Germany

PostPosted: Mon Jan 31, 2022 9:07 pm
Reply with quote

sergeyken wrote:
The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility.

One of your statements made me look up the manual, and there is the following:
Code:
Y'DATE3'-365
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Mon Jan 31, 2022 9:38 pm
Reply with quote

Joerg.Findeisen wrote:
sergeyken wrote:
The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility.

One of your statements made me look up the manual, and there is the following:
Code:
Y'DATE3'-365

It produces C'YYDDD' - cannot compare to P'0cyydddC' ... icon_rolleyes.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 907
Location: Bamberg, Germany

PostPosted: Thu Feb 03, 2022 12:41 pm
Reply with quote

sergeyken wrote:
It produces C'YYDDD' - cannot compare to P'0cyydddC' ... icon_rolleyes.gif

Basically you can, look up Table 29. Permissible Comparisons for Dates in the Manual.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Thu Feb 03, 2022 6:23 pm
Reply with quote

Joerg.Findeisen wrote:
sergeyken wrote:
It produces C'YYDDD' - cannot compare to P'0cyydddC' ... icon_rolleyes.gif

Basically you can, look up Table 29. Permissible Comparisons for Dates in the Manual.
Again: the date format P'cyyddd' = X'0cyydddC' is a proprietary one.
None of standard date operations, including date comparison, is applicable to this non-standard value, without its preliminary conversion.
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 how to keep unpaired records with REPRO. JCL & VSAM 9
No new posts Dataset size increase on adding 1 byt... DFSORT/ICETOOL 8
No new posts SMF Record Date conversion failing CLIST & REXX 1
No new posts Removal of date value records DFSORT/ICETOOL 12
No new posts Concurrent writing records to VSAM fr... JCL & VSAM 9
Search our Forums:

Back to Top