Increment Date on a Sequential File.
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 31
- Joined: Mon May 11, 2015 3:20 am
- Location: Robinsons Cybergate Tower 2
- Contact:
Increment Date on a Sequential File.
Hi,
I have a sequential file which contains a date
20150812
We read it on a sequence job using execute command and pass it on to a user variable activity then to our sequence job so that our job can get its value.
My question is it is possible to increment this date and taking to account valid dates, example leap years, 30th and 31st of the month, etc., after every successful run of the job.
Advanced Thank you.
I have a sequential file which contains a date
20150812
We read it on a sequence job using execute command and pass it on to a user variable activity then to our sequence job so that our job can get its value.
My question is it is possible to increment this date and taking to account valid dates, example leap years, 30th and 31st of the month, etc., after every successful run of the job.
Advanced Thank you.
BOG
Control file can be overwritten in a subsequent job.
On successful completion of main job/sequence ... execute a successor job to trap 'user variable' mentioned in your post, convert string from YYYYMMDD to Date format, increment date by 1 (see DateOffsetByDays function) and then convert it back to YYYYMMDD and overwrite the control file.
However it will be a better and more robust approach to park control records in a database (rather than a sequential file) and extract them as and when needed.
On successful completion of main job/sequence ... execute a successor job to trap 'user variable' mentioned in your post, convert string from YYYYMMDD to Date format, increment date by 1 (see DateOffsetByDays function) and then convert it back to YYYYMMDD and overwrite the control file.
However it will be a better and more robust approach to park control records in a database (rather than a sequential file) and extract them as and when needed.
Kel, I don't think we know enough to help you here. It comes down to what the date represents.
How is it being used? Is it a stand-in for the process date, is it the date of the last run, or is it just a check mark on a calendar?
Or something I'm missing, perhaps?
We use a process date in every cycle. Our cycle spans midnight, so sometimes we store the date in a file (control card) and use it instead of querying the current or system date. In a couple of cases it represents the last run date, and since we are business oriented it must be a business day, not a holiday or weekend day.
How is it being used? Is it a stand-in for the process date, is it the date of the last run, or is it just a check mark on a calendar?
Or something I'm missing, perhaps?
We use a process date in every cycle. Our cycle spans midnight, so sometimes we store the date in a file (control card) and use it instead of querying the current or system date. In a couple of cases it represents the last run date, and since we are business oriented it must be a business day, not a holiday or weekend day.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
That would require a Parallel job just to read and increment a date in what I assume is a one record sequential file, seems a bit overkill to me. Better IMHO to write a custom routine and leverage it in the / a sequence or even after job. Date manipulation in BASIC is pretty straight forward but if you don't want to roll up your own, Ray does have a set of "Date Math" routines you can freely download from his site. Or at least he did...rkashyap wrote:On successful completion of main job/sequence ... execute a successor job to trap 'user variable' mentioned in your post, convert string from YYYYMMDD to Date format, increment date by 1 (see DateOffsetByDays function) and then convert it back to YYYYMMDD and overwrite the control file.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
That's a good answer. I would suggest the next question: what is the significance of the date? What does it mean in the file name?Kel wrote:We use the date on that control file as an extension to names of text files that we are going to extract.
For Example,
/path/filenameyyyymmdd.TXT
where yyyymmdd is the date from control file.
You can establish a date in other ways besides storing it in the file. I don't mean that your requirement may be questionable, but if you answer the "why" you might find simpler ways to use that date.
For example, I use the process date in file names also, mainly to keep them unique from one cycle to the next. I don't need to keep the date in a file, I just establish it (cycle date, for example) at the beginning of the cycle and propagate it to every job.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
-
- Participant
- Posts: 31
- Joined: Mon May 11, 2015 3:20 am
- Location: Robinsons Cybergate Tower 2
- Contact:
Hi chullet,
Can you give me the link of the site for the "Date Math" Routines by ray so I can browse it.
Hi FranklinE,
I will have to confirm this, but my understanding is that we use this date to keep track on changes of the file.
For example:
On the FTP Server, The File is named, file.txt
Then we extract it to a sequential file as fileyyyymmdd.txt
Then we use this sequential file to other jobs.
But lets say that a row was removed on file.txt the next day.
Then on extraction from FTP to Sequential File, the file name will be
fileyyyymmdd+1.txt
-so basically what I think is the dates are used to keep track on the changes on the sequential file.
:EDIT, my explanation is so unclear. Peace.
Can you give me the link of the site for the "Date Math" Routines by ray so I can browse it.
Hi FranklinE,
I will have to confirm this, but my understanding is that we use this date to keep track on changes of the file.
For example:
On the FTP Server, The File is named, file.txt
Then we extract it to a sequential file as fileyyyymmdd.txt
Then we use this sequential file to other jobs.
But lets say that a row was removed on file.txt the next day.
Then on extraction from FTP to Sequential File, the file name will be
fileyyyymmdd+1.txt
-so basically what I think is the dates are used to keep track on the changes on the sequential file.
:EDIT, my explanation is so unclear. Peace.
BOG
'User variable activity' can be passed to the 'new' job via job-parameters.Kel wrote:We read it on a sequence job using execute command and pass it on to a user variable activity then to our sequence job so that our job can get its value.
Though as noted, a custom Server(i.e. Basic) routine would be better suited for this task ... faster to code, compile and execute than a parallel job for a single record manipulation. For small data volumes, or for utility functions, Basic routines and server jobs usually finish before initial housekeeping of a parallel job is done.
BTW ... if this helps, code of a Basic routine to increment date is:
Code: Select all
Ans=Trim(Oconv(Iconv([i]IN_YYYYMMDD[/i],"DYMD[4,2,2]")+[i]IN_DAYS2OFFSET[/i],"D YMD[4,2,2]"),' ','A')
Return Ans
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: