Author Topic: Rename Files using Cognos  (Read 701 times)

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #15 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?

Maybe there is a problem with my configuration:
Quote
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.

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

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #16 on: 13 Feb 2020 12:38:46 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.

Maybe there is a problem with my configuration:
What did you enter for the value of CM.OUTPUTSCRIPT?
e:\temp\a.bat    ;D 8)

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #17 on: 13 Feb 2020 02:12:57 pm »
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?

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #18 on: 13 Feb 2020 02:30:04 pm »
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.




Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #19 on: 13 Feb 2020 02:57:11 pm »
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)

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #20 on: 13 Feb 2020 03:20:05 pm »
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

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #21 on: 13 Feb 2020 03:39:48 pm »
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?

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #22 on: 13 Feb 2020 03:50:31 pm »
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.

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #23 on: 13 Feb 2020 04:38:38 pm »
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.

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #24 on: 14 Feb 2020 07:32:09 am »
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.

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #25 on: Today at 10:17:17 am »
Nope.  The script gets called when a copy of a report output (version) are created on the file system.  It does not run when the report is sent to the file system using Run as... or a schedule and the option "Save report as external file" is used (and output is not saved as a version).

Offline Francis aka khayman

  • Statesman
  • ******
  • Join Date: Jun 2009
  • Posts: 534
  • Forum Citizenship: +26/-4
    • CognosM
Re: Rename Files using Cognos
« Reply #26 on: Today at 11:06:36 am »
i haven't tested but if you schedule the report you can select 2 kinds of deliveries: Save report as external file and save report.

i could be wrong here but i think if you select both, it will save the report 2x as well as run the script. through the script you can then rename the file created in save report as external file provided the output folder is fixed, then delete the duplicate files.

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 489
  • Forum Citizenship: +21/-1
Re: Rename Files using Cognos
« Reply #27 on: Today at 03:35:17 pm »
I think I finally understand how this works.  It seems less configurable, but the script picks up the rest of the configuration...

My current way (using Archive Location File System Root):
  • Within the Archive Location File System Root, a folder is created for a user or business unit to write to.  This is usually a junction pointing to their folder on the network.  (like a shared folder or a web site folder)
  • In Define File System Locations, I configure an alias to the folder and apply permissions for certain users, groups, or roles to use (write to) that alias.
  • Users schedule or use "run as" to get their reports to run and write output to their location.

To replicate the functionality using CM.OutPutLocation and CM.OutputScript:
  • For the folder or report in Cognos, apply permissions for certain users, groups, or roles to create versions.  (write or full permission?)
  • Users schedule or use "run as" to save their report output as a version of the report.
  • Cognos saves a copy to the folder defined in CM.OutPutLocation.
  • The script defined in CM.OutputScript runs.  This script can:
    • Identify which file was just created.
    • Read the description (xml) file to determine the report path.
    • If the report path matches a specific pattern or value, do something (like copy it to the subfolder/junction and rename it to something meaningful like the report name).
    • Delete the original output file.


So the second option seems like more coding, but far more flexible.  It must be a .bat file, but that can call anything (PowerShell, Windows Scripting Host, executable) to do the actual work, so batch programming isn't even needed.

Both would not be needed.  If I implement CM.Output*, I'll probably clear the Archive Location File System Root box so that "Save report as an external file" disappears from the list of delivery options.

Thanks for sticking with me, Francis.  This was very helpful.

 


       
Twittear