Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to list the active Alerts used within a tab(report) within a Document

Hello

We have a number of tabs/reports within a single webi document. There are a couple of alerts within the webi document but only one is used within a given tab/report.

Is there an API around that will help me query the alerts that are enabled within each tab/report within a given document instance?

There is an IReportProcessingInfo class that is around for it looks like its not applicable for Webi documents.

Regards

Madhu

BO XI R2 SP2 on Windows 2003

Former Member
replied

Hi Madhu,

Below is a sample code to traverse through the ReportStructure and get the Alerters from the cells.

Hope this helps.

Regards,

Dan

Main:

            /************************** RETRIEVING PARAMETERS **************************/

            // Retrieve the logon information
            String username = "username";
            String password = "password";
            String cmsName  = "cms name";
            String authType = "secEnterprise";  
     
            // Retrieve the name of the Web Intelligence document to be used in the sample
            String webiDocName = "WebI Alerter Test";

            /************************** LOGON TO THE ENTERPRISE **************************/

            // Logon to the enterprise
            IEnterpriseSession boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( username, password, cmsName, authType);

            /************************** RETRIEVE INFOOBJECT FOR THE WEBI DOCUMENT **************************/

            // Retrieve the IInfoStore object
            IInfoStore boInfoStore =(IInfoStore) boEnterpriseSession.getService("InfoStore");  
            session.setAttribute("SAMPLE.InfoStore", boInfoStore);  

            // Build query to retrieve the universe InfoObjects
            String sQuery = "SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND='" + CeKind.WEBI + "' AND SI_NAME='" + webiDocName + "'";

            // Execute the query
            IInfoObjects boInfoObjects = (IInfoObjects) boInfoStore.query(sQuery);

            // Retrieve the InfoObject for the Web Intelligence document
            IInfoObject boInfoObject = (IInfoObject) boInfoObjects.get(0);

            /************************** RETRIEVE DOCUMENT INSTANCE FOR THE WEBI DOCUMENT **************************/

            // Retrieve the Report Engines
            ReportEngines boReportEngines = (ReportEngines) boEnterpriseSession.getService("ReportEngines");;
            
            // Retrieve the Report Engine for Web Intelligence documents
            ReportEngine boReportEngine = boReportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);

            // Retrieve the document instance for the Web Intelligence document
            DocumentInstance boDocumentInstance = boReportEngine.openDocument(boInfoObject.getID());

            ReportStructure boReportStructure = boDocumentInstance.getStructure();
            out.print(traverseReportStructure(boReportStructure));
            
            out.print("<HR>Process Complete!<HR>");

            boDocumentInstance.closeDocument();
            boReportEngine.close();
            boEnterpriseSession.logoff();

Functions:

String traverseReportStructure(ReportStructure boReportStructure) {
            String output = "";

            for (int i=0; i<boReportStructure.getReportElementCount(); i++) {
                        output += traverseReportElement(boReportStructure.getReportElement(i), 0);
            }
            
            return output;
}

String traverseReportElement(ReportElement boReportElement, int level) {
            String output = "";
            String padding = getPadding(level);

            if (boReportElement instanceof ReportContainer) {
                        output += padding + "Report Name: " + ((ReportContainer) boReportElement).getName() + "<BR>";
            } else if (boReportElement instanceof PageHeaderFooter) {
                        if (((PageHeaderFooter) boReportElement).isHeader()) {
                                    output += padding + "Report Header<BR>";
                        } else {
                                    output += padding + "Report Footer<BR>";
                        }
            } else if (boReportElement instanceof ReportBody) {
                        output += padding + "Report Body<BR>";
            } else if (boReportElement instanceof Cell) {
                        output += padding;
                        output += "Cell ID: " + ((Cell) boReportElement).getID() + " - ";
                        output += getAlerters(((Cell) boReportElement).getAlerters(), level+1);
            } else if (boReportElement instanceof ReportBlock) {
                        output += padding + "Block Name: " + ((ReportBlock) boReportElement).getName() + "<BR>";
                        output += traverseReportBlock((ReportBlock) boReportElement, level+1);
            } else {
                        output += padding + boReportElement.getClass().getName() + "<BR>";
            }
            
            for (int i=0; i<boReportElement.getReportElementCount(); i++) {
                        output += traverseReportElement(boReportElement.getReportElement(i), level+1);
            }

            return output;
}

String traverseReportBlock(ReportBlock boReportBlock, int level) {
            String output = "";
            String padding = getPadding(level);

            Representation boRepresentation = boReportBlock.getRepresentation();
            output += padding + "Block type is [" + boRepresentation.getClass().getName() + "].<BR>"; 

            if (boRepresentation instanceof SimpleTable) {
                        SimpleTable boSimpleTable = (SimpleTable) boRepresentation;

                        output += padding + "Processing SimpleTable...<BR>";

                        output += padding + "Block Header<BR>" + traverseCellMatrix(boSimpleTable.getHeader(null), level+1);
                        output += padding + "Block Body<BR>" + traverseCellMatrix(boSimpleTable.getBody(), level+1);
                        output += padding + "Block Footer<BR>" + traverseCellMatrix(boSimpleTable.getFooter(null), level+1);
            } else {
                        output += padding + "Unhandled Block Type...<BR>";
            }

            return output;
}

String traverseCellMatrix(CellMatrix boCellMatrix, int level) {
            String output = "";
            String padding = getPadding(level);

            if (boCellMatrix.getRowCount()>0) {
                        TableCell boTableCell = null;
                        for (int i=0; i<boCellMatrix.getColumnCount(); i++) {
                                    boTableCell = (TableCell) boCellMatrix.getCell(0, i);
                                    output += padding + "Column: " + i + " - " + boTableCell.getText() + " - ";
                                    output += getAlerters(boTableCell.getAlerters(), level+1);
                        }
            } else {
                        output += padding + "No Cells.<BR>";
            }

            return output;
}

String getAlerters(Alerters boAlerters, int level) {
            String output = "";
            String padding = getPadding(level);

            if (boAlerters.getCount()<=0) {
                        output += "No alerters.<BR>";
            } else {
                        output += "Alerters found!<BR>";

                        Alerter boAlerter = null;
                        for (int i=0; i<boAlerters.getCount(); i++) {
                                    boAlerter = boAlerters.getAlerter(i);

                                    output += padding + "<B>" + boAlerter.getName() + "</B><BR>";
                        }
            }

            return output;
}

String getPadding(int level) {
            String output = "";

            for (int i=0; i<level; i++) {
                        output += "     ";
            }

            return output;
}

Edited by: Dan Cuevas on May 25, 2009 9:45 PM

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question