on 10-03-2008 7:34 AM
Hi,
We can create variables which can be formulas applied on objects using infoview.
Is there any way, these variables can be created using java BO SDK?
Please paste some sample code for us.
Cheers,
Shruti
Hi
I want to create variables for the webintelligence reports.
Does the above code pasted, will work for webi as well? I assume that the code pasted is for deski reports
Thanks,
Shruti.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The above code is for Crystal Reports only, using the Report Application Server SDK.
Below is for Web Intelligence, using the ReportEngine SDK:
reportContainer = documentInstance.createReport("Report1");
cell = reportContainer.getReportBody().createFreeCell(" Free Cell ");
cell.setX(20.0);
cell.setY(10.0);
cell.getFont().setName("Arial");
cell.getFont().setSize(16);
cell.getFont().setStyle(StyleType.BOLD);
reportBlock = reportContainer.getReportBody().createBlock();
reportBlock.setAttachTo(cell, VAnchorType.BOTTOM, HAnchorType.NONE);
dictionary = documentInstance.getDictionary();
// Add variable
variableExpression = dictionary.createVariable("Double floor size", ObjectQualification.MEASURE,
"=[Sales floor size sqFt]*2");
// Add cells to report.
blockAxis = reportBlock.getAxis(TableAxis.HORIZONTAL);
blockAxis.addExpr(dictionary.getChildByName("Double floor size"));
where the relevant bit is where you create a VariableExpression using createVariable method on the ReportDictionary (it's actually simpler than in InfoView).
Sincerely,
Ted Ueda
Thanks for the appraoch, it is working as expected
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Web Intelligence or Desktop Intelligence?
Sincerely,
Ted Ueda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please find below a snippet code based on java managed RAS api that adds a formula onto the report. I hope this answer your question.
<%@ include file="logon.jsp"%>
<%
ReportClientDocument oReportClientDocument;
IReportAppFactory oReportAppFactory;
IInfoObjects oInfoObjects=null;
IInfoObject oInfoObject=null;
String reportName = "SimpleRCAPIReport.rpt";
// Retrieve report to be modified
oInfoObjects = iStore.query("Select * from CI_INFOOBJECTS where SI_PROGID = 'CrystalEnterprise.Report' and SI_INSTANCE = 0 and SI_NAME = '" + reportName + "'");
oReportAppFactory = (IReportAppFactory)es.getService("", "RASReportService");
oReportClientDocument = oReportAppFactory.openDocument((IInfoObject)oInfoObjects.get(0), 0, java.util.Locale.ENGLISH);
// First create the formula field
FormulaField newFormulaField = new FormulaField();
// Set the parameters (assume it's a string and Crystal Syntax)
newFormulaField.setText("{Customer.Contact First Name} + ' ' + {Customer.Contact Last Name}");
newFormulaField.setName("CustomerName");
newFormulaField.setSyntax(FormulaSyntax.crystal);
newFormulaField.setType(FieldValueType.stringField);
// Now add it to the report
oReportClientDocument.getDataDefController().getFormulaFieldController().add(newFormulaField);
// Now that the formula has been created, add the newly created formula to the report
// First determine which section to add the formula field to - in this case the details section
ISection sectionToAddTo = oReportClientDocument.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0);
// Get back all the formulafields in the report
Fields formulaFields = oReportClientDocument.getDataDefController().getDataDefinition().getFormulaFields();
int formulaFieldIndex = formulaFields.find("{@CustomerName}", FieldDisplayNameType.formulaName, java.util.Locale.ENGLISH);
Field formulaField = (Field)formulaFields.getField(formulaFieldIndex);
// Set the type of field this is
formulaField.setType(FieldValueType.stringField);
// Now create a new Field object which will be added to the report
FieldObject oFieldObject = new FieldObject();
// Set the datasource of this field object to the formula form of the above Database Field Object
oFieldObject.setDataSourceName(formulaField.getFormulaForm());
oFieldObject.setFieldValueType(formulaField.getType());
// Now set the co-ordinates of where the field will go
oFieldObject.setLeft(8000);
oFieldObject.setTop(1);
oFieldObject.setWidth(1911);
oFieldObject.setHeight(226);
// And finally Add it to the report
oReportClientDocument.getReportDefController().getReportObjectController().add(oFieldObject, sectionToAddTo, -1);
// Now display the report
session.setAttribute("reportSource", oReportClientDocument.getReportSource());
response.sendRedirect("CrystalReportViewer.jsp");
%>
Cheers
Alphonse
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.