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

Finding out consecutive date entries & count in file


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

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Fri Nov 20, 2015 3:24 pm
Reply with quote

I have a file with fixed RECL as below.

File has person's travel history with person code,name,place and date.

If employee's travel plan was for 3 days file has 3 entries with consecutive dates as below.

P.NO Name ST Date
0001 bms1 ny 10/12/2015
0001 bms1 ny 12/12/2015
0001 bms1 nz 11/11/2015
0001 bms1 nz 11/12/2015
0002 bms2 az 11/10/2015
0002 bms2 az 11/11/2015
0002 bms2 az 11/12/2015


Requirement is to create file having 1 entry (instead of 3 as in input file) with details of start date and end date along with number of days in that place as below.

P.NO Name ST StartDate EndDate total days
0001 bms1 ny 10/12/2015 10/12/2015 1
0001 bms1 ny 12/12/2015 12/12/2015 1
0001 bms1 nz 11/11/2015 11/12/2015 2
0001 bms2 az 11/10/2015 11/12/2015 3

Have COBOL solution but was thinking of trying out using SORT too.
Any suggestions/guidance is of great help.

Thanks & Regards
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Nov 20, 2015 7:18 pm
Reply with quote

I think, you can do by WHEN=GROUP , KEYBEGIN, build and DATEDIFF.
Can you please explain why you have these two entries?
Code:
0001 bms1 ny 10/12/2015 10/12/2015 1
0001 bms1 ny 12/12/2015 12/12/2015 1
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Nov 20, 2015 8:49 pm
Reply with quote

Because those are 2 one-night stays - not consecutive nights.
(10 years on the forum and the OP still has not learned how to use the code tags! Shame on him/her.)
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Nov 20, 2015 9:45 pm
Reply with quote

You need logic more than the technique to achieve what you want.

Have a look at this: http://ibmmainframes.com/viewtopic.php?t=64423&highlight=

.
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: Fri Nov 20, 2015 10:09 pm
Reply with quote

One problem is whether there is a limit to the number of days per key.

What is the LRECL?
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Mon Nov 23, 2015 2:19 pm
Reply with quote

Nic Clouston wrote:
Because those are 2 one-night stays - not consecutive nights.
(10 years on the forum and the OP still has not learned how to use the code tags! Shame on him/her.)


Of course 10 years in the forum but i posted only 10/20 times in the forum (I've not used this recently), but I refrained my self from posting any query here rather found out my self referring books/websites , you know why whenever i open your forum i can see only comments targeting for asking questions saying silly...etc..I do understand why is this happening :(...Please be aware you could be the Master as Moderator but we may not get that good exposure and time with work we get .

We come back to you with questions because we trust you as a guide/guru who is much more knowledgeable than us.

Anyways thank you all for help.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Nov 23, 2015 4:48 pm
Reply with quote

To get the est from a forum one should visit it regularly to see what is being posted. One never knows what one will learn. As a non-CICS person I know quite a bit about CICS (and other things) because I read everything posted daily, often several times a day.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Nov 23, 2015 8:27 pm
Reply with quote

Don't take it personally on type or levels of questions you ask as that has nothing to do with this here.
Quote:
Please be aware you could be the Master as Moderator but we may not get that good exposure and time with work we get .

I don't disagree fully but that is not the point, Please follow the code tags simple and I am sure you would also do the same when somewhere you become the moderator.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon Nov 23, 2015 9:07 pm
Reply with quote

There's a lot of things that could be said but to be relevant it would have been much better if you had replied to Bill's question

AND 'just in case', If you have already solved it then it's worth posting the solution for the benefits of others.

.
Back to top
View user's profile Send private message
boyti ko

New User


Joined: 03 Nov 2014
Posts: 78
Location: Malaysia

PostPosted: Tue Nov 24, 2015 10:15 am
Reply with quote

I tried, but failed. You can just use Cobol program to do it. Much easier imo.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Nov 25, 2015 1:10 am
Reply with quote

Tricky one, I spent sometime and could able to do it for 2 consecutive records but for 3 or more it is complicated and hence I think Bill raised the concerned already. But "Yes" programmatic approach is easy for now to write and after to prolong for someone else than maintaining a complex SORT card where we know the requirements are changing dynamically.
Something like
Code:
Step1- Use a KEYBEGIN to GROUP them and push the date and add seq #
Step 2- Use DATEDIFF with current and pushed one ( result will be 1 or other value)
step 3- condition ( seq # in step1 = 2 and datediff in step2 = 1) build  record by adding '2' suffixed
step 4- when other build with suffixed '1'
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 split large record length file... DFSORT/ICETOOL 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top