Focal Point
Report Caster - How to date stamp the file name of your email distributed files

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2431016882

June 20, 2008, 12:44 PM
trob
Report Caster - How to date stamp the file name of your email distributed files
Ok, well I searched the forums a while and searched the document lib but could not find any easy solutions for date stamping your email distributed files. I brainstormed a bit and this is the method I came up with. It's pretty clean and easy and requires little maintenance. There are other methods for ftp but I use email for distribution, however this should work for any type.

My methods was using MSSQL 2000 server as the 7.6.5 Report Caster repository. The db name is rcaster and user is iadmin.

Report Caster keeps its task info in the BOTTASK table and I will also use the BOTPARMS table to control which task to update.

I setup a stored procedure sp_datestamp_bottask on the MSSQL server in the rcaster database.

CREATE procedure dbo.sp_datestamp_bottask
as
UPDATE BOTTASK
SET ASVALUE = LOWER( convert(varchar, getdate(), 112) + '_' +SUBSTRING(BOTTASK.TASKOBJ , CHARINDEX('/', BOTTASK.TASKOBJ)+1 , 200 ) + '.' + BOTPARMS.PARAM_VALUE ) 
FROM BOTTASK JOIN BOTPARMS ON BOTTASK.TASKID = BOTPARMS.TASKID
WHERE BOTPARMS.PARAM_NAME LIKE 'datestamp';

commit
GO

This code is MSSQL syntax so it needs to be adjusted if your not using MSSQL for your repository.

The procedure joins BOTTASK and BOTPARMS by TASKID and updates ASVALUE (Save Report AsSmiler in BOTTASK where PARAM_NAME is like 'datestamp'. To select which records to update inside of caster I select the scheduled job -> task -> go into Advanced and add a parameter named 'datestamp' with the value of the file extension. I could not figure an easier way to control the file extension so I just us the value of the parameter. Your Save Report As changes to 20080620_car_report.xls, if you used xls as your datestamp parameter.

The update command will change the save report as name to the procedure name starting past the /. If your in deeper folders you will need to adjust this. It works great for my environment. So if you have a procedure named car_report in the rcaster application folder it would look like this rcaster/car_report. The update will strip off rcaster/ and use car_report as the file name, add the date as a prefix in YYMD format followed by an underscore and postfix .file extension (from parameter value). For MSSQL you can change the date format by changing the third parameter in convert().

From here you can run this several ways. I decided to create a .fex to run this procedure out of Reportcaster so I can handle it all from there. For MSSQL you can also just schedule the procedure to run on the server. You could also run it as a pre-processing procedure of any task.

Here is my procedure I schedule to run everyday at 12:01 in reportcaster.

-* File datestamp.fex

ENGINE SQLMSS SET CONNECTION_ATTRIBUTES rcaster tiawebfocus/iadmin,encryptedpassword

SQL SQLMSS EX dbo.sp_datestamp_bottask ;

-EXIT

This runs the procedure and updates my datestamps for the selected task every morning. You could easily add a timestamp if necessary, the Save Report As: (ASVALUE) field is varchar(64).

This message has been edited. Last edited by: trob,


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
June 20, 2008, 12:47 PM
trob
^^^^^

LOL Smiler

: ) I'm not going to fix it.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03