3

I want to query the meta data in Cognos 8 to find all report and column names. If possible, I'd like to include the column definitions.

Can I do this using a Cognos report or do I need to query some repository?

Thanks.

jabs
  • 1,694
  • 4
  • 19
  • 36
  • I can't believe there is someone out there that even knows what Cognos is! I thought my company was the only one that used it. Anyway... You could look into "profiling". That should give you a sample of results as well as what data types you're looking for. – durbnpoisn Jun 20 '14 at 15:33
  • You're asking for a lot of different information. The report metadata is buried in the Content Store, and isn't easy to get out, although some googling will probably get you some queries. Column definitions, you may have to pull out of the individual FM models. – Andrew Jun 20 '14 at 15:42
  • @durbnpoisn - Yes, it's here and I got stuck (for the time being) with my department's share of it. Thanks for the tip on profiling. – jabs Jun 20 '14 at 15:51
  • @Andrew - This shouldn't be too difficult, but clearly it is. My cursory search didn't give me anything, but I'll look for Content Store searched. This explains why I can't find it in the Audit. – jabs Jun 20 '14 at 15:51
  • Cognos considers the content store schema as proprietary, obfuscates it and provides no documentation. They do have a SDK that exposes some things in the system and might help but you have to know Java to take advantage of it. Profiling maybe your only recourse but it will be tedious. – Johnsonium Jun 20 '14 at 18:17
  • 1
    @durbnpoisn Yes, we Cognos users do lurk here in the Stacks. A lot of application-specific questions are rejected here in stackoverflow, but SQL, Framework and Report questions are frequently addressed. BTW, Cognos is a leading Business Intelligence tool. A lot of companies use it for Reporting. Savvy companies are using it for Analytics. With Cognos Express, smaller shops are getting into Cognos now too. You are not in the minority. – Damienknight Jun 20 '14 at 21:21
  • 1
    Depending on your budget you might want to buy the tool from MotioPi http://www.motio.com/content/motiopi-cognos-administration-tools. Cognos, like _any other_ enterprise reporting tool often gets the finger of blame pointed at it, but it's not the tool it's business support behind it. Garbage in garbage out. – Nick.Mc May 09 '16 at 22:41

2 Answers2

9

You can select a list of reports from the content store with the following query:

SELECT     CMOBJNAMES_BASE.NAME AS ObjName, CMOBJECTS.PCMID, CMCLASSES.NAME AS ClassName, CMOBJPROPS7.spec
FROM       CMOBJECTS 
JOIN       CMOBJNAMES_BASE ON CMOBJECTS.CMID    = CMOBJNAMES_BASE.CMID
JOIN       CMCLASSES       ON CMOBJECTS.CLASSID = CMCLASSES.CLASSID
LEFT JOIN  CMOBJPROPS7     ON CMOBJECTS.CMID = CMOBJPROPS7.CMID
WHERE     CMOBJECTS.CLASSID IN (10, 37)
ORDER BY CMOBJECTS.PCMID;

I use that in Cognos 10. I believe in cognos 8 the CMOBJNAMES_BASE table is actually named 'CMOBJNAMES' without the _BASE.

UPDATE: Has been tested and works in Cognos 11r9.

The Report metadata is stored in the 'SPEC' column of CMOBJPROPS7 as XML. You can parse this XML in order to strip out the columns used in the report. It will not be a simple task.

If you have time but not money, you can write your own code to parse that XML. If you have more money than time, you can buy a 3rd party program to accomplish this, such as Motio or BSP Metamanager.

The query above is less useful for building a clean list of columns, but great for searching for specific data items. For example, you have column you are wanting to change in a data source, but you are not sure which report uses that column. Run the query above, and search for the data item. It will be embedded within the XML in the Cognos MDX format, ie. [Presentation View].[Sales Summary].[Sales]

EDIT: As requested below, here is a query that includes folder paths.

