1827819 Members
3864 Online
109969 Solutions
New Discussion

SUbtracting in OpenVMS

 
SOLVED
Go to solution
Joseph Huber_1
Honored Contributor

Re: SUbtracting in OpenVMS

>>I need the file date and not the file create date ...
What is "the file date" in contrast to creation date ?
f$file(file,"CDT") creation date
f$file(file,"RDT") modification/revision date
http://www.mpp.mpg.de/~huber
abrsvc
Respected Contributor

Re: SUbtracting in OpenVMS

Having seen similar file naming conventions, I suspect that the filename is calculated/created and sometime thereafter the actual file is actually created on disk. Since the filename appears to have relevance to the application at hand, the asker can not rely on the creation date and must resort to the actual filname itself. That being said, I think that a variation on the alternative method I suggested might be a better way to approach this. Using the search capability of directory along with a time qualifier should make the list short enough to process easily. Depending upon the rename, adding an exclude qualifier ont he directory command may make the list even shorter.

The bottom line here is that a more detailed description of the ultimate goal is needed.

Dan
The Brit
Honored Contributor

Re: SUbtracting in OpenVMS

Try this,

$ Month="NULL,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,"
$ file_date = "20100527"
$ Yr = f$extr(0,4,File_Date)
$ Mth = f$extr(4,2,File_Date)
$ Mth = f$elem(Mth,",",Month)
$ Day = f$extr(6,2,file_date)
$ ADate = Day + "-" + Mth + "-" + Yr
$ show symb adate
ADATE = "27-MAY-2010"


Dave
Joseph Huber_1
Honored Contributor

Re: SUbtracting in OpenVMS

back to the original problem:
>>
I am writing a COM to rename a group of files which satisfy the below condition. The File name has the current date and time
Example: 20100919103344
If the difference between the current date (20100920) and the file date (20100919) is greater than 1, then i need to do certain steps.
<<

Use the the following command-file:

$! @this p1=filespecification of form yyyymmddhhmmss.ext
$!old date : more than 1 day before today
$ olddate=f$cvtim("yesterday-1-","COMPARISON","DATE")-"-"-"-"
$ filedate = f$extract(0,8,f$parse(p1,,,"NAME","SYNTAX_ONLY"))
$ if filedate.les.olddate
$ then
$ write sys$output "File ",p1," is older than 1 day."
$! do what has to be done with this file...
$! rename 'p1' [.destination] !or whatelse...
$ endif

And call it for each file in question as the argument:
@this 'filespec'

assuming 1 day difference of date wanted, not "older than 24 hours".
http://www.mpp.mpg.de/~huber

Re: SUbtracting in OpenVMS

Hi all,

Let me be clear with my question:

We have Jobs, which first create a TEMP File and write all the records into that. After the successful completion of the Job, the TEMP file will be renamed to the corresponding extension by the same job.

Example : abc_20100922033445.TR_TEMP (Starting of the Job)
will be renamed to
abc_20100922033445.TR (After Successful completion of the Job)

Due to various reasons, the job is failing everyday which is unavoidable. So, I have been given a task to rename the TEMP file to their corresponding extensions if they are more than 1 Day old.

The reason we check for the 1 day criteria is because, we should not rename a file which is being currently used by the Job.

The rename command is very straight forward and nothing complex.

example: $Ren /log [logical_name]abc_20100922033445.TR_TEMP [logical_name]abc_20100922033445.TR

I hope i am clear with my question. If you are not clear, please revert back to me.

----------------------------------
Hi Jan, i will check the CDT again. If that works fine , then i can use that.
Jan van den Ende
Honored Contributor

Re: SUbtracting in OpenVMS

CHANDRASEKARAN,

That looks promising!

A RENAME does not modify CDT (CreateDateTime), so you can simply use that.

I assume from our questions that you are more accustomed to the Unix-style of file date, where there is only ONE date, being the date of last "touch".
VMS file metadata holds multiple dates, of which CDT is one, and it looks like the one you need.

Good luck!

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Jan van den Ende
Honored Contributor

Re: SUbtracting in OpenVMS

CHANDRASEKARAN,

I looked again at your Example:

>>>
abc_20100922033445.TR_TEMP (Starting of the Job)
will be renamed to
abc_20100922033445.TR (After Successful completion of the Job)
<<<

Well, this may even be a one-liner:

$ RENAME *.TR_TEMP *.TR /BEFORE=TESTERDAY

I DO advice to include the directory spec in the command:

$ RENAME trlogdir:*.TR_TEMP *.TR /BEFORE=YESTERDAY

Lookup HELP LEXICAL F$CVTIME if you need finer time spec, eg /BEFORE=f$CVTIM("TODAY-30:0:0") --- everything before 18:00 the day before yesterday or
/BEFORE=f$CVTIM("-30:0:0") --- 30 hours before time of execution of the command

hth

Proost.

Have one on me.

jpe






abc_20100922033445.TR_TEMP
Don't rust yours pelled jacker to fine doll missed aches.

Re: SUbtracting in OpenVMS

Hi All,

I have used the below commands to achieve the renaming issue.

$ Month="NULL,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,"
$ file_date = "20100527"
$ Yr = f$extr(0,4,File_Date)
$ Mth = f$extr(4,2,File_Date)
$ Mth = f$elem(Mth,",",Month)
$ Day = f$extr(6,2,file_date)
$ ADate = Day + "-" + Mth + "-" + Yr
$ show symb adate
ADATE = "27-MAY-2010"

the comment from DBA is that, i am using the above code repetitively..

The suggestion from my DBA is that they want me to use subroutines.

he also said "subroutines can be made to act like functions by using global symbols which you initialize just before calling the routine."


can someone help in how to create a subroutine.

Thanks....
Steven Schweda
Honored Contributor

Re: SUbtracting in OpenVMS

> can someone help in how to create a
> subroutine.

Help? You want help? Have you tried HELP?

help subroutine
help call

help gosub
help return

Re: SUbtracting in OpenVMS

Thanks a lot.....
i found the help and it solved my issue....