How do you reference a Formular Object on a Crystal Report using Java

Hi all,
I am trying to reference an object on my report which contains a Formula field.
I have read the following 2 threads, but they refer to textObjects:
[How do you reference a textObject on a Crystal report using Java|Re: How do you reference a textObject on a Crystal report using Java?]
[Changing the text of ITextObject programatically|Re: Changing the text of ITextObject programatically]
But I cannot even get those to work. I can reference a object which refers to a database field but as soon as I try
reference a textObject or reportObject I just get a NULL variable.
Below is the code I am useing
IReportObject dbField = reportClientDocument.getReportDefController().findObjectByName("BOB1");
IReportObject textBob = reportClientDocument.getReportDefController().findObjectByName("BOB2");
"BOB1" is the name of my DB field Object, and "BOB2" can be a Text box or a Formula item and I just get nothing.
I have just tested it with a FieldHeadingObject and that returns a valid object, so clearly I am going about this the wrong way
for objects I place on the reports which are not driven by the database items.
Ultimately what I want to do is reference an object in the Report Footer which will contain the RecordCount of the number of
records contained in the report, which I am them going to use to determine if the report holds data,
if it does I will print it, else ignore it and move on the the next report. I am doing this so that I can at an extra filter to split
a report up into groups and produce a sinlge PDF for each group instead of one massive PDF containing all the groups.
So if someone has a solution to any of my problems I would be very greatful, and I dont mind being told Im an idiot and should
rather do it another way, as long as you supply that other way
Thanks for the help
Darren
Edited by: Darren Jackson on Dec 16, 2009 7:29 PM
Forgot to add am using CR4Ev2 SP3

