If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Rename Files using Cognos

Started by dsmuker, 27 Jan 2020 07:20:20 PM

Previous topic - Next topic

dsmuker

I am using Cognos Event studio to schedule reports to write output CSV files at file location. Apparently, the output file has suffix "en-gb". is it possible to rename the files using cognos.
for the moment i have created a Batch script to rename the files. Is there a way to run the batch script using cognos event studio?
I cannot use it using stored procedure as DBAs will not let me to export it to cognos.

Thanks
Gary

Francis aka khayman

research on CM.OUTPUTSCRIPT

not sure though if this feature is still in v11

dougp

CM.OUTPUTSCRIPT is in the documentation for CA11.  What I don't know is what Cognos wants for a path.  Does it want something like e:\foldername\script.bat, or file://\\servername\sharename\script.bat?  Are there examples available.  What I have found online in the last couple hours has been useless.

Francis aka khayman

its been a while since i've done this... your server is windows right? why don't you experiment first with a simple batch file?

for example copy x.txt y.txt
then try the each path see which one works?

i could experiment as well from my end but it will take time. i recon you will can get the answer before i can get back to you

dougp

Uhmm... Yeah...
I already have a script and I have set the value of the property.  The script isn't being called.  It's not a permissions problem.  As I stated, I don't see any examples of what, exactly, to enter for the value of the CM.OUTPUTSCRIPT variable.

Francis aka khayman

just curious... have you set the "save the report to file system" property to "yes"?

dougp

Yes.  Reports get saved to the location I expect.  The script just doesn't get called.

Penny

If the account running the scheduled report has its language preference set to en-gb, then shouldn't the prefix on the filename be removed?

Francis aka khayman

ok took me a while to find time to restart the server services and experiment on this.

i encountered the issue wherein files gets saved but batch file seems it did not run. batch file looks like this:

copy x.txt y.txt

then i changed it to explicit directory definition

copy c:\temp\x.txt c:\temp\y.txt

it worked.

dougp

Did it not run, or did it not work?
What happens if you change the file like this to make it start in the correct directory and perform logging?


@echo OFF
@rem --------------------------------------------------------------
@rem
@rem --------------------------------------------------------------
setlocal

@rem store the drive and path of this file in a variable
set dirname=%~dp0
@rem cd to the directory containing this file
pushd %dirname%

@rem do stuff
echo log entry 1 >> log.txt
copy x.txt y.txt


@rem cd back to where we started
popd


endlocal

Francis aka khayman

it did run for me.

why don't you try running a simple batch file first like i did?

dougp

You said it didn't run.

Quotei encountered the issue wherein files gets saved but batch file seems it did not run. batch file looks like this:

copy x.txt y.txt

Now you are saying it did run?  Which is it?

Francis aka khayman

Quote from: Francis aka khayman on 11 Feb 2020 08:29:39 AM
then i changed it to explicit directory definition

copy c:\temp\x.txt c:\temp\y.txt

it worked.

dougp

So when the bat file was

copy x.txt y.txt

did it not run or did it not work?

Francis aka khayman

#14
i would say it worked in the sense that the batch file ran.

it looked for the file x.txt but it did not find it in the folder where it was looking for. so no file was copied.

when the file location was explicitly stated, it was able to find the file and copy it.

dougp

Again, if it did nothing how do you know the bat file ran?  Were the additional lines in the bat file that performed logging?

Maybe there is a problem with my configuration:
QuoteCM.OUTPUTSCRIPT is in the documentation for CA11.  What I don't know is what Cognos wants for a path.  Does it want something like e:\foldername\script.bat, or file://\\servername\sharename\script.bat?  Are there examples available.  What I have found online in the last couple hours has been useless.

What did you enter for the value of CM.OUTPUTSCRIPT?

Francis aka khayman

Quote from: dougp on 13 Feb 2020 12:12:40 PM
Again, if it did nothing how do you know the bat file ran?  Were the additional lines in the bat file that performed logging?
because when i changed the batch file to explicitly specify the folder location, it ran fine.

Quote from: dougp on 13 Feb 2020 12:12:40 PM
Maybe there is a problem with my configuration:
What did you enter for the value of CM.OUTPUTSCRIPT?
e:\temp\a.bat    ;D 8)

dougp

Hmmm... That's what I'm using.

The documentation states that CM.OutPutLocation is mandatory if you want to save report output files in IBM Cognos software.  Did you enter that parameter?  Is it the same thing that appears in Cognos Configuration > Actions | Global Configuration > Archive Location File System Root?