-- List of Reports, the folder they are in, and the package they are using
select distinct temp2.name as package,temp1.folder,temp1.name from
(SELECT    temp.PARENTNAME AS FOLDER,CMOBJECTS.PCMID,CMOBJNAMES.CMID, CMOBJNAMES.LOCALEID, CMOBJNAMES.MAPDLOCALEID, CMOBJNAMES.ISDEFAULT, CMOBJNAMES.NAME, 
                      CMOBJECTS.CLASSID
FROM         CMOBJNAMES INNER JOIN
                      CMOBJECTS ON CMOBJNAMES.CMID = CMOBJECTS.CMID
INNER JOIN
(SELECT P.CMID AS PARENT,P.NAME AS PARENTNAME FROM CMOBJNAMES P where P.LOCALEID between 24 and 52) temp
ON CMOBJECTS.PCMID = TEMP.PARENT
WHERE     (CMOBJECTS.CLASSID = 10)
AND SUBSTR(TEMP.PARENTNAME,1,1) NOT IN ('1','2','3','4','5','6','7','8','9') AND
TEMP.PARENTNAME NOT LIKE 'Backup%') temp1
inner join
(SELECT  CMREFNOORD1.CMID AS PID, CMREFNOORD1.REFCMID, CMOBJNAMES.NAME
FROM         CMREFNOORD1 INNER JOIN
                      CMOBJECTS ON CMREFNOORD1.REFCMID = CMOBJECTS.CMID INNER JOIN
                      CMOBJNAMES ON CMOBJECTS.CMID = CMOBJNAMES.CMID
WHERE     (CMREFNOORD1.PROPID = 31 AND CMOBJNAMES.LOCALEID between 24 and 52)) temp2
on temp1.cmid = temp2.pid and LOCALEID between 24 and 52;
Damienknight
  • 1,876
  • 2
  • 18
  • 34
  • I was looking for columns (labels) specifically so this query doesn't fully capture it - plus, I'm told we don't have the SDK which I understand to be necessary for access to the content store. Thanks anyway. +1 for the query. – jabs Jun 26 '14 at 20:41
  • SDK is not required to query the content store. The content store is either the DB2 database cognos creates on its own (eek, good for demos, not really intended for production) or more likely a database you have created yourself and pointed Cognos at. Use the login being used by Cognos to get to the content store, and you will have all the access you need. Check the metadata returned, it has data used to build the final web page, so it likely contains the labels you are looking for. – Damienknight Jun 27 '14 at 15:20
  • 1
    Thanks Damienknight, the query has helped already. However, I would like to know if there is a way to add a folder that the report name is contained in? For example, some users have created a folder, then a sub-folder, then saving the report. We've had some turnover and things aren't documented as well as they should be. I've needing to locate reports based on column headers in a previously saved Excel file that was generated from a report. Thanks ... – CWinKY May 09 '16 at 22:31
  • That's a great question. I went ahead and updated the answer to include a query I wrote which displays folder paths as well. – Damienknight May 11 '16 at 14:32
1

Not sure if this will help anybody, but our version doesn't have a table named CMOBJNAMES_BASE.

This is what works for me:

select ob2.cmid, c.name as classname, n.name as objectname, o.DELIVOPTIONS as deliveryoptions, z2.name as owner
from CMOBJPROPS2 p
inner join CMOBJPROPS26 o on p.cmid=o.cmid
inner join CMOBJECTS ob on ob.cmid=o.cmid
inner join CMOBJECTS ob2 on ob.pcmid=ob2.cmid
inner join CMOBJNAMES n on n.cmid=ob2.cmid
inner join CMCLASSES c on ob2.classid=c.classid
left join CMREFNOORD2 z1 on z1.cmid = p.cmid
left join CMOBJPROPS33 z2 on z2.CMID = z1.REFCMID
where ACTIVE = 1 order by z2.name, objectName
Michael Singer
  • 423
  • 5
  • 7
  • What version of Cognos are you on? I recently tested the script and it works in 11r9. I am guessing you are either in 11.1 or some version of cognos express? – Damienknight Sep 30 '19 at 23:16