Right I have made some headway.
Firstly, Im an idiot. I was making changes and setting up test fields on my report, but then when running the app, I had it looking at
the backup report, which would explain why all the new textbox fields were not being found.
The stupiditity did force me to delve deep and work out a fair bit of how the reports work, so cant complain too much. BUT, I am still
not able to return values of Formula fields and formulas extra. Could someone tell me if this is even possible. I get retrieve the formula field
name, and properties but not its value once the report has been populated. Am I wasting my time?
Well I will continue dismantling my reports till I find the answer, or someone points me in the right direction.
If any one is interested this is the code I used to drill down to my text boxes:
IReportObject recCount = reportClientDocument.getReportDefController().findObjectByName("TB1");
ITextObject obj_RecCount = (ITextObject) recCount;
System.out.println(obj_RecCount.getName());
Paragraphs objP = obj_RecCount.getParagraphs();
for (int i = 0; i < objP.size(); i++){
     ParagraphElements pE = objP.getParagraph(i).getParagraphElements();
     for (int j = 0;j < pE.size(); j++){
          IParagraphTextElement pEE = (ParagraphTextElement) pE.getParagraphElement(j);
          System.out.println(pEE.getText());
Cheers

Similar Messages

  • How do you reference a textObject on a Crystal report using Java?

    Hi,
    Could someone please tell me the java statement to reference a textObject on a Crystal report. I am struggling to find the info in the docs and work out how the object model works.
    My textObject on the report is called "VersionNumber" and I want to locate it on the report (I know it will be in the page footer) and then retrieve its value and change it.
    I've managed to get a handle to the report using,
    ReportClientDocument localDoc;
    localDoc = getReport();
    localDoc.open("rassdk://" + reportFile.getAbsolutePath(), OpenReportOptions._openAsReadOnly);
    Any help would be much appreciated.
    Regards
    Rob.

    I've found a way of referencing the textObject using the following line of java code (used in conjunction with the preceding code).
    IReportObject iro = localDoc.getReportDefController().findObjectByName("VersionNumber");
    I can put "iro" into a Watch (within Eclipse) and I can find the contents of the textObject there under the Paragraph tree, but I am now stuck with how to reference this within Java.
    If anyone can help it would be much appreciated (and I will of course award points !)
    Regards
    Robert.

  • How do you reference a created global variable in a report text field?

    I have created a parameter using the Globaldim statement in a script file. when I reference this parameter in any other script file during the current DIAdem session the value is passed without any issue.  Call the variable parmxyz where I assign it a value of 25.3 
    The help section under Globaldim mentions that global variables can be referenced in all panels, scripts, and dialogue boxes.  When I try to insert a text box on a report page using the @@parmxyz@@ it returns NOVALUE where I expect to see 25.3 (for example).
    When I substitute @@CurrDate@@ I do get the date, so I know the text box is valid.  What am I doing wrong?
    Steve    M 

    Hello Steve!
    It should work the way you did it. But their are some circumstances wich might prevent it:
    You have reseted the global script engine. All variables will be lost.
    You have a Sub with the same name in a command extension script. There is no warning ;-)
    One Test you can make is to put in '@@TypeName(paramxy)@@' as the expression to see the variable type. You can also try a realy unique variable name. The last option is to use ItemInfoGet to get detailed infos about your variable.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • How to find out all the text elements in the report using Java?

    How to trace the contents of an rpt file?
    I am able to open the rpt file in my report viewer but can not trace it using the JAVA code.
    Actually, I need to find out all the text elements of rpt (Report) file and replace them with the contents of resource bundle.
    My Java code to open a report is given below:
    import com.crystaldecisions.reports.sdk.ISubreportClientDocument;
    import com.crystaldecisions.reports.sdk.ParameterFieldController;
    import com.crystaldecisions.reports.sdk.ReportClientDocument;
    import com.crystaldecisions.sdk.occa.report.data.ConnectionInfo;
    import com.crystaldecisions.sdk.occa.report.data.ConnectionInfos;
    import com.crystaldecisions.sdk.occa.report.data.Fields;
    import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
    import com.crystaldecisions.sdk.occa.report.data.ParameterField;
    import com.crystaldecisions.sdk.occa.report.data.ParameterFieldDiscreteValue;
    import com.crystaldecisions.sdk.occa.report.data.Values;
    import com.crystaldecisions.sdk.occa.report.lib.IStrings;
    import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;
    import com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper;
    import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
    import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
    public String viewRpt()
                   //1.) Setting Database Infos
                            IConnectionInfo iConnectionInfoObj=setDatabaseConnectionInfos();
                   //2.) Setting Report Path
                   String reportPath=u201DE:
    was60
    rptFilesLocation
    u201D;
                   reportPath=(reportPath!=null)?                                             reportPath:AppConstants.CONSTANTS.BLANK;
                   String reportName="report1.rpt";
                   String reportFullPath = reportPath +   rptName;
                 //3.) Setting Report Source
                             ReportClientDocument reportClientDoc = new ReportClientDocument();
                                              reportClientDoc.open(reportPath, 0);
                  IReportSource reportSource = reportClientDoc.getReportSource();
                  setReportSource(reportSource);
                  reportClientDoc.close();
              //4.) Setting the Fields Starts
              setFieldsCrystal(null);
              Fields fields = new Fields();
              ParameterField pfield1 = new ParameterField();
              Values vals1 = new Values();
              ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue();
              pfield1.setName("@parameter1");
              pfieldDV1.setValue(u201Cvalue1u201D);
              vals1.add(pfieldDV1);
              pfield1.setCurrentValues(vals1);
              fields.add(pfield1);
              pfield1 = new ParameterField();
              vals1 = new Values();
              pfieldDV1 = new ParameterFieldDiscreteValue();
              pfield1.setName("@parameter2");
              pfieldDV1.setValue(u201Cvalue2u201D);
              vals1.add(pfieldDV1);
              pfield1.setCurrentValues(vals1);
              fields.add(pfield1);
              setFieldsCrystal(fields);
              //Setting the Fields Ends
    The sample jsp code to view the report is as follows:
    <%@taglib uri="http://www.businessobjects.com/jsf/crystalreportsviewers"
         prefix="bocrv"%>
    <bocrv:reportPageViewer viewerName="CrystalViewer"
                                                 reportSource="#{CrystalReportBeanObject.reportSource}"
                                                 displayToolbarRefreshButton="false"
                                                 allowDatabaseLogonPrompting="false"
                                                 allowParameterPrompting="false"
                                                 databaseLogonInfos="#{CrystalReportBeanObject.connectionInfosCrystal}"
                                                 parameterFields="#{CrystalReportBeanObject.fieldsCrystal}"
                                                 displayGroupTree="false" displayToolbarLogo="false"
                                                 displayToolbarToggleTreeButton="false"
                                                 enablePageToGrow="false" height="540"
                                                 zoomPercentage="100" width="750"
                                                 allowDrillDown="false"
                                                 displayToolbarPrintButton="true"
                                                 printMode="PDF"
                                                 ></bocrv:reportPageViewer>
    Edited by: JayKumarSharma on Mar 23, 2011 12:42 PM

    This is how you retrieve all the text fields in the reort:
    ReportObjects reportObjects = (ITextObject) oReportClientDocument.getReportDefController().getReportObjectController().getReportObjectsByKind(ReportObjectKind.text);
    for(int i=0; i< reportObjects.size();i++)
    ITextObject textObject = (ITextObject)reportObjects.get(i);
    // use ReportObjectController to modify the text object.
    If you want to modify the contents of the text element, you can do it as follows:
    TextObject oTextObject = new TextObject();
    Paragraphs oParagraphs = new Paragraphs();
    Paragraph oParagraph = new Paragraph();
    ParagraphElements oParagraphElements = new ParagraphElements();
    ParagraphTextElement oParagraphTextElement = new ParagraphTextElement();
    oParagraphTextElement.setText("This is the new text field");
    oParagraphTextElement.setKind(ParagraphElementKind.text);
    oReportClientDocument.getReportDefController().getReportObjectController().modify(textObject, oTextObject);
    oReportClientDocument.save();

  • How can i reference a MIME object within a correspondence format through...

    how can i reference a MIME object within a correspondence format through TX oofo or se71?
    Hi, I need to put a MIME object within a correspondence's format that i've already done through Tx oofo. My problem is, that i don't know exactly how can i make the reference of that MIME object in the format? and What structure type do i have to use in order to make appear the MIME object in my correspondence's format? Does anybody can help me with this?   
    Regards    Hector

    Frank,
    I tried to find some examples/samples on how to create CollectionModel for a table component but not successful.
    Can you clarify the following ?
    1. "CollectionModel" is referenced only by af:table attributes "value", "selectedRowKeys" and "selectionListener".
    The rest of af:table attributes such as "rows", "fetchSize" used to reference the iterator binding in the binding container via the EL expression "#{bindings.VOIteratorBinding.xxx} .
    What should I replace that EL expression with?
    2. I heck out the bean method to create the CollectionModel as following, is it close to what you mean?
    public void initBusinessDataDashboardView() {
    OperationBinding operation = BeanUtils.getOperationBinding("getPanelBusinessData");
    Map params = operation.getParamsMap();
    Key panelKey = getPanelInfoView().getKey();
    params.put("panelKey", panelKey);
    params.put("maximizedView", false);
    panelView = (ViewObject)operation.execute();
    // Heck code to create CollectionModel
    RowSet rowSet = panelView.getRowSet();
    ArrayList rowList = new ArrayList();
    while (rowSet.hasNext()) {
    rowList.add(rowSet.next());
    model = new ChildPropertyTreeModel(rowList, null);
    // To be used to set up af:table value, selectRowKeys, selectionListener via EL expr #{backingBeanScope.MyBean.model.xxx}
    public CollectionModel getModel() {
    return model;
    Am I on the right track?
    Edited by: Pricilla on May 4, 2010 2:20 PM

  • How do you test any SAP objects before a transport to the production server

    How do you test any SAP objects before a transport to the production server?

    Hi Rama Krishna,
       The actual process is develop the object in development system and unit test there with the available data.
      Then move it to Quality server where the data will be the actual replica of production and where the integration testing and ened to end testing happens and also the user acceptance testing  happens there.
    and once everything is found fine there then it is moved to production system.
    Award points if this is helpful.
    Regards,
    Ravi G

  • How to add OLE wordpad objects to a crystal report through VB program

    Can we programmatically add OLE wordpad objects to a crystal report XI r 2. through VB.NET or VB6?
    And is there a way of treating a database binary/blob field as an ole object in CR?

    Hi Mohan,
    Try it in the Designer first. If it works in the designer then it will work in our SDK's but you'll have to use RAS. So when you post your question to the .NET Development - Crystal Reports Forum be sure to specify what version you are using and anything else as far as versions go.
    It may be easier to simply link the OLE Object in the designer, check the help file out on how to.
    Thank you
    Don

  • How do you open the DVD tray on a K430 without using Windows Explorer?

    How do you open the DVD tray on a K430 without using Windows Explorer? I can't find a button on or below the door.  Am I missing something?  Additionally, will the K430 boot from a DVD/CD if it finds one in the DVD tray instead of the hard disk?  Please help. Thanks. 
    Solved!
    Go to Solution.

    hi penguin247,
    Regarding your questions:
    1. Can you try to press the eject symbol on the DVD bay and observe if the DVD tray comes out.
    Link to picture
    2. By default, the HDD is set as the first boot device and the ODD second on the K430. You will need to change the boot order or continuously tap F12 during POST to boot from the ODD (assuming you have a bootable media inserted).
    Regards
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • How do you increase the font size to bigger than 24, using the typewriter tool in Adobe Acrobat Pro 9 for Mac?

    How do you increase the font size to bigger than 24, using the typewriter tool in Adobe Acrobat Pro 9 for Mac?   Often I just want to label an item on a map that is in PDF and want to use a simple label rather than a Text Box for labeling, but have yet to find a way to increase the font size beyond 24.   Can someone help me with this? - JML

    Read this:
    https://forums.adobe.com/thread/1468782?sr=stream&ru=2382437

  • How do you make clips go in slowmotion and play reversed using imovie 08

    how do you make clips go in slowmotion and play reversed using imovie 08

    as owner of iM08, you're entitled for a free download here:
    http://www.apple.com/support/downloads/imovieHD6.html
    Plan B) using a designated 'slow mo' software, link, demo and how-to on my site:
    http://karsten.schluter.googlepages.com/slowmowithim08

  • HT2477 Just bought a Mac book and the set up is with the Voice over key commands,how do you switch this off as it is painfull to use and use the scroll pad

    Just bought a Mac book and the set up is with the Voice over key commands,how do you switch this off as it is painfull to use and use the scroll pad?

    It's the button (key) that is labelled Control.
    Each of the modifier keys and similar keys has its own symbol; this makes listing command keys easier to do. The Command key is usually the only key which has its symbol printed on the key. If you open Keyboard Viewer (in the Input menu, the one which displays the flag in the main menu bar), you can see what symbol refers to which key.

  • TS3212 how can you remove the pop-up blocker when dowload itunes using google chrome

    how can you remove the pop-up blocker when dowload itunes using google chrome ??

    Set that domain as '''Allowed'''. <br />
    https://support.mozilla.com/en-US/kb/Pop-up%20blocker#w_pop-up-blocker-settings

  • How do you open a picture that has had text added using software such as Windows Photo Gallery?

    How do you open a picture that has had text added using software such as Windows Photo Gallery?

    In Editor, go to File menu>open, and point to where the photo file is on disk.

  • How do you change categories in both transactions and budget report in the personal budget template in Numbers?

    How do you change categories in both transactions and budget report in the personal budget template in Numbers?
    I am working on both an iPad mini and a MacBook Air. 
    Whenever I change the category name in the budget report, it does not actually show up in the transactions tab when I am using the Personal Budget Template. 
    I have already tried copying and pasting a category in the budget report to add another row but it still does not show up in the transactions tab. 

    Hi golmeda,
    Check out this answer here:
    Using Numbers Personal Budget template I can't figure out how to change the categories in both tabs (budget and transact…
    If it is unclear let me know.
    quinn

  • How to create a report with data using the Crystal Reports for Java SDK

    Hi,
    How do I create a report with data that can be displayed via the Crystal Report for Java SDK and the Viewers API?
    I am writing my own report designer, and would like to use the Crystal Runtime Engine to display my report in DHTML, PDF, and Excel formats.  I can create my own report through the following code snippet:
    ReportClientDocument boReportClientDocument = new ReportClientDocument();
    boReportClientDocument.newDocument();
    However, I cannot find a way to add data elements to the report without specifying an RPT file.  Is this possible?  I seems like it is since the Eclipse Plug In allows you to specify your database parameters when creating an RPT file.
    is there a way to do this through these packages?
    com.crystaldecisions.sdk.occa.report.data
    com.crystaldecisions.sdk.occa.report.definition
    Am I forced to create a RPT file for the different table and column structures I have? 
    Thank you in advance for any insights.
    Ted Jenney

    Hi Rameez,
    After working through the example code some more, and doing some more research, I remain unable to populate a report with my own data and view the report in a browser.  I realize this is a long post, but there are multiple errors I am receiving, and these are the seemingly essential ones that I am hitting.
    Modeling the Sample code from Create_Report_From_Scratch.zip to add a database table, using the following code:
    <%@ page import="com.crystaldecisions.sdk.occa.report.application.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.data.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.document.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.definition.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
    <%@ page import = "com.crystaldecisions.report.web.viewer.*"%>
    <%
    try { 
                ReportClientDocument rcd = new ReportClientDocument();
                rcd.newDocument();
    // Setup the DB connection
                String database_dll = "Sqlsrv32.dll";
                String db = "qa_start_2012";
                String dsn = "SQL Server";
                String userName = "sa";
                String pwd = "sa";
                // Create the DB connection
                ConnectionInfo oConnectionInfo = new ConnectionInfo();
                PropertyBag oPropertyBag1 = oConnectionInfo.getAttributes();
                // Set new table logon properties
                PropertyBag oPropertyBag2 = new PropertyBag();
                oPropertyBag2.put("DSN", dsn);
                oPropertyBag2.put("Data Source", db);
                // Set the connection info objects members
                // 1. Pass the Logon Properties to the main PropertyBag
                // 2. Set the Server Description to the new **System DSN**
                oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, oPropertyBag2);
                oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, dsn);
                oPropertyBag1.put("Database DLL", database_dll);
                oConnectionInfo.setAttributes(oPropertyBag1);
                oConnectionInfo.setUserName(userName);
                oConnectionInfo.setPassword(pwd);
                // The Kind of connectionInfos is CRQE (Crystal Reports Query Engine).
                oConnectionInfo.setKind(ConnectionInfoKind.CRQE);
    // Add a Database table
              String tableName = "Building";
                Table oTable = new Table();
                oTable.setName(tableName);
                oTable.setConnectionInfo(oConnectionInfo);
                rcd.getDatabaseController().addTable(oTable, null);
        catch(ReportSDKException RsdkEx) {
                out.println(RsdkEx);  
        catch (Exception ex) {
              out.println(ex);  
    %>
    Throws the exception
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed
    There was other sample code on SDN which suggested the following - adding the table after calling table.setDataFields() as in:
              String tableName = "Building";
                String fieldname = "Building_Name";
                Table oTable = new Table();
                oTable.setName(tableName);
                oTable.setAlias(tableName);
                oTable.setQualifiedName(tableName);
                oTable.setDescription(tableName) ;
                Fields fields = new Fields();
                DBField field = new DBField();
                field.setDescription(fieldname);
                field.setHeadingText(fieldname);
                field.setName(fieldname);
                field.setType(FieldValueType.stringField);
                field.setLength(40);
                fields.add(field);
                oTable.setDataFields(fields);
                oTable.setConnectionInfo(oConnectionInfo);
                rcd.getDatabaseController().addTable(oTable, null);
    This code succeeds, but it is not clear how to add that database field to a section.  If I attempt to call the following:
    FieldObject oFieldObject = new FieldObject();
                oFieldObject.setDataSourceName(field.getFormulaForm());
                oFieldObject.setFieldValueType(field.getType());
                // Now add it to the section
                oFieldObject.setLeft(3120);
                oFieldObject.setTop(120);
                oFieldObject.setWidth(1911);
                oFieldObject.setHeight(226);
                rcd.getReportDefController().getReportObjectController().add(oFieldObject, rcd.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0), -1);
    Then I get an error (which is not unexpected)
    com.crystaldecisions.sdk.occa.report.lib.ReportDefControllerException: The field was not found.---- Error code:-2147213283 Error code name:invalidFieldObject
    How do I add one of the table.SetDataFields()  to my report to be displayed?
    Are there any other pointers or suggestions you may have?
    Thank you

Maybe you are looking for