Francis aka khayman

ok i think we are getting somewhere. i encountered this in the past...

there are now 2 ways of saving a report...

1. the old way is cm.outputlocation

2. the new way is defining a file output location in Dispatchers and Services.

when you use cm.outputscript, you have to use #1. cm.outputscript will not work if with #2

The value I defined in Archive Location File System Root is:

file:///temp

and yes it also works when i use way #2.




dougp

I'm confused.  Aren't #1 and #2 the same thing?

The documentation (https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cra.doc/t_asg_steps_setting_file_location.html) says to:
Open Admin Console
Configuration
Dispatchers and Services
{click on the dispatcher}
Content Manager Service > Properties
Settings
Advanced Settings > Edit...
Create a parameter named CM.OutPutLocation with a value that is the path to the directory (like e:\ReportOutput)
Create a parameter named CM.OutputScript with a value that is the path to the batch script (like e:\scripts\DoSomething.bat)

How do...
Cognos Configuration > Local Configuration > Environment > Data Access > Content Manager > Save report outputs to a file system?
...and...
Cognos Configuration > Actions | Global Configuration > Archive Location File System Root
...play into this?  Does having them set create a conflict with CM.OutputScript?

Are the parameter names case-sensitive?  Is the documentation correct?  (OutPutLocation or OutputLocation, OutputScript or OutPutScript)

Francis aka khayman

they are different. first way, this is the old one dating back to reportnet is to use cm.outputlocation and the documentation seems accurate.


the second way is to define the file System Location... you can do that using...

Ibm Cognos Administration > Configuration > Dispatchers and Services

at the upper right there are some icons... new folder, cut, paste,...etc third from the right is "Define File System Location"

you define a location and give it a name for example "Location 123"

then for example if you schedule a report to run... one of the Delivery options is to Save report as an external file...

Under that, you can find "Location 123" from the Location choices

dougp

Apparently, I've been using the second way.  It requires...
Cognos Configuration > Local Configuration > Environment > Data Access > Content Manager > Save report outputs to a file system? = True
...and...
Cognos Configuration > Actions | Global Configuration > Archive Location File System Root = file://\\servername\ReportOutput

Then I...
. create subfolders in ReportOutput
. go into "Define File System Location" and alias those folders and set permissions


So now I have added CM.OutPutLocation and CM.OutputScript to the Content Manager Service advanced settings, but they don't appear to do anything.


Is there a conflict?
Does this mean that if I want to run a script, I need to roll back those updates to Cognos Configuration, and I lose the ability to have subfolders with different write permissions?

Francis aka khayman

ok more info...

the second way is usually used in scheduling and running batches

the first way is when you run a report in the background and saved excel, html, etc is produced. you will get a saved html in run history as well as in the location you defined in CM.OUTPUTLOCATION. at the same time CM.OUTPUTSCRIPT is triggered when defined.

dougp

I have been running this way for years.  It works for schedules and agents, as well as Run as... | Run in background...

But...

Now I wonder about the quality of the documentation and the knowledge of the consultants that set up my Cognos environment.

Pages 77-79 of the IBM Cognos Analytics Version 11.0 Administration and Security Guide include information about this.

Saving report output files outside of IBM Cognos software
Report output files can be saved to a file system outside of IBM Cognos software. Users can choose which
output files to save.
  talks about Archive Location File System Root and creating the aliases by using Define File System Locations
  writes messy file names and provides no scripting options


Saving report output files in IBM Cognos Software
Users can save copies of report output files in IBM Cognos software. All report output files are saved to a
location specified in Content Manager.
  uses Save report outputs to a file system = true
  this mentions CM.OutPutLocation and CM.OutputScript


The two things appear to be unrelated.  The first allows reports that are scheduled or run in the background to be sent to a directory on the file system.  The second causes every saved "version" of a report to be also saved to the file system.  Apparently the only reason I have not been duplicating all of my saved reports is I did not have CM.OutPutLocation set.  (And I'm happy about that.  Running out of drive space is not fun.)  If that's true, it seems like I don't need Save report outputs to a file system = true.

Bummer.  I was hoping I could write a script to strip off the "_en_us" from all of the file names of my report outputs and delete all of the XML files.

Francis aka khayman

yup they are unrelated in the sense that they are independent of each other.

but it seems to me you can still write that script. you will just have to deal with duplicate saved reports. the easiest way is to include a delete in your batch file.