View previous topic :: View next topic
|
Author |
Message |
bhavya_sha
New User
Joined: 16 Apr 2005 Posts: 33
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
One problem is whether there is a limit to the number of days per key.
What is the LRECL? |
|
Back to top |
|
|
bhavya_sha
New User
Joined: 16 Apr 2005 Posts: 33
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
|
boyti ko
New User
Joined: 03 Nov 2014 Posts: 78 Location: Malaysia
|
|
|
|
I tried, but failed. You can just use Cobol program to do it. Much easier imo. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
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 |
|
|